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

« back to all changes in this revision

Viewing changes to src/Item.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) 2004, 2005, 2006 Ulf Lorenz
 
2
// Copyright (C) 2004 Andrea Paternesi
 
3
// Copyright (C) 2007, 2008 Ben Asselstine
 
4
// Copyright (C) 2008 Ole Laursen
 
5
//
 
6
//  This program is free software; you can redistribute it and/or modify
1
7
//  it under the terms of the GNU General Public License as published by
2
8
//  the Free Software Foundation; either version 2 of the License, or
3
9
//  (at your option) any later version.
9
15
//
10
16
//  You should have received a copy of the GNU General Public License
11
17
//  along with this program; if not, write to the Free Software
12
 
//  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.
13
20
 
14
21
#include <sstream>
15
22
#include <map>
16
23
#include "Item.h"
17
 
#include "Itemlist.h"
18
24
#include "File.h"
19
25
#include "counter.h"
20
26
#include "playerlist.h"
23
29
using namespace std;
24
30
 
25
31
Item::Item(XML_Helper* helper)
 
32
        : Renamable (helper)
26
33
{
27
34
    
28
35
    // Loading of items is a bit complicated, so i'd better loose some words.
32
39
 
33
40
    helper->getData(d_bonus, "bonus");
34
41
    
35
 
    helper->getData(d_name, "name");
36
42
    helper->getData(d_plantable, "plantable");
37
43
    if (d_plantable)
38
44
      {
52
58
}
53
59
 
54
60
Item::Item(std::string name, bool plantable, Player *plantable_owner)
 
61
        : Renamable(name)
55
62
{
56
63
  d_bonus = 0;
57
 
  d_name = name;
58
64
  d_plantable = plantable;
59
65
  d_plantable_owner_id = plantable_owner->getId();
60
66
  d_planted = false;
61
67
  d_id = fl_counter->getNextId();
 
68
  //std::cerr << "item created with id " << d_id << std::endl;
62
69
}
63
70
 
64
71
Item::Item(const Item& orig)
65
 
:d_bonus(orig.d_bonus),
66
 
    d_name(orig.d_name), d_plantable(orig.d_plantable),
 
72
:Renamable(orig), d_bonus(orig.d_bonus), d_plantable(orig.d_plantable),
67
73
    d_plantable_owner_id(orig.d_plantable_owner_id), d_planted(orig.d_planted)
68
74
{
69
75
  // Some things we don't copy from the template; we rather get an own ID
70
76
  d_id = fl_counter->getNextId();
 
77
  //std::cerr << "item created with id " << d_id << std::endl;
71
78
}
72
79
 
73
80
Item::~Item()
80
87
 
81
88
  // A template is never saved, so we assume this class is a real-life item
82
89
  retval &= helper->openTag("item");
83
 
  retval &= helper->saveData("name", d_name);
 
90
  retval &= helper->saveData("name", getName());
84
91
  retval &= helper->saveData("plantable", d_plantable);
85
92
  if (d_plantable)
86
93
    {
101
108
  return (d_bonus & bonus) == 0 ? false : true;
102
109
}
103
110
 
104
 
void Item::setBonus(Item::Bonus bonus)
 
111
void Item::addBonus(Item::Bonus bonus)
105
112
{
106
113
  d_bonus |= bonus;
107
114
}
108
115
 
109
 
std::string Item::getBonusDescription()
 
116
void Item::removeBonus(Item::Bonus bonus)
 
117
{
 
118
  d_bonus ^= bonus;
 
119
}
 
120
 
 
121
std::string Item::getBonusDescription() const
110
122
{
111
123
  // the attributes column
112
124
  std::vector<Glib::ustring> s;