refactor: Resolve import and constant duplication issues in AI and game modules

This commit is contained in:
Kacper Kostka (aider)
2025-04-02 11:50:23 +02:00
parent be20e824f3
commit 8057ba881b
2 changed files with 13 additions and 23 deletions

26
ai.js
View File

@@ -1,31 +1,13 @@
/**********************************************************************
* CONSTANTS
* ANIMAL CONSTANTS
**********************************************************************/
const ANIMAL_HUNGER_MAX = 100;
const RABBIT_HUNGER_INCREMENT = 0.05;
const RABBIT_REPRO_CHANCE = 0.005;
const RABBIT_REPRO_COOLDOWN = 1000;
// Citizen constants
const HUNGER_INCREMENT = 0.02;
const HUNGER_MAX = 100;
const HUNGER_THRESHOLD = 70;
const ENERGY_DECREMENT_WORK = 0.01;
const ENERGY_INCREMENT_REST = 0.1;
const ENERGY_MAX = 100;
const ENERGY_THRESHOLD = 30;
const HEALTH_MAX = 100;
const HEALTH_THRESHOLD = 50;
const EDUCATION_MAX = 100;
const FRUIT_GATHER_RATE = 2;
const FRUIT_PLANT_COST = 5;
const FRUIT_TREE_START_AMOUNT = 50;
const REWARD_DELIVER_WOOD = 5;
/**********************************************************************
* CITIZEN AI
**********************************************************************/
function updateCitizen(cit) {
// Export functions
export function updateCitizen(cit) {
cit.hunger += HUNGER_INCREMENT;
if(cit.hunger > HUNGER_MAX) cit.hunger = HUNGER_MAX;
@@ -72,7 +54,7 @@ function updateCitizen(cit) {
/**********************************************************************
* ANIMAL AI
**********************************************************************/
function updateAnimal(ani) {
export function updateAnimal(ani) {
if(ani.type === "Rabbit") {
updateRabbit(ani);
}