Planeshift
factions.h
Go to the documentation of this file.
1 /*
2  * factions.h
3  * written by Keith Fulton <keith@paqrat.com>
4  *
5  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
6  *
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation (version 2 of the License)
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  */
20 #ifndef __FACTIONS_H__
21 #define __FACTIONS_H__
22 
23 #include <csutil/hash.h>
24 #include <csutil/csstring.h>
25 
30 {
31  int value;
32  csString event_description;
33 
34  bool operator== (FactionLifeEvent OtherEvt) const { return value == OtherEvt.value; }
35  bool operator< (FactionLifeEvent OtherEvt) const { return value < OtherEvt.value; }
36 };
37 
41 struct Faction
42 {
43  csString name;
44  csString description;
45  int id;
46  float weight;
47  csArray<FactionLifeEvent> PositiveFactionEvents;
48  csArray<FactionLifeEvent> NegativeFactionEvents;
49 };
50 
51 
57 {
59  int score;
60  bool dirty;
61 };
62 
63 
69 {
70 protected:
72  csHash<FactionStanding*, int> factionstandings;
73 
75  csHash<Faction*, int>* factions_by_id;
76 
77 public:
82  FactionSet(const char *csv_list,csHash<Faction*, int, CS::Memory::AllocatorMalloc> &factionset);
83 
84  ~FactionSet();
85 
86  bool GetFactionStanding(int factionID,int& standing, float& weight);
87 
100  void UpdateFactionStanding(int factionID, int delta, bool setDirty = true, bool overwrite = false);
101 
105  void GetFactionListCSV(csString& csv);
106 
107  float FindWeightedDiff(FactionSet* other);
108 
109  csHash<FactionStanding*, int>& GetStandings() { return factionstandings; }
110 
114  bool CheckFaction(Faction * faction, int value);
115 
119  int GetFaction(Faction *faction);
120 };
121 
122 
123 
124 #endif
125 
bool operator==(FactionLifeEvent OtherEvt) const
Definition: factions.h:34
int id
Definition: factions.h:45
Faction * faction
Definition: factions.h:58
csHash< Faction *, int > * factions_by_id
A list of all the factions in this set.
Definition: factions.h:75
csArray< FactionLifeEvent > NegativeFactionEvents
Stores the Negative faction values life events.
Definition: factions.h:48
bool operator<(FactionLifeEvent OtherEvt) const
Definition: factions.h:35
This class is a set of faction structures.
Definition: factions.h:68
csHash< FactionStanding *, int > factionstandings
A list of all the standings with each faction.
Definition: factions.h:72
csString description
Definition: factions.h:44
csString name
Definition: factions.h:43
This struct stores the particular score of a particular player to a particular faction.
Definition: factions.h:56
int value
Value from which this life event is attribuited.
Definition: factions.h:31
csArray< FactionLifeEvent > PositiveFactionEvents
Stores the Positive faction values life events.
Definition: factions.h:47
csString event_description
The text of this life event.
Definition: factions.h:32
This struct stores the values and text used for the dynamically generated life events based on factio...
Definition: factions.h:29
float weight
Definition: factions.h:46
csHash< FactionStanding *, int > & GetStandings()
Definition: factions.h:109
An ingame faction group.
Definition: factions.h:41