fix: Add soldier button and implement wolf hunting mechanics

This commit is contained in:
Kacper Kostka (aider)
2025-04-02 11:59:49 +02:00
parent 5d2a98b494
commit 413aebf839
3 changed files with 199 additions and 5 deletions

15
game.js
View File

@@ -35,6 +35,7 @@ const COST_HOSPITAL = 500;
const COST_SCHOOL = 450;
const COST_SPAWNER = 500;
const COST_TREE = 50;
const COST_SOLDIER = 250;
// Earn money
const REWARD_DELIVER_WOOD = 5;
@@ -82,10 +83,11 @@ const SCHOOL_WOOD_REQUIRED = 65;
const SCHOOL_BUILD_RATE = 0.12;
// Professions
const PROFESSIONS = ["Farmer", "Builder", "Merchant", "Doctor", "Teacher"];
const PROFESSIONS = ["Farmer", "Builder", "Merchant", "Doctor", "Teacher", "Soldier"];
// Rabbits
// Animals
const STARTING_RABBITS = 10;
const STARTING_WOLVES = 3;
const RABBIT_HUNGER_INCREMENT = 0.003;
const RABBIT_REPRO_COOLDOWN = 3000;
const RABBIT_REPRO_CHANCE = 0.0005;
@@ -108,10 +110,14 @@ function initWorld() {
citizens.push(c);
logAction(`Initial Citizen joined: ${c.name} [Builder]`);
// Spawn some rabbits
// Spawn some animals
for(let i=0; i<STARTING_RABBITS; i++) {
animals.push(createAnimal("Rabbit", randInt(-1000,1000), randInt(-1000,1000)));
}
for(let i=0; i<STARTING_WOLVES; i++) {
animals.push(createAnimal("Wolf", randInt(-1000,1000), randInt(-1000,1000)));
}
requestAnimationFrame(update);
}
@@ -217,6 +223,7 @@ function updateHUD() {
const merchantCount = citizens.filter(c => c.profession === "Merchant").length;
const doctorCount = citizens.filter(c => c.profession === "Doctor").length;
const teacherCount = citizens.filter(c => c.profession === "Teacher").length;
const soldierCount = citizens.filter(c => c.profession === "Soldier").length;
professionCountsDisplay.textContent = `Citizens: 👷${builderCount} 🌾${farmerCount} 💰${merchantCount} 💉${doctorCount} 📚${teacherCount}`;
professionCountsDisplay.textContent = `Citizens: 👷${builderCount} 🌾${farmerCount} 💰${merchantCount} 💉${doctorCount} 📚${teacherCount} ⚔️${soldierCount}`;
}