Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Hot fix demands calculation and correct "productionTime" of "Coal Mine"
Browse files Browse the repository at this point in the history
  • Loading branch information
suhrmann committed Nov 4, 2020
1 parent fe66961 commit 1e34885
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "anno-1800-calculator",
"productName": "Anno 1800 Calculator",
"version": "0.4.3",
"version": "0.4.4",
"description": "Calculate your populations' demands and optimal production chains.",
"contributors": [
"Simon Uhrmann <suhrmann@posteo.de>",
Expand Down
26 changes: 13 additions & 13 deletions src/components/resident_demands/ResidenceInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -320,27 +320,27 @@
</template>

<script>
import ResidenceData from '@/data/residence.json'
import Population from '@/data/population.json'
export default {
name: 'BottomPopulationInput',
data: function () {
return {
farmersPerResidence: ResidenceData.farmers.residence,
workersPerResidence: ResidenceData.workers.residence,
artisansPerResidence: ResidenceData.artisans.residence,
engineersPerResidence: ResidenceData.engineers.residence,
investorsPerResidence: ResidenceData.investors.residence,
scholarsPerResidence: ResidenceData.scholars.residence, // TODO VALIDATE! Unknown by now
farmersPerResidence: Population.farmers.residence,
workersPerResidence: Population.workers.residence,
artisansPerResidence: Population.artisans.residence,
engineersPerResidence: Population.engineers.residence,
investorsPerResidence: Population.investors.residence,
scholarsPerResidence: Population.scholars.residence, // TODO VALIDATE! Unknown by now
jornalerosPerResidence: ResidenceData.jornaleros.residence,
obrerosPerResidence: ResidenceData.obreros.residence,
jornalerosPerResidence: Population.jornaleros.residence,
obrerosPerResidence: Population.obreros.residence,
explorersPerResidence: ResidenceData.explorers.residence,
techniciansPerResidence: ResidenceData.technicians.residence,
explorersPerResidence: Population.explorers.residence,
techniciansPerResidence: Population.technicians.residence,
shepherdsPerResidence: ResidenceData.shepherds.residence, // TODO VALIDATE! Unknown by now
eldersPerResidence: ResidenceData.elders.residence // TODO VALIDATE! Unknown by now
shepherdsPerResidence: Population.shepherds.residence, // TODO VALIDATE! Unknown by now
eldersPerResidence: Population.elders.residence // TODO VALIDATE! Unknown by now
}
},
computed: {
Expand Down
35 changes: 30 additions & 5 deletions src/components/resident_demands/residentDemandCalculatorMixin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Consumption from '@/data/consumption.json'
import ConsumptionPerResidence from '@/data/consumption.json'
import Producers from '@/data/producers.json'
import NonProducers from '@/data/non-producers.json'
import Population from '@/data/population.json'

import {
chainNodeMixin
} from '../production_chains/chainNodeMixin'
Expand All @@ -15,10 +17,33 @@ export default {
return {
producers: Producers,
nonProducers: NonProducers,
consumption: Consumption
consumptionPerResidence: ConsumptionPerResidence,
population: Population
}
},

computed: {

/**
* "The amount of goods each residence of this tier consumes every second."
* So for this population based calculation we need to convert it to "consumption per population".
*/
consumptionPerPopulation () {
const consumption = JSON.parse(JSON.stringify(this.consumptionPerResidence)) // Clone consumptionPerResidence
// Convert value per residence to per population
Object.keys(consumption).forEach(pop => {
Object.keys(consumption[pop]).forEach(type => {
Object.keys(consumption[pop][type]).forEach(demand => {
const populationPerResidence = this.population[pop].residence
consumption[pop][type][demand] = consumption[pop][type][demand] / populationPerResidence
})
})
})

console.log('consumption: ', consumption)
return consumption
},

numPopulation: function () {
return this.$store.state.population
},
Expand All @@ -41,13 +66,13 @@ export default {
totalDemands: function () {
// Merge all demands
const _self = this
const demands = Object.assign(...Object.keys(this.consumption).map(
const demands = Object.assign(...Object.keys(this.consumptionPerPopulation).map(
pop => {
const numPopStr = 'num' + pop.charAt(0).toUpperCase() + pop.slice(1) // build e.g. "numFarmers" from "farmers"
return {
[pop]: {
basic: _self.calculateDemands(_self.consumption[pop].basic, _self.numPopulation[numPopStr]),
luxury: _self.calculateDemands(_self.consumption[pop].luxury, _self.numPopulation[numPopStr])
basic: _self.calculateDemands(_self.consumptionPerPopulation[pop].basic, _self.numPopulation[numPopStr]),
luxury: _self.calculateDemands(_self.consumptionPerPopulation[pop].luxury, _self.numPopulation[numPopStr])
}
}
}
Expand Down
37 changes: 24 additions & 13 deletions src/data/population.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,90 @@
"id": 1,
"name": "Farmers",
"img": "farmers.webp",
"firstProductionChain": 1
"firstProductionChain": 1,
"residence": 10
},
"workers": {
"id": 2,
"name": "Workers",
"img": "workers.webp",
"firstProductionChain": 5
"firstProductionChain": 5,
"residence": 20
},
"artisans": {
"id": 3,
"name": "Artisans",
"img": "artisans.webp",
"firstProductionChain": 13
"firstProductionChain": 13,
"residence": 30
},
"engineers": {
"id": 4,
"name": "Engineers",
"img": "engineers.webp",
"firstProductionChain": 28

"firstProductionChain": 28,
"residence": 40
},
"investors": {
"id": 5,
"name": "Investors",
"img": "investors.webp",
"firstProductionChain": 35
"firstProductionChain": 35,
"residence": 50
},
"scholars": {
"id": 8,
"name": "Scholars",
"img": "scholars.webp",
"firstProductionChain": 39
"firstProductionChain": 39,
"residence": 60
},


"jornaleros": {
"id": 6,
"name": "Jornaleros",
"img": "jornaleros.webp",
"firstProductionChain": 17
"firstProductionChain": 17,
"residence": 10
},
"obreros": {
"id": 7,
"name": "Obreros",
"img": "obreros.webp",
"firstProductionChain": 22
"firstProductionChain": 22,
"residence": 20
},


"explorers": {
"id": 9,
"name": "Explorers",
"img": "explorers.webp",
"firstProductionChain": 45
"firstProductionChain": 45,
"residence": 10
},
"technicians": {
"id": 10,
"name": "Technicians",
"img": "technicians.webp",
"firstProductionChain": 49
"firstProductionChain": 49,
"residence": 20
},


"shepherds": {
"id": 11,
"name": "Shepherds",
"img": "shepherd.webp",
"firstProductionChain": 51
"firstProductionChain": 51,
"residence": 10
},
"elders": {
"id": 12,
"name": "Elders",
"img": "elders.webp",
"firstProductionChain": 55
"firstProductionChain": 55,
"residence": 20
}
}
2 changes: 1 addition & 1 deletion src/data/producers.json
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
"building": "Coal Mine",
"img": "artisans/coal.webp",
"regionID": 1,
"productionTime": 30,
"productionTime": 15,
"construction": {
"cash": 500,
"wood": 4,
Expand Down

0 comments on commit 1e34885

Please sign in to comment.