diff --git a/TODO.taskpaper b/TODO.taskpaper --- a/TODO.taskpaper +++ b/TODO.taskpaper @@ -29,7 +29,7 @@ - Add contract struct @milestone(3: Contracts) @nvm - Add tree simulation @milestone(3: Contracts) - Add contract generation @milestone(3: Contracts) - - Outline reserved areas @milestone(3: Contracts) @done(2021-04-15) + - Outline reserved areas @milestone(3: Contracts) @done(2021-04-09) - Add company images @milestone(3: Contracts) @maybe Trees: - Add basic maintenance cost @milestone(1: Basic Money) @done(2021-01-27) diff --git a/isometric-park-fna/Engines/SimulationBridgeEngine.cs b/isometric-park-fna/Engines/SimulationBridgeEngine.cs --- a/isometric-park-fna/Engines/SimulationBridgeEngine.cs +++ b/isometric-park-fna/Engines/SimulationBridgeEngine.cs @@ -53,10 +53,17 @@ // SetComponent(entity, new BudgetComponent{currentBudget = this.simulation.latestBudget, // priorBudget = this.simulation.previousBudget}); - if (status == ContractStatus.Accepted) + switch (budgetComponent.category) { - new_contract_amount += budgetComponent.amount; + case "Contracts": + + if (status == ContractStatus.Accepted) + { + new_contract_amount += budgetComponent.amount; + } + break; } + } simulation.contracts = new_contract_amount; diff --git a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs --- a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs @@ -14,6 +14,10 @@ { private Random random_generator; + public const int DEFAULT_SQUARES = 25; + public const int CONTRACT_MINIMUM = 50; + public const int CONTRACT_MAXIMUM = 250; + public ContractSpawner() { this.random_generator = new Random(); @@ -59,14 +63,19 @@ { var contract = CreateEntity(); - var squares = (message.squares == null) ? CreateArea(25, 25, 30) : message.squares; + var max_squares = (message.max_squares == null) ? DEFAULT_SQUARES : message.max_squares; + var squares = (message.squares == null) ? CreateArea(25, 25, max_squares) : message.squares; + + var contract_amount = random_generator.Next(CONTRACT_MINIMUM, CONTRACT_MAXIMUM); // AddComponent AddComponent(contract, new AreaComponent { squares = squares }); AddComponent(contract, new NameComponent { DisplayName = message.name }); AddComponent(contract, new ContractStatusComponent { status = ContractStatus.Proposed }); - AddComponent(contract, new BudgetLineComponent { category = "Contracts", amount = 100.0M }); + AddComponent(contract, new BudgetLineComponent { category = "Contracts", + //Round to the nearest $5 + amount = (decimal)((contract_amount/5)*5) }); } } -} \ No newline at end of file +} diff --git a/isometric-park-fna/Messages/SpawnContractMessage.cs b/isometric-park-fna/Messages/SpawnContractMessage.cs --- a/isometric-park-fna/Messages/SpawnContractMessage.cs +++ b/isometric-park-fna/Messages/SpawnContractMessage.cs @@ -7,5 +7,6 @@ { public Vector2[] squares; public string name; + public int max_squares; } -} \ No newline at end of file +}