initial commit, lordsawar source, slightly modified
[lordsawar] / src / Triumphs.h
1 //  Copyright (C) 2008 Ben Asselstine
2 //
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.
7 //
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.
12 //
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 
16 //  02110-1301, USA.
17
18 #ifndef TRIUMPHS_H
19 #define TRIUMPHS_H
20
21 class XML_Helper;
22
23 #include "player.h"
24
25 //! Tallies of the kinds of army units that have been killed.
26 /**
27  * 
28  */
29 class Triumphs
30 {
31     public:
32         //! The xml tag of this object in a saved-game file.
33         static std::string d_tag; 
34
35         //! Every player keeps a tally of frags.
36         enum TriumphType {
37           //! Kills we've made of an opponent's Hero army units.
38           TALLY_HERO = 0, 
39           //! Kills we've made of an opponent's awardable Army units.
40           TALLY_SPECIAL = 1, 
41           //! Kills we've made of an opponents other Army units.
42           TALLY_NORMAL = 2, 
43           //! Kills we've made of an opponent's Army units on the water.
44           TALLY_SHIP = 3, 
45           //! Kills we've made of opponent's Heroes who carry a standard Item.
46           TALLY_FLAG = 4
47         };
48
49         //! Standard constructor.
50         Triumphs();
51
52         //! Loading constructor.
53         /**
54          * Load the triumph tallies from a file.
55          * Triumphs are stored in the saved-game file at:
56          * lordsawar.playerlist.player.triumphs.
57          *
58          * @param helper  The opened saved-game file to load the tallies from.
59          */
60         Triumphs (XML_Helper* helper);
61
62         //! Copy constructor.
63         Triumphs(const Triumphs&);
64
65         //! Destructor.
66         ~Triumphs();
67
68
69         // Methods that operate on the class data but do not modify the class.
70
71         //! Save the triumph tallies to a file.
72         /**
73          * @param helper  The opened saved-game file to save the tallies to.
74          *
75          * @return True if saving went well, false otherwise.
76          */
77         bool save(XML_Helper* helper) const;
78
79         /**
80          * The player's triumphs are tallied as opponent's armies die.
81          * This method gets a tally for certain kind of triumph.  
82          * See TriumphsDialog for a caller of this method.
83          *
84          * @param player      The player to obtain a tally for.
85          * @param type        The kind of kills to tally (Player::TriumphType).
86          *
87          * @return Zero or more number of armies killed.
88          */
89         //! Returns a number of armies killed.
90         guint32 getTriumphTally(Player *player, TriumphType type) const
91           {return d_triumph[player->getId()][type];}
92
93
94         // Methods the operate on the class data, and modify the class.
95         
96         //! Tally up a kill for the given player.
97         void tallyTriumph(Player *p, TriumphType type);
98
99     private:
100
101         //! A set of tally statistics for frags of army units.
102         /**
103          * 5 is max TriumphType + 1.
104          */ 
105         guint32 d_triumph[MAX_PLAYERS][5]; 
106 };
107
108 #endif
109
110 // End of file