void AICastleDefense(Castle & c) { if(c.isCastle()) { if(!c.isBuild(BUILD_LEFTTURRET)) c.BuyBuilding(BUILD_LEFTTURRET); if(!c.isBuild(BUILD_RIGHTTURRET)) c.BuyBuilding(BUILD_RIGHTTURRET); if(!c.isBuild(BUILD_MOAT)) c.BuyBuilding(BUILD_MOAT); if(!c.isBuild(BUILD_CAPTAIN) && NULL == c.GetHeroes().Guest()) c.BuyBuilding(BUILD_CAPTAIN); if(!c.isBuild(BUILD_TAVERN) && Race::KNGT == c.GetRace()) c.BuyBuilding(BUILD_TAVERN); if(!c.isBuild(BUILD_SPEC)) c.BuyBuilding(BUILD_SPEC); } c.RecruitAllMonster(); }
void RunTest3(void) { VERBOSE("Run Test3"); ListFiles maps = GetMapsFiles(".mp2"); if(maps.empty()) return; const std::string & amap = maps.front(); Settings & conf = Settings::Get(); Maps::FileInfo fi; if(!fi.ReadMP2(amap)) return; conf.SetCurrentFileInfo(fi); world.LoadMapMP2(amap); Heroes & hero1 = *world.GetHeroes(Heroes::SANDYSANDY); Heroes & hero2 = *world.GetHeroes(Heroes::BAX); Players & players = conf.GetPlayers(); int mycolor = Color::GetFirst(players.GetColors(CONTROL_HUMAN)); int aicolor = Color::GetFirst(players.GetColors((CONTROL_AI))); players.SetPlayerControl(mycolor, CONTROL_HUMAN); players.SetPlayerControl(aicolor, CONTROL_HUMAN); Kingdom & kingdom1 = world.GetKingdom(mycolor); Kingdom & kingdom2 = world.GetKingdom(aicolor); conf.SetCurrentColor(mycolor); conf.SetGameType(Game::TYPE_BATTLEONLY); players.SetStartGame(); hero1.SetSpellPoints(150); int xx = world.w() / 2; int yy = world.h() / 2; if(kingdom1.GetCastles().size()) hero1.Recruit(kingdom1.GetColor(), Point(xx, yy)); hero2.Recruit(kingdom2.GetColor(), Point(xx, yy + 1)); Army & army1 = hero1.GetArmy(); Castle* castle = kingdom2.GetCastles().at(0); castle->ActionNewDay(); castle->BuyBuilding(BUILD_MAGEGUILD1); castle->ActionNewDay(); castle->BuyBuilding(BUILD_CAPTAIN); castle->ActionNewDay(); castle->BuyBuilding(BUILD_MOAT); //Army army2; //Army & army2 = hero2.GetArmy(); Army & army2 = castle->GetArmy(); if(army2.GetCommander()) { army2.GetCommander()->SpellBookActivate(); army2.GetCommander()->AppendSpellToBook(Spell::SHIELD, true); } army1.Clean(); //army1.JoinTroop(Monster::PHOENIX, 10); //army1.GetTroop(0)->Set(Monster::ARCHER, 30); army1.GetTroop(1)->Set(Monster::BOAR, 20); army1.GetTroop(2)->Set(Monster::OGRE_LORD, 20); //army1.JoinTroop(Monster::Rand(Monster::LEVEL1), 30); //army1.JoinTroop(Monster::Rand(Monster::LEVEL2), 20); //army1.JoinTroop(Monster::Rand(Monster::LEVEL3), 10); army2.Clean(); army2.GetTroop(0)->Set(Monster::BOAR, 20); army2.GetTroop(2)->Set(Monster::OGRE_LORD, 20); // army2.at(0) = Troop(Monster::OGRE, 1); // army2.at(1) = Troop(Monster::DWARF, 2); // army2.at(2) = Troop(Monster::DWARF, 2); // army2.at(3) = Troop(Monster::DWARF, 2); // army2.at(4) = Troop(Monster::DWARF, 2); // army2.JoinTroop(static_cast<Monster::monster_t>(1), 10); // army2.JoinTroop(static_cast<Monster::monster_t>(4), 10); // army2.JoinTroop(static_cast<Monster::monster_t>(6), 10); // army2.JoinTroop(static_cast<Monster::monster_t>(8), 10); Battle::Loader(army1, army2, army1.GetCommander()->GetIndex()); }
void AICastleDevelopment(Castle & c) { const Kingdom & kingdom = c.GetKingdom(); if(c.isCastle()) { // build for capital or large golds if(c.isCapital() || kingdom.GetFunds().Get(Resource::GOLD) > 8000) { if(!c.isBuild(BUILD_STATUE)) c.BuyBuilding(BUILD_STATUE); if(!c.isBuild(BUILD_SPEC) && Race::WRLK == c.GetRace()) c.BuyBuilding(BUILD_SPEC); if(!c.isBuild(BUILD_TAVERN) && Race::KNGT == c.GetRace()) c.BuyBuilding(BUILD_TAVERN); if(!c.isBuild(BUILD_MAGEGUILD1) && ((Race::SORC | Race::WZRD | Race::WRLK | Race::NECR) & c.GetRace())) c.BuyBuilding(BUILD_MAGEGUILD1); if(!c.isBuild(BUILD_WELL)) c.BuyBuilding(BUILD_WELL); if(!c.isBuild(DWELLING_MONSTER1)) c.BuyBuilding(DWELLING_MONSTER1); if(!c.isBuild(DWELLING_MONSTER2)) c.BuyBuilding(DWELLING_MONSTER2); if(!c.isBuild(DWELLING_MONSTER3)) c.BuyBuilding(DWELLING_MONSTER3); if(!c.isBuild(DWELLING_MONSTER4)) c.BuyBuilding(DWELLING_MONSTER4); if(!c.isBuild(BUILD_THIEVESGUILD) && ((Race::NECR) & c.GetRace())) c.BuyBuilding(BUILD_THIEVESGUILD); if(!c.isBuild(BUILD_MARKETPLACE)) c.BuyBuilding(BUILD_MARKETPLACE); if(!c.isBuild(BUILD_MAGEGUILD1)) c.BuyBuilding(BUILD_MAGEGUILD1); if(!c.isBuild(BUILD_MAGEGUILD2) && ((Race::SORC | Race::WZRD | Race::WRLK | Race::NECR) & c.GetRace())) c.BuyBuilding(BUILD_MAGEGUILD2); if(!c.isBuild(DWELLING_UPGRADE2)) c.BuyBuilding(DWELLING_UPGRADE2); if(!c.isBuild(DWELLING_UPGRADE3)) c.BuyBuilding(DWELLING_UPGRADE3); if(!c.isBuild(DWELLING_UPGRADE4)) c.BuyBuilding(DWELLING_UPGRADE4); if(!c.isBuild(BUILD_LEFTTURRET)) c.BuyBuilding(BUILD_LEFTTURRET); if(!c.isBuild(BUILD_RIGHTTURRET)) c.BuyBuilding(BUILD_RIGHTTURRET); if(!c.isBuild(BUILD_MOAT)) c.BuyBuilding(BUILD_MOAT); if(!c.isBuild(BUILD_CAPTAIN)) c.BuyBuilding(BUILD_CAPTAIN); if(!c.isBuild(BUILD_MAGEGUILD2)) c.BuyBuilding(BUILD_MAGEGUILD2); if(!c.isBuild(DWELLING_MONSTER5)) c.BuyBuilding(DWELLING_MONSTER5); if(!c.isBuild(DWELLING_MONSTER6)) c.BuyBuilding(DWELLING_MONSTER6); if(!c.isBuild(BUILD_MAGEGUILD3)) c.BuyBuilding(BUILD_MAGEGUILD3); if(!c.isBuild(DWELLING_UPGRADE5)) c.BuyBuilding(DWELLING_UPGRADE5); if(!c.isBuild(DWELLING_UPGRADE6)) c.BuyBuilding(DWELLING_UPGRADE6); } } else { // build castle only monday or tuesday or for capital if(c.isCapital() || 3 > world.GetDay()) c.BuyBuilding(BUILD_CASTLE); } // last day and buy monster if(world.LastDay()) c.RecruitAllMonster(); }