Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Player.h
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: Player.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Player / Logbook class
13 */
14 
15 
16 #ifndef Player_h
17 #define Player_h
18 
19 #include "Types.h"
20 #include "List.h"
21 #include "Text.h"
22 
23 // +-------------------------------------------------------------------+
24 
25 class Player;
26 class Bitmap;
27 class ShipStats;
28 class AwardInfo;
29 class Sound;
30 
31 // +-------------------------------------------------------------------+
32 
33 class Player
34 {
35 public:
36  static const char* TYPENAME() { return "Player"; }
37 
38  Player(const char* name);
39  virtual ~Player();
40 
41  int operator == (const Player& u) const { return name == u.name; }
42 
43  int Identity() const { return uid; }
44  const Text& Name() const { return name; }
45  const Text& Password() const { return pass; }
46  const Text& Squadron() const { return squadron; }
47  const Text& Signature() const { return signature; }
48  const Text& ChatMacro(int n) const;
49  int CreateDate() const { return create_date; }
50  int Rank() const;
51  int Medal(int n) const;
52  int Points() const { return points; }
53  int Medals() const { return medals; }
54  int FlightTime() const { return flight_time; }
55  int Missions() const { return missions; }
56  int Kills() const { return kills; }
57  int Losses() const { return losses; }
58  int Campaigns() const { return campaigns; }
59  int Trained() const { return trained; }
60 
61  int FlightModel() const { return flight_model; }
62  int FlyingStart() const { return flying_start; }
63  int LandingModel() const { return landing_model; }
64  int AILevel() const { return ai_level; }
65  int HUDMode() const { return hud_mode; }
66  int HUDColor() const { return hud_color; }
67  int FriendlyFire() const { return ff_level; }
68  int GridMode() const { return grid; }
69  int Gunsight() const { return gunsight; }
70 
71  bool ShowAward() const { return award != 0; }
72  Text AwardName() const;
73  Text AwardDesc() const;
74  Bitmap* AwardImage() const;
75  Sound* AwardSound() const;
76 
77  bool CanCommand(int ship_class);
78 
79  void SetName(const char* n);
80  void SetPassword(const char* p);
81  void SetSquadron(const char* s);
82  void SetSignature(const char* s);
83  void SetChatMacro(int n, const char* m);
84  void SetCreateDate(int d);
85  void SetRank(int r);
86  void SetPoints(int p);
87  void SetMedals(int m);
88  void SetCampaigns(int n);
89  void SetTrained(int n);
90  void SetFlightTime(int t);
91  void SetMissions(int m);
92  void SetKills(int k);
93  void SetLosses(int l);
94 
95  void AddFlightTime(int t);
96  void AddPoints(int p);
97  void AddMedal(int m);
98  void AddMissions(int m);
99  void AddKills(int k);
100  void AddLosses(int l);
101 
102  bool HasTrained(int n) const;
103  bool HasCompletedCampaign(int id) const;
104  void SetCampaignComplete(int id);
105 
106  void SetFlightModel(int n);
107  void SetFlyingStart(int n);
108  void SetLandingModel(int n);
109  void SetAILevel(int n);
110  void SetHUDMode(int n);
111  void SetHUDColor(int n);
112  void SetFriendlyFire(int n);
113  void SetGridMode(int n);
114  void SetGunsight(int n);
115 
116  void ClearShowAward();
117 
118  Text EncodeStats();
119  void DecodeStats(const char* stats);
120 
121  int GetMissionPoints(ShipStats* stats, DWORD start_time);
122  void ProcessStats(ShipStats* stats, DWORD start_time);
123  bool EarnedAward(AwardInfo* a, ShipStats* s);
124 
125  static const char* RankName(int rank);
126  static const char* RankAbrv(int rank);
127  static int RankFromName(const char* name);
128  static Bitmap* RankInsignia(int rank, int size);
129  static const char* RankDescription(int rank);
130  static const char* MedalName(int medal);
131  static Bitmap* MedalInsignia(int medal, int size);
132  static const char* MedalDescription(int medal);
133  static int CommandRankRequired(int ship_class);
134 
135  static List<Player>& GetRoster();
136  static Player* GetCurrentPlayer();
137  static void SelectPlayer(Player* p);
138  static Player* Create(const char* name);
139  static void Destroy(Player* p);
140  static Player* Find(const char* name);
141  static void Initialize();
142  static void Close();
143  static void Load();
144  static void Save();
145  static bool ConfigExists();
146  static void LoadAwardTables();
147 
148 protected:
149  Player();
150 
151  void CreateUniqueID();
152 
153  int uid;
159  int mfd[4];
160 
161  // stats:
163  int points;
164  int medals; // bitmap of earned medals
166  int missions;
167  int kills;
168  int losses;
169  int campaigns; // bitmap of completed campaigns
170  int trained; // id of highest training mission completed
171 
172  // gameplay options:
176  int ai_level;
177  int hud_mode;
179  int ff_level;
180  int grid;
181  int gunsight;
182 
183  // transient:
185 };
186 
187 #endif Player_h