~ubuntu-branches/ubuntu/raring/lordsawar/raring

« back to all changes in this revision

Viewing changes to src/QEnemyArmies.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese, Gonéri Le Bouder
  • Date: 2008-06-17 11:15:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080617111526-yjyvu9df50zmpdo0
Tags: 0.0.9-1
[ Barry deFreese ]
* New upstream release.
  + Fixes gcc-4.3 builds so drop ftbfs_gcc-4.3_fix.diff.
  + Add new build-dependency for libgnet-dev.
* Add simple man page for new lordsawar-tile-editor.
* Add desktop file for lordsawar-tile-editor.
* Remove French translation on install.

[ Gonéri Le Bouder ]
* bump Debian Policy to 3.8.0. No change needed.
* fix wording in the 0.0.8-3 entry of the Debian changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2003, 2004, 2005 Ulf Lorenz
 
2
// Copyright (C) 2004 Andrea Paternesi
 
3
// Copyright (C) 2007, 2008 Ben Asselstine
 
4
// Copyright (C) 2007, 2008 Ole Laursen
 
5
//
1
6
//  This program is free software; you can redistribute it and/or modify
2
7
//  it under the terms of the GNU General Public License as published by
3
8
//  the Free Software Foundation; either version 2 of the License, or
10
15
//
11
16
//  You should have received a copy of the GNU General Public License
12
17
//  along with this program; if not, write to the Free Software
13
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 
19
//  02110-1301, USA.
14
20
 
15
21
#include <sstream>
16
22
#include <sigc++/functors/mem_fun.h>
62
68
    : Quest(q_mgr, hero, Quest::KILLARMIES), d_killed(0)
63
69
{
64
70
    // have us be informed when hostilities break out
65
 
    d_victim_player = getVictimPlayer(getHero()->getPlayer());
66
 
    d_victim_player->sdyingArmy.connect( sigc::mem_fun(*this, &QuestEnemyArmies::dyingArmy));
 
71
    d_victim_player = getVictimPlayer(getHero()->getOwner());
67
72
    
68
73
    /** we have to kill 14-20 units: 14 + rand(0..6) */
69
74
    d_to_kill = 14 + (rand() % 7);
82
87
    helper->getData(ui, "victim_player");
83
88
 
84
89
    d_victim_player = Playerlist::getInstance()->getPlayer(ui);
85
 
    // we want to be informed about fight causalties
86
 
    d_victim_player->sdyingArmy.connect( sigc::mem_fun(*this, &QuestEnemyArmies::dyingArmy));
87
 
 
88
 
    update_targets();
89
 
 
 
90
 
 
91
    update_targets();
 
92
    initDescription();
 
93
}
 
94
//=======================================================================
 
95
QuestEnemyArmies::QuestEnemyArmies(QuestsManager& q_mgr, Uint32 hero,
 
96
                                   Uint32 armies_to_kill, Uint32 victim_player)
 
97
    : Quest(q_mgr, hero, Quest::KILLARMIES), d_killed(0)
 
98
{
 
99
    // have us be informed when hostilities break out
 
100
    d_victim_player = Playerlist::getInstance()->getPlayer(victim_player);
 
101
    d_to_kill = armies_to_kill;
 
102
 
 
103
    update_targets();
90
104
    initDescription();
91
105
}
92
106
//=======================================================================
125
139
    // This quest should never expire, so this is just a dummy function
126
140
}
127
141
//=======================================================================
128
 
void QuestEnemyArmies::dyingArmy(Army *army, std::vector<Uint32> culprits)
129
 
{
130
 
    debug("QuestEnemyArmies: dyingArmy - pending = " << (int)d_pending);
131
 
 
132
 
    if (!isActive())
133
 
        return;
134
 
    
135
 
    // did our hero kill them?
136
 
    for (unsigned int i = 0; i < culprits.size(); i++)
137
 
    {
138
 
        if (culprits[i] == d_hero)
139
 
        {
140
 
            d_killed++;
141
 
            if (d_killed >= d_to_kill)
142
 
            {
143
 
                debug("CONGRATULATIONS: QUEST 'ENEMY ARMIES' IS COMPLETED!");
144
 
                d_q_mgr.questCompleted(d_hero);
145
 
            }
146
 
            break;
147
 
        }
148
 
    }
149
 
}
150
 
//=======================================================================
151
142
void QuestEnemyArmies::initDescription()
152
143
{
153
144
    char buffer[101]; buffer[100]='\0';
159
150
 
160
151
bool QuestEnemyArmies::isFeasible(Uint32 heroId)
161
152
{
162
 
  if (getVictimPlayer(getHeroById(heroId)->getPlayer()))
 
153
  if (getVictimPlayer(getHeroById(heroId)->getOwner()))
163
154
    return true;
164
155
  return false;
165
156
}
 
157
 
166
158
void QuestEnemyArmies::armyDied(Army *a, bool heroIsCulprit)
167
159
{
168
160
  if (!isActive())
169
161
    return;
170
162
 
171
 
  if (heroIsCulprit == true && a->getPlayer() == d_victim_player)
 
163
  if (heroIsCulprit == true && a->getOwner() == d_victim_player)
172
164
    {
173
165
      d_killed++;
174
166
      if (d_killed >= d_to_kill)