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