bourgade/src/buildings.ts

163 lines
4.5 KiB
TypeScript
Raw Normal View History

import type { Building } from "./types";
import { getEmptyResources } from "./utils";
import type { VillageState } from "./village";
export default {
'townhall': {
name: 'Town Hall',
cost: (level: number) => {
return {
wood: level * 10,
stone: level * 10,
iron: level * 10,
food: 0,
};
},
behavior: {
storage: (_V: VillageState, _self: Building) => {
return {
'wood': 100,
'stone': 100,
'iron': 100,
'food': 100,
}
2024-10-23 10:36:03 +02:00
},
},
},
'woodcutter': {
name: 'Woodcutter',
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.wood = outputPerMinute;
2024-10-23 10:36:03 +02:00
const intakePerMinute = Math.ceil(self.level / 5);
prod.food = -intakePerMinute;
return prod;
2024-10-23 10:36:03 +02:00
},
},
},
'mine': {
name: 'Mine',
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.iron = outputPerMinute;
2024-10-23 10:36:03 +02:00
const intakePerMinute = Math.ceil(self.level / 5);
prod.food = -intakePerMinute;
return prod;
2024-10-23 10:36:03 +02:00
},
},
},
'pit': {
name: 'Pit',
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.stone = outputPerMinute;
2024-10-23 10:36:03 +02:00
const intakePerMinute = Math.ceil(self.level / 5);
prod.food = -intakePerMinute;
return prod;
2024-10-23 10:36:03 +02:00
},
},
},
'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',
cost: (level: number) => {
return {
wood: level * 10,
stone: level * 10,
iron: level * 10,
food: 0,
};
},
behavior: {
storage: (V: VillageState, self: Building) => {
const x = self.level;
const capacity = ( ( ( x + ( x * x ) ) / 2 ) + 3 ) * 25;
return {
'wood': capacity,
'stone': capacity,
'iron': capacity,
'food': 0,
2024-10-23 10:36:03 +02:00
};
},
},
},
'granary': {
name: 'Granary',
cost: (level: number) => {
return {
wood: level * 10,
stone: level * 10,
iron: level * 10,
food: 0,
};
},
behavior: {
storage: (V: VillageState, self: Building) => {
const x = self.level;
const capacity = ( ( ( x + ( x * x ) ) / 2 ) + 3 ) * 25;
return {
'wood': 0,
'stone': 0,
'iron': 0,
'food': capacity,
2024-10-23 10:36:03 +02:00
};
},
},
},
};