bool AIHeroesScheduledVisit(const Kingdom & kingdom, s32 index) { for(KingdomHeroes::const_iterator it = kingdom.GetHeroes().begin(); it != kingdom.GetHeroes().end(); ++it) { AIHero & ai_hero = AIHeroes::Get(**it); Queue & task = ai_hero.sheduled_visit; if(task.isPresent(index)) return true; } return false; }
void RedrawIncomeInfo(const Point & pt, const Kingdom & myKingdom) { const Funds income = myKingdom.GetIncome(INCOME_ARTIFACTS | INCOME_HEROSKILLS); Text text("", Font::SMALL); text.Set(CapturedExtInfoString(Resource::WOOD, myKingdom.GetColor(), income)); text.Blit(pt.x + 54 - text.w() / 2, pt.y + 408); text.Set(CapturedExtInfoString(Resource::MERCURY, myKingdom.GetColor(), income)); text.Blit(pt.x + 146 - text.w() / 2, pt.y + 408); text.Set(CapturedExtInfoString(Resource::ORE, myKingdom.GetColor(), income)); text.Blit(pt.x + 228 - text.w() / 2, pt.y + 408); text.Set(CapturedExtInfoString(Resource::SULFUR, myKingdom.GetColor(), income)); text.Blit(pt.x + 294 - text.w() / 2, pt.y + 408); text.Set(CapturedExtInfoString(Resource::CRYSTAL, myKingdom.GetColor(), income)); text.Blit(pt.x + 360 - text.w() / 2, pt.y + 408); text.Set(CapturedExtInfoString(Resource::GEMS, myKingdom.GetColor(), income)); text.Blit(pt.x + 428 - text.w() / 2, pt.y + 408); text.Set(CapturedExtInfoString(Resource::GOLD, myKingdom.GetColor(), income)); text.Blit(pt.x + 494 - text.w() / 2, pt.y + 408); }
void RedrawIncomeInfo(const Point & pt, const Kingdom & myKingdom) { const Funds & funds = myKingdom.GetFunds(); Text text("", Font::SMALL); text.Set(GetString(world.CountCapturedMines(Resource::WOOD, myKingdom.GetColor()))); text.Blit(pt.x + 54 - text.w() / 2, pt.y + 408); text.Set(GetString(world.CountCapturedMines(Resource::MERCURY, myKingdom.GetColor()))); text.Blit(pt.x + 146 - text.w() / 2, pt.y + 408); text.Set(GetString(world.CountCapturedMines(Resource::ORE, myKingdom.GetColor()))); text.Blit(pt.x + 228 - text.w() / 2, pt.y + 408); text.Set(GetString(world.CountCapturedMines(Resource::SULFUR, myKingdom.GetColor()))); text.Blit(pt.x + 294 - text.w() / 2, pt.y + 408); text.Set(GetString(world.CountCapturedMines(Resource::CRYSTAL, myKingdom.GetColor()))); text.Blit(pt.x + 360 - text.w() / 2, pt.y + 408); text.Set(GetString(world.CountCapturedMines(Resource::GEMS, myKingdom.GetColor()))); text.Blit(pt.x + 428 - text.w() / 2, pt.y + 408); text.Set(GetString(world.CountCapturedMines(Resource::GOLD, myKingdom.GetColor()))); text.Blit(pt.x + 494 - text.w() / 2, pt.y + 408); text.Set(GetString(funds.wood)); text.Blit(pt.x + 56 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.mercury)); text.Blit(pt.x + 146 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.ore)); text.Blit(pt.x + 226 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.sulfur)); text.Blit(pt.x + 294 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.crystal)); text.Blit(pt.x + 362 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.gems)); text.Blit(pt.x + 428 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.gold)); text.Blit(pt.x + 496 - text.w() / 2, pt.y + 448); text.Set(_("Gold Per Day:")); text.Blit(pt.x + 328 - text.w(), pt.y + 462); text.Set(GetString(myKingdom.GetIncome().Get(Resource::GOLD))); text.Blit(pt.x + 340, pt.y + 462); }
int main(void) { /*Republic Ukraine; Ukraine.currancy = "ãðèâíÿ"; Ukraine.population = 45.6; Ukraine.territory = 603.7; cout << "Ukraine: "; Ukraine.getinfo(); */ Kingdom *UK = new Kingdom(*(new State(420.7,57.6,"pound")));// :State(603, 45, "gryvna"); // Âåëèêîáðèòàí³ÿ cout << "UK: "; UK->getinfo(); /*Kingdom UAE; // Îá'ºäíàí³ Àðàáñüê³ Åì³ðàòè cout << "UAE: "; UAE.getinfo(); */ return 0; }
void AI::KingdomTurn(Kingdom & kingdom) { KingdomHeroes & heroes = kingdom.GetHeroes(); KingdomCastles & castles = kingdom.GetCastles(); const Color::color_t & color = kingdom.GetColor(); if(kingdom.isLoss() || color == Color::NONE) { kingdom.LossPostActions(); return; } if(! Settings::Get().MusicMIDI()) AGG::PlayMusic(MUS::COMPUTER); Interface::StatusWindow *status = Interface::NoGUI() ? NULL : &Interface::StatusWindow::Get(); // indicator if(status) status->RedrawTurnProgress(0); if(status) status->RedrawTurnProgress(1); // castles AI turn for(KingdomCastles::iterator it = castles.begin(); it != castles.end(); ++it) if(*it) CastleTurn(**it); if(status) status->RedrawTurnProgress(3); // heroes turns for(KingdomHeroes::iterator it = heroes.begin(); it != heroes.end(); ++it) if(*it) HeroesTurn(**it); if(status) status->RedrawTurnProgress(6); if(status) status->RedrawTurnProgress(7); if(status) status->RedrawTurnProgress(8); if(status) status->RedrawTurnProgress(9); DEBUG(DBG_AI, DBG_INFO, Color::String(color) << " moved"); }
void RedrawFundsInfo(const Point & pt, const Kingdom & myKingdom) { const Funds & funds = myKingdom.GetFunds(); Text text("", Font::SMALL); AGG::GetICN(ICN::OVERBACK, 0).Blit(Rect(4, 422, 530, 56), pt.x + 4, pt.y + 422); text.Set(GetString(funds.wood)); text.Blit(pt.x + 56 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.mercury)); text.Blit(pt.x + 146 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.ore)); text.Blit(pt.x + 226 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.sulfur)); text.Blit(pt.x + 294 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.crystal)); text.Blit(pt.x + 362 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.gems)); text.Blit(pt.x + 428 - text.w() / 2, pt.y + 448); text.Set(GetString(funds.gold)); text.Blit(pt.x + 496 - text.w() / 2, pt.y + 448); text.Set(_("Gold Per Day:") + std::string(" ") + GetString(myKingdom.GetIncome().Get(Resource::GOLD))); text.Blit(pt.x + 180, pt.y + 462); std::string msg = _("Day: %{day}"); StringReplace(msg, "%{day}", world.GetDay()); text.Set(msg); text.Blit(pt.x + 360, pt.y + 462); }
void StartWar(Kingdom& enemy) { cout << "Starting war against " << enemy.GetName() << endl; }
void Game::generate_kingdoms() { if (!world) { debugmsg("Game::generate_kingdoms() called with NULL world!"); return; } if (!kingdoms.empty()) { for (int i = 0; i < kingdoms.size(); i++) { delete (kingdoms[i]); } } kingdoms.clear(); bool color_free[c_null]; // c_null is the last color for (int i = 0; i < c_null; i++) { color_free[i] = true; } // One kingdom for each race. Start at 1 to skip RACE_NULL. for (int i = 1; i < RACE_MAX; i++) { popup_nowait("Initializing kingdoms (%d of %d)...", i, RACE_MAX - 1); Kingdom* kingdom = new Kingdom; kingdom->uid = i - 1; kingdom->set_game(this); kingdom->race = Race(i); Race_datum* race_dat = Race_data[i]; // Pick a color - try the official race color first if (race_dat->color < c_dkgray && color_free[ race_dat->color ]) { kingdom->color = race_dat->color; color_free[ race_dat->color ] = false; } else { std::vector<nc_color> colors = race_dat->kingdom_colors; // Remove any already-used colors for (int i = 0; i < colors.size(); i++) { if (!color_free[ colors[i] ]) { colors.erase(colors.begin() + i); i--; } } if (colors.empty()) { // Can't use official colors; use a random one std::vector<nc_color> free_colors; // Start at 1 to skip c_black; stop at c_dkgray to skip bright colors for (int i = 1; i < c_dkgray; i++) { if (color_free[i]) { free_colors.push_back( nc_color(i) ); } } if (free_colors.empty()) { // 8 kingdoms used already! kingdom->color = nc_color( rng(1, c_dkgray - 1) ); } else { int index = rng(0, free_colors.size() - 1); kingdom->color = free_colors[index]; color_free[ free_colors[index] ] = false; } } else { // We can use an official color! int index = rng(0, colors.size() - 1); kingdom->color = colors[index]; color_free[ colors[index] ] = false; } } // if (!color_free[race_dat->color]) // Place the kingdom. if (kingdom->place_capital(world)) { kingdoms.push_back( kingdom ); // ...and add to our list. } } // for (int i = 1; i < RACE_MAX; i++) /* Now, expand the kingdoms by placing duchy seats. To keep things fair, each * kingdom gets to place a single city/duchy at a time. We go through our list, * each kingdom taking a turn, until all kingdoms are out of points. */ std::vector<int> points, kingdom_index; for (int i = 0; i < kingdoms.size(); i++) { points.push_back( KINGDOM_EXPANSION_POINTS ); // Defined in kingdom.h kingdom_index.push_back( i ); } int iteration = 0, max_points = points.size() * KINGDOM_EXPANSION_POINTS; while (!kingdom_index.empty()) { iteration++; int total_points = 0; for (int i = 0; i < points.size(); i++) { total_points += points[i]; } int percent = (100 * (max_points - total_points)) / max_points; popup_nowait("Placing duchies... [%d%%%%%%%%]", percent); for (int i = 0; i < kingdom_index.size(); i++) { Kingdom* kingdom = kingdoms[ kingdom_index[i] ]; if (!kingdom->place_duchy_seat(world, points[i])) { kingdom_index.erase( kingdom_index.begin() + i ); points.erase( points.begin() + i ); } } } // Now each kingdom gets to place minor cities in its duchies. for (int i = 0; i < kingdoms.size(); i++) { int percent = (100 * (i + 1)) / kingdoms.size(); popup_nowait("Placing minor cities... [%d%%%%%%%%] [%d/%d]", percent, i + 1, kingdoms.size()); kingdoms[i]->place_minor_cities(world); } // Build roads from the capital to each duchy. Building roads from the duchy to // its minor cities is handled in place_minor_cities(). for (int i = 0; i < kingdoms.size(); i++) { int percent = (100 * (i + 1)) / kingdoms.size(); popup_nowait("Connecting duchies via road... [%d%%%%%%%%]", percent); for (int n = 0; n < kingdoms[i]->dukes.size(); n++) { City* capital = kingdoms[i]->capital; City* duke = kingdoms[i]->dukes[n]; kingdoms[i]->build_road( world, capital, duke ); } } // Finally, swell the territory claimed by each kingdom. int expansions = 3; for (int n = 0; n < expansions; n++) { for (int i = 0; i < kingdoms.size(); i++) { popup_nowait("Expanding territories... (%d/%d; %d/%d)", n + 1, expansions, i + 1, kingdoms.size()); kingdoms[i]->expand_boundaries(world); } } // And setup trade routes for all cities! for (int i = 0; i < kingdoms.size(); i++) { int base_percent = (100 * i) / kingdoms.size(); kingdoms[i]->setup_trade_routes(base_percent); } }