40
40
for (Playerlist::const_iterator pit = pl->begin(); pit != pl->end(); pit++)
44
44
sl = (*pit)->getStacklist();
45
45
for (sit = sl->begin(); sit != sl->end(); sit++)
47
//is this stack not in a city? no? it's a target.
48
if (GameMap::getCity((*sit)->getPos()) == NULL)
49
targets.push_back((*sit)->getPos());
50
for (it = (*sit)->begin(); it != (*sit)->end(); it++)
52
if ((*it)->getAwardable())
54
specials.push_back((*it));
47
//is this stack not in a city? no? it's a target.
48
if (GameMap::getCity((*sit)->getPos()) == NULL)
49
targets.push_back((*sit)->getPos());
50
for (it = (*sit)->begin(); it != (*sit)->end(); it++)
52
if ((*it)->getAwardable())
54
specials.push_back((*it));
59
59
if (specials.size() == 0)
65
65
//#define debug(x) {cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<endl<<flush;}
67
//=======================================================================
68
67
QuestEnemyArmytype::QuestEnemyArmytype(QuestsManager& q_mgr, guint32 hero)
69
: Quest(q_mgr, hero, Quest::KILLARMYTYPE)
68
: Quest(q_mgr, hero, Quest::KILLARMYTYPE)
71
Player *p = getHero()->getOwner();
74
d_type_to_kill = getVictimArmytype (p, d_targets);
70
Player *p = getHero()->getOwner();
73
d_type_to_kill = getVictimArmytype (p, d_targets);
78
//=======================================================================
79
78
QuestEnemyArmytype::QuestEnemyArmytype(QuestsManager& q_mgr, XML_Helper* helper)
80
: Quest(q_mgr, helper)
79
: Quest(q_mgr, helper)
82
helper->getData(d_type_to_kill, "type_to_kill");
81
helper->getData(d_type_to_kill, "type_to_kill");
86
//=======================================================================
87
86
QuestEnemyArmytype::QuestEnemyArmytype(QuestsManager& q_mgr, guint32 hero,
89
: Quest(q_mgr, hero, Quest::KILLARMYTYPE)
88
: Quest(q_mgr, hero, Quest::KILLARMYTYPE)
92
d_type_to_kill = type_to_kill;
91
d_type_to_kill = type_to_kill;
96
//=======================================================================
97
96
bool QuestEnemyArmytype::save(XML_Helper *helper) const
101
retval &= helper->openTag(Quest::d_tag);
102
retval &= Quest::save(helper);
103
retval &= helper->saveData("type_to_kill", d_type_to_kill);
104
retval &= helper->closeTag();
100
retval &= helper->openTag(Quest::d_tag);
101
retval &= Quest::save(helper);
102
retval &= helper->saveData("type_to_kill", d_type_to_kill);
103
retval &= helper->closeTag();
108
//=======================================================================
109
108
std::string QuestEnemyArmytype::getProgress() const
111
Armysetlist *al = Armysetlist::getInstance();
112
guint32 set = Playerlist::getInstance()->getActiveplayer()->getArmyset();
113
const ArmyProto *a = al->getArmy(set, d_type_to_kill);
114
return String::ucompose(
115
_("You have not killed a unit of enemy %1 yet."), a->getName());
110
Armysetlist *al = Armysetlist::getInstance();
111
guint32 set = Playerlist::getInstance()->getActiveplayer()->getArmyset();
112
const ArmyProto *a = al->getArmy(set, d_type_to_kill);
113
return String::ucompose(
114
_("You have not killed a unit of enemy %1 yet."), a->getName());
117
//=======================================================================
118
117
void QuestEnemyArmytype::getSuccessMsg(std::queue<std::string>& msgs) const
120
Armysetlist *al = Armysetlist::getInstance();
121
guint32 set = Playerlist::getInstance()->getActiveplayer()->getArmyset();
122
const ArmyProto *a = al->getArmy(set, d_type_to_kill);
123
msgs.push(String::ucompose(_("You have killed a unit of enemy %1."), a->getName()));
124
msgs.push(_("Well done!"));
119
Armysetlist *al = Armysetlist::getInstance();
120
guint32 set = Playerlist::getInstance()->getActiveplayer()->getArmyset();
121
const ArmyProto *a = al->getArmy(set, d_type_to_kill);
122
msgs.push(String::ucompose(_("You have killed a unit of enemy %1."), a->getName()));
123
msgs.push(_("Well done!"));
126
//=======================================================================
127
126
void QuestEnemyArmytype::getExpiredMsg(std::queue<std::string>& msgs) const
129
// This quest should never expire, so this is just a dummy function
128
// This quest should never expire, so this is just a dummy function
131
//=======================================================================
132
131
void QuestEnemyArmytype::initDescription()
134
Armysetlist *al = Armysetlist::getInstance();
135
guint32 set = Playerlist::getInstance()->getActiveplayer()->getArmyset();
136
const ArmyProto *a = al->getArmy(set, d_type_to_kill);
137
d_description = String::ucompose(_("You must destroy a unit of enemy %1."),
133
Armysetlist *al = Armysetlist::getInstance();
134
guint32 set = Playerlist::getInstance()->getActiveplayer()->getArmyset();
135
const ArmyProto *a = al->getArmy(set, d_type_to_kill);
136
d_description = String::ucompose(_("You must destroy a unit of enemy %1."),
140
//=======================================================================
141
140
bool QuestEnemyArmytype::isFeasible(guint32 heroId)
143
142
std::list< Vector<int> >targets;