initial commit, lordsawar source, slightly modified
[lordsawar] / src / armyprodbase.cpp
1 // Copyright (C) 2000, 2001, 2003 Michael Bartl
2 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Ulf Lorenz
3 // Copyright (C) 2004, 2005 Andrea Paternesi
4 // Copyright (C) 2007, 2008 Ben Asselstine
5 // Copyright (C) 2007, 2008 Ole Laursen
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License as published by
9 //  the Free Software Foundation; either version 3 of the License, or
10 //  (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU Library General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
20 //  02110-1301, USA.
21
22 #include <iostream>
23 #include <sstream>
24 #include <algorithm>
25 #include "armyprodbase.h"
26 #include "armyprotobase.h"
27 #include "xmlhelper.h"
28 #include "armysetlist.h"
29
30 std::string ArmyProdBase::d_tag = "armyprodbase";
31
32 //#define debug(x) {std::cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<std::endl<<std::flush;}
33 #define debug(x)
34
35 ArmyProdBase::ArmyProdBase(const ArmyProdBase& a)
36     :ArmyProtoBase(a)
37 {
38 }
39
40 ArmyProdBase::ArmyProdBase(const ArmyProto& a)
41     :ArmyProtoBase(a)
42 {
43 }
44
45 ArmyProdBase::ArmyProdBase(XML_Helper* helper)
46   :ArmyProtoBase(helper)
47 {
48   helper->getData(d_armyset, "armyset");
49   helper->getData(d_type_id, "type");
50 }
51
52 ArmyProdBase::~ArmyProdBase()
53 {
54 }
55
56 bool ArmyProdBase::save(XML_Helper* helper) const
57 {
58   bool retval = true;
59
60   retval &= helper->openTag(ArmyProdBase::d_tag);
61
62   ArmyProtoBase::saveData(helper);
63
64   retval &= helper->saveData("type", d_type_id);
65   retval &= helper->saveData("armyset", d_armyset);
66
67   retval &= helper->closeTag();
68
69   return retval;
70 }
71         
72 void ArmyProdBase::morph(const ArmyProto *army)
73 {
74   setStrength(army->getStrength());
75   setMaxMoves(army->getMaxMoves());
76   setMoveBonus(army->getMoveBonus());
77   setArmyBonus(army->getArmyBonus());
78   setTypeId(army->getTypeId());
79   setArmyset(army->getArmyset());
80 }