Adjust the cost and construction time of all buildings.

This commit is contained in:
Adrian 2024-11-08 18:13:03 +01:00
parent 5a0369070e
commit ff7458757a
6 changed files with 70 additions and 43 deletions

View File

@ -3,6 +3,26 @@ import { getEmptyResources } from "../utils";
import type { VillageState } from "../village"; import type { VillageState } from "../village";
function getStandardTimeToBuild(level: number) {
return Math.round(Math.pow(level, 1 / 1.2) + 1);
}
function getResourceBuildingCost(level: number, initial: number) {
return initial * level * (level - 1);
}
function getStorageBuildingCost(level: number, initial: number) {
return initial * Math.round( (level + level * level) / 3);
}
function getUnitBuildingCost(level: number, initial: number) {
return initial * Math.round( (level + level * level) / 2);
}
export default [ export default [
{ {
type: 'townhall', type: 'townhall',
@ -17,6 +37,7 @@ export default [
food: 0, food: 0,
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
storage: (_V: VillageState, _self: BuildingType) => { storage: (_V: VillageState, _self: BuildingType) => {
return { return {
@ -35,12 +56,13 @@ export default [
maxLevel: 20, maxLevel: 20,
cost: (level: number) => { cost: (level: number) => {
return { return {
wood: level * 10, wood: getResourceBuildingCost(level, 6),
stone: level * 10, stone: getResourceBuildingCost(level, 10),
iron: level * 10, iron: getResourceBuildingCost(level, 14),
food: 0, food: getResourceBuildingCost(level, 10),
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
production: (V: VillageState, self: BuildingType) => { production: (V: VillageState, self: BuildingType) => {
const prod = getEmptyResources(); const prod = getEmptyResources();
@ -61,12 +83,13 @@ export default [
maxLevel: 20, maxLevel: 20,
cost: (level: number) => { cost: (level: number) => {
return { return {
wood: level * 10, wood: getResourceBuildingCost(level, 10),
stone: level * 10, stone: getResourceBuildingCost(level, 14),
iron: level * 10, iron: getResourceBuildingCost(level, 6),
food: 0, food: getResourceBuildingCost(level, 10),
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
production: (V: VillageState, self: BuildingType) => { production: (V: VillageState, self: BuildingType) => {
const prod = getEmptyResources(); const prod = getEmptyResources();
@ -87,12 +110,13 @@ export default [
maxLevel: 20, maxLevel: 20,
cost: (level: number) => { cost: (level: number) => {
return { return {
wood: level * 10, wood: getResourceBuildingCost(level, 14),
stone: level * 10, stone: getResourceBuildingCost(level, 6),
iron: level * 10, iron: getResourceBuildingCost(level, 10),
food: 0, food: getResourceBuildingCost(level, 10),
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
production: (V: VillageState, self: BuildingType) => { production: (V: VillageState, self: BuildingType) => {
const prod = getEmptyResources(); const prod = getEmptyResources();
@ -113,12 +137,13 @@ export default [
maxLevel: 20, maxLevel: 20,
cost: (level: number) => { cost: (level: number) => {
return { return {
wood: level * 10, wood: getResourceBuildingCost(level, 14),
stone: level * 10, stone: getResourceBuildingCost(level, 14),
iron: level * 10, iron: getResourceBuildingCost(level, 12),
food: 0, food: getResourceBuildingCost(level, 0),
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
production: (V: VillageState, self: BuildingType) => { production: (V: VillageState, self: BuildingType) => {
const prod = getEmptyResources(); const prod = getEmptyResources();
@ -134,12 +159,13 @@ export default [
maxLevel: 20, maxLevel: 20,
cost: (level: number) => { cost: (level: number) => {
return { return {
wood: level * 10, wood: getStorageBuildingCost(level, 15),
stone: level * 10, stone: getStorageBuildingCost(level, 20),
iron: level * 10, iron: getStorageBuildingCost(level, 10),
food: 0, food: getStorageBuildingCost(level, 15),
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
storage: (V: VillageState, self: BuildingType) => { storage: (V: VillageState, self: BuildingType) => {
const x = self.level; const x = self.level;
@ -159,12 +185,13 @@ export default [
maxLevel: 20, maxLevel: 20,
cost: (level: number) => { cost: (level: number) => {
return { return {
wood: level * 10, wood: getStorageBuildingCost(level, 12),
stone: level * 10, stone: getStorageBuildingCost(level, 22),
iron: level * 10, iron: getStorageBuildingCost(level, 10),
food: 0, food:getStorageBuildingCost(level, 6),
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
storage: (V: VillageState, self: BuildingType) => { storage: (V: VillageState, self: BuildingType) => {
const x = self.level; const x = self.level;
@ -184,12 +211,13 @@ export default [
maxLevel: 20, maxLevel: 20,
cost: (level: number) => { cost: (level: number) => {
return { return {
wood: level * 100, wood: getUnitBuildingCost(level, 75),
stone: level * 100, stone: getUnitBuildingCost(level, 90),
iron: level * 100, iron: getUnitBuildingCost(level, 50),
food: 0, food: getUnitBuildingCost(level, 45),
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
production: (V: VillageState, self: BuildingType) => { production: (V: VillageState, self: BuildingType) => {
const prod = getEmptyResources(); const prod = getEmptyResources();
@ -209,12 +237,13 @@ export default [
maxLevel: 20, maxLevel: 20,
cost: (level: number) => { cost: (level: number) => {
return { return {
wood: level * 100, wood: getUnitBuildingCost(level, 60),
stone: level * 100, stone: getUnitBuildingCost(level, 30),
iron: level * 100, iron: getUnitBuildingCost(level, 90),
food: 0, food: getUnitBuildingCost(level, 40),
}; };
}, },
timeToBuild: getStandardTimeToBuild,
behavior: { behavior: {
production: (V: VillageState, self: BuildingType) => { production: (V: VillageState, self: BuildingType) => {
const prod = getEmptyResources(); const prod = getEmptyResources();

View File

@ -3,9 +3,9 @@ export default [
type: 'philosopher', type: 'philosopher',
name: 'Philosopher', name: 'Philosopher',
cost: { cost: {
wood: 20, wood: 25,
stone: 50, stone: 55,
iron: 0, iron: 5,
food: 0, food: 0,
}, },
behavior: { behavior: {

View File

@ -29,7 +29,7 @@ export default function build(V: VillageState, buildingType: string, tile: Hex)
newBuilding.tile = tile; newBuilding.tile = tile;
newBuilding.level = 0; newBuilding.level = 0;
newBuilding.state.upgrade.isUpgrading = true; newBuilding.state.upgrade.isUpgrading = true;
newBuilding.state.upgrade.remainingTime = 1000 * (newBuilding.level + 1); newBuilding.state.upgrade.remainingTime = 1000 * newBuilding.timeToBuild(newBuilding.level + 1);
V.buildings.push(newBuilding); V.buildings.push(newBuilding);
V.villageTiles[tile.y][tile.x] = newBuilding.id; V.villageTiles[tile.y][tile.x] = newBuilding.id;

View File

@ -28,7 +28,7 @@ export default function upgradeBuilding(V: VillageState, buildingId: number) {
V.resources.food -= cost.food; V.resources.food -= cost.food;
building.state.upgrade.isUpgrading = true; building.state.upgrade.isUpgrading = true;
building.state.upgrade.remainingTime = 1000 * (building.level + 1); building.state.upgrade.remainingTime = 1000 * building.timeToBuild(building.level + 1);
return true; return true;
} }

View File

@ -12,14 +12,11 @@ export function createQuest(level: number): QuestType {
Object.keys(reward).forEach(r => { Object.keys(reward).forEach(r => {
const resource = r as keyof ResourcesType; const resource = r as keyof ResourcesType;
reward[resource] = random( reward[resource] = random(
duration * 5 - level * 10, Math.round((duration * 5 - level * 10) * (1 + level / 3)),
duration * 5 + level * 10, Math.round((duration * 5 + level * 10) * (1 + level / 3)),
); );
if (resource === 'food') { if (resource === 'culture') {
reward[resource] = Math.round(reward[resource] / 3);
}
else if (resource === 'culture') {
reward[resource] = Math.round(reward[resource] / 20); reward[resource] = Math.round(reward[resource] / 20);
} }
}); });

View File

@ -26,6 +26,7 @@ export interface BuildingSource {
autoBuilt?: boolean; autoBuilt?: boolean;
maxLevel: number; maxLevel: number;
cost: (level: number) => CostType; cost: (level: number) => CostType;
timeToBuild: (level: number) => number;
behavior: { behavior: {
production?: Function; production?: Function;
storage?: Function; storage?: Function;