1 // Copyright (C) 2009 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 #include "Commentator.h"
21 #include "playerlist.h"
24 #include "stacklist.h"
30 Commentator* Commentator::d_instance = 0;
32 Commentator* Commentator::getInstance()
35 d_instance = new Commentator();
40 void Commentator::deleteInstance()
48 Commentator::Commentator()
52 Commentator::~Commentator()
56 bool Commentator::hasComment() const
58 if ((rand() % MAX_PLAYERS) == 0)
63 std::vector<std::string> Commentator::getComments(Player *player) const
65 std::vector<std::string> comments;
66 guint32 round = player->countEndTurnHistoryEntries();
71 if (player->getGold() < 100)
72 comments.push_back(_("You are sadly in need of gold!"));
73 else if (player->getGold() > 2500)
75 comments.push_back(_("Your wealth is greather than the mightiest of dragons!"));
76 comments.push_back(_("All your gold must surely be a burden!"));
78 std::list<Hero*> heroes = player->getHeroes();
79 if (heroes.size() == 0)
80 comments.push_back(_("Will no hero defend your honour?"));
81 else if (heroes.size() > 3)
82 comments.push_back(_("I see heroes are flocking to your banner!"));
84 if (round > 5 && player->getScore() < 10)
86 comments.push_back(_("Your enemies mock your feeble endeavours!"));
87 comments.push_back(_("How much adversity can you endure?"));
88 comments.push_back(_("Your enemies are beyond measure!"));
89 comments.push_back(_("Your dreams of conquest confound you!"));
91 else if (round > 30 && player->getScore() < 10)
92 comments.push_back(_("Your sorry efforts have come to nought!"));
94 if (player->getScore() >= 40 && round >= 10)
96 comments.push_back(_("Victory is just beyond your reach!"));
97 comments.push_back(_("Your destiny is forged in steel!"));
98 comments.push_back(_("You stand at the crossroads of victory!"));
99 comments.push_back(_("Attack is the best means of defence!"));
100 comments.push_back(_("Do you feel the wolves snapping at your heels?"));
102 else if (player->getScore() >= 30 && round < 15)
103 comments.push_back(_("Warlord! Your progress is astounding!"));
104 else if (player->getScore() >= 20 && round <= 20)
106 comments.push_back(_("So, Warlord, you show some merit!"));
107 comments.push_back(_("You are doing well... ...so far!"));
110 if (player == Playerlist::getInstance()->getWinningPlayer())
112 comments.push_back(_("Beware! Lest overconfidence consume you!"));
113 comments.push_back(_("Your name evokes fear and loathing!"));
115 guint32 attacking_enemy_cities = 0;
116 for (Stacklist::iterator it = player->getStacklist()->begin(); it != player->getStacklist()->end(); it++)
119 if (stack->hasPath() &&
120 GameMap::getEnemyCity(stack->getLastPointInPath()) != NULL)
121 attacking_enemy_cities++;
123 if (attacking_enemy_cities > 0)
124 comments.push_back(_("Ahh, the expectation of a coming battle!"));
126 if (attacking_enemy_cities > 4)
127 comments.push_back(_("Warlord... a might battle is brewing!"));
129 City *capital_city = Citylist::getInstance()->getCapitalCity(player);
130 if (capital_city->getOwner() != player)
131 comments.push_back(_("As your capital city has fallen, so shall you!"));