unsigned char GameProgress::getWeakestWeapon() const { unsigned char weakest = 0; for(unsigned char i = 0; i < getWeaponCount(); ++i) { if(getWeaponEnergy(i) < getWeaponEnergy(weakest)) { weakest = i; } } return weakest; }
bool BaseAI::startTurn() { int count = 0; count = getWallCount(); walls.clear(); walls.resize(count); for(int i = 0; i < count; i++) { walls[i] = Wall(getWalls()+i); } count = getCrateCount(); crates.clear(); crates.resize(count); for(int i = 0; i < count; i++) { crates[i] = Crate(getCrates()+i); } count = getWeaponCount(); weapons.clear(); weapons.resize(count); for(int i = 0; i < count; i++) { weapons[i] = Weapon(getWeapons()+i); } count = getHumanCount(); humans.clear(); humans.resize(count); for(int i = 0; i < count; i++) { humans[i] = Human(getHumans()+i); } count = getZombieCount(); zombies.clear(); zombies.resize(count); for(int i = 0; i < count; i++) { zombies[i] = Zombie(getZombies()+i); } count = getAirstrikeCount(); airstrikes.clear(); airstrikes.resize(count); for(int i = 0; i < count; i++) { airstrikes[i] = Airstrike(getAirstrikes()+i); } count = getSpawnzoneCount(); spawnzones.clear(); spawnzones.resize(count); for(int i = 0; i < count; i++) { spawnzones[i] = Spawnzone(getSpawnzones()+i); } if(turnNum() == 1) { init(); if(!isHuman()) { return true; } } if(isHuman()) { return runHuman(); } else { return runZombie(); } }
int GameProgress::getWeaponEnergy(unsigned char weapon) const { if(weapon < getWeaponCount()) { return weaponEnergies[weapon]; } return 0; }
void GameProgress::resetWeaponEnergyToDefault() { for(unsigned char i = 0; i < getWeaponCount(); ++i) { setWeaponEnergy(i, DEFAULT_WEAPON_ENERGY); } }
void GameProgress::enableWeapon(unsigned char weapon, bool enable) { if(weapon < getWeaponCount()) { weaponsEnabled[weapon] = enable; } }
void GameProgress::setWeaponEnergy(unsigned char weapon, int value) { if(weapon < getWeaponCount()) { value = std::max(0, value); weaponEnergies[weapon] = value; } }
bool GameProgress::weaponIsEnabled(unsigned char weapon) const { if(weapon < getWeaponCount()) { return weaponsEnabled[weapon]; } return false; }