2024-10-22 17:15:35 +02:00
|
|
|
import type { Building } from "./types";
|
|
|
|
import { getEmptyResources } from "./utils";
|
2024-10-21 17:35:32 +02:00
|
|
|
import type { VillageState } from "./village";
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
2024-10-23 10:14:19 +02:00
|
|
|
'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
|
|
|
},
|
|
|
|
},
|
2024-10-23 10:14:19 +02:00
|
|
|
},
|
2024-10-21 17:35:32 +02:00
|
|
|
'woodcutter': {
|
|
|
|
name: 'Woodcutter',
|
|
|
|
cost: (level: number) => {
|
|
|
|
return {
|
|
|
|
wood: level * 10,
|
|
|
|
stone: level * 10,
|
|
|
|
iron: level * 10,
|
|
|
|
food: 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
behavior: {
|
2024-10-22 17:15:35 +02:00
|
|
|
production: (V: VillageState, self: Building) => {
|
|
|
|
const prod = getEmptyResources();
|
2024-10-21 17:35:32 +02:00
|
|
|
const outputPerMinute = 5 * (self.level * self.level);
|
2024-10-22 17:15:35 +02:00
|
|
|
prod.wood = outputPerMinute;
|
2024-10-23 10:36:03 +02:00
|
|
|
|
|
|
|
const intakePerMinute = Math.ceil(self.level / 5);
|
|
|
|
prod.food = -intakePerMinute;
|
|
|
|
|
2024-10-22 17:15:35 +02:00
|
|
|
return prod;
|
2024-10-23 10:36:03 +02:00
|
|
|
},
|
|
|
|
},
|
2024-10-21 17:35:32 +02:00
|
|
|
},
|
|
|
|
'mine': {
|
|
|
|
name: 'Mine',
|
|
|
|
cost: (level: number) => {
|
|
|
|
return {
|
|
|
|
wood: level * 10,
|
|
|
|
stone: level * 10,
|
|
|
|
iron: level * 10,
|
|
|
|
food: 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
behavior: {
|
2024-10-22 17:15:35 +02:00
|
|
|
production: (V: VillageState, self: Building) => {
|
|
|
|
const prod = getEmptyResources();
|
2024-10-21 17:35:32 +02:00
|
|
|
const outputPerMinute = 5 * (self.level * self.level);
|
2024-10-22 17:15:35 +02:00
|
|
|
prod.iron = outputPerMinute;
|
2024-10-23 10:36:03 +02:00
|
|
|
|
|
|
|
const intakePerMinute = Math.ceil(self.level / 5);
|
|
|
|
prod.food = -intakePerMinute;
|
|
|
|
|
2024-10-22 17:15:35 +02:00
|
|
|
return prod;
|
2024-10-23 10:36:03 +02:00
|
|
|
},
|
|
|
|
},
|
2024-10-21 17:35:32 +02:00
|
|
|
},
|
|
|
|
'pit': {
|
|
|
|
name: 'Pit',
|
|
|
|
cost: (level: number) => {
|
|
|
|
return {
|
|
|
|
wood: level * 10,
|
|
|
|
stone: level * 10,
|
|
|
|
iron: level * 10,
|
|
|
|
food: 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
behavior: {
|
2024-10-22 17:15:35 +02:00
|
|
|
production: (V: VillageState, self: Building) => {
|
|
|
|
const prod = getEmptyResources();
|
2024-10-21 17:35:32 +02:00
|
|
|
const outputPerMinute = 5 * (self.level * self.level);
|
2024-10-22 17:15:35 +02:00
|
|
|
prod.stone = outputPerMinute;
|
2024-10-23 10:36:03 +02:00
|
|
|
|
|
|
|
const intakePerMinute = Math.ceil(self.level / 5);
|
|
|
|
prod.food = -intakePerMinute;
|
|
|
|
|
2024-10-22 17:15:35 +02:00
|
|
|
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;
|
|
|
|
},
|
|
|
|
},
|
2024-10-21 17:35:32 +02:00
|
|
|
},
|
2024-10-22 17:15:35 +02:00
|
|
|
'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
|
|
|
};
|
|
|
|
},
|
2024-10-22 17:15:35 +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
|
|
|
};
|
|
|
|
},
|
2024-10-22 17:15:35 +02:00
|
|
|
},
|
|
|
|
},
|
2024-10-21 17:35:32 +02:00
|
|
|
};
|