Add fields and food consumption.

This commit is contained in:
Adrian 2024-10-23 10:36:03 +02:00
parent 6f1c3b3070
commit 16db8ee0be
2 changed files with 52 additions and 16 deletions

View File

@ -22,8 +22,8 @@ export default {
'iron': 100,
'food': 100,
}
}
}
},
},
},
'woodcutter': {
name: 'Woodcutter',
@ -40,9 +40,13 @@ export default {
const prod = getEmptyResources();
const outputPerMinute = 5 * (self.level * self.level);
prod.wood = outputPerMinute;
const intakePerMinute = Math.ceil(self.level / 5);
prod.food = -intakePerMinute;
return prod;
}
}
},
},
},
'mine': {
name: 'Mine',
@ -59,9 +63,13 @@ export default {
const prod = getEmptyResources();
const outputPerMinute = 5 * (self.level * self.level);
prod.iron = outputPerMinute;
const intakePerMinute = Math.ceil(self.level / 5);
prod.food = -intakePerMinute;
return prod;
}
}
},
},
},
'pit': {
name: 'Pit',
@ -78,9 +86,32 @@ export default {
const prod = getEmptyResources();
const outputPerMinute = 5 * (self.level * self.level);
prod.stone = outputPerMinute;
const intakePerMinute = Math.ceil(self.level / 5);
prod.food = -intakePerMinute;
return prod;
}
}
},
},
},
'field': {
name: 'Field',
cost: (level: number) => {
return {
wood: level * 10,
stone: level * 10,
iron: level * 10,
food: 0,
};
},
behavior: {
production: (V: VillageState, self: Building) => {
const prod = getEmptyResources();
const outputPerMinute = 5 * (self.level * self.level);
prod.food = outputPerMinute;
return prod;
},
},
},
'warehouse': {
name: 'Warehouse',
@ -101,8 +132,8 @@ export default {
'stone': capacity,
'iron': capacity,
'food': 0,
}
}
};
},
},
},
'granary': {
@ -124,8 +155,8 @@ export default {
'stone': 0,
'iron': 0,
'food': capacity,
}
}
};
},
},
},
};

View File

@ -1,4 +1,5 @@
import { writable } from "svelte/store";
import buildings from "./buildings";
import { createBuilding } from "./create";
import type { Building } from "./types";
@ -19,12 +20,16 @@ export interface VillageState {
const village = writable<VillageState>({
buildings: [
createBuilding(buildings.townhall),
createBuilding(buildings.woodcutter),
createBuilding(buildings.pit),
createBuilding(buildings.mine),
createBuilding(buildings.field),
],
resources: {
wood: 100,
stone: 100,
iron: 100,
food: 0,
wood: 60,
stone: 60,
iron: 60,
food: 50,
culture: 0,
},
});