summaryrefslogtreecommitdiffhomepage
path: root/Stars45/Player.h
blob: 39dbfcdd095796717514fe8c19285862ba38d0f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*  Project Starshatter 4.5
    Destroyer Studios LLC
    Copyright © 1997-2004. All Rights Reserved.

    SUBSYSTEM:    Stars.exe
    FILE:         Player.h
    AUTHOR:       John DiCamillo


    OVERVIEW
    ========
    Player / Logbook class
*/


#ifndef Player_h
#define Player_h

#include "Types.h"
#include "List.h"
#include "Text.h"

// +-------------------------------------------------------------------+

class Player;
class Bitmap;
class ShipStats;
class AwardInfo;
class Sound;

// +-------------------------------------------------------------------+

class Player
{
public:
   static const char* TYPENAME() { return "Player"; }

   Player(const char* name);
   virtual ~Player();

   int operator == (const Player& u) const { return name == u.name; }

   int            Identity()     const { return uid;           }
   const Text&    Name()         const { return name;          }
   const Text&    Password()     const { return pass;          }
   const Text&    Squadron()     const { return squadron;      }
   const Text&    Signature()    const { return signature;     }
   const Text&    ChatMacro(int n) const;
   int            CreateDate()   const { return create_date;   }
   int            Rank()         const;
   int            Medal(int n)   const;
   int            Points()       const { return points;        }
   int            Medals()       const { return medals;        }
   int            FlightTime()   const { return flight_time;   }
   int            Missions()     const { return missions;      }
   int            Kills()        const { return kills;         }
   int            Losses()       const { return losses;        }
   int            Campaigns()    const { return campaigns;     }
   int            Trained()      const { return trained;       }

   int            FlightModel()  const { return flight_model;  }
   int            FlyingStart()  const { return flying_start;  }
   int            LandingModel() const { return landing_model; }
   int            AILevel()      const { return ai_level;      }
   int            HUDMode()      const { return hud_mode;      }
   int            HUDColor()     const { return hud_color;     }
   int            FriendlyFire() const { return ff_level;      }
   int            GridMode()     const { return grid;          }
   int            Gunsight()     const { return gunsight;      }

   bool           ShowAward()    const { return award != 0;    }
   Text           AwardName()    const;
   Text           AwardDesc()    const;
   Bitmap*        AwardImage()   const;
   Sound*         AwardSound()   const;

   bool           CanCommand(int ship_class);

   void           SetName(const char* n);
   void           SetPassword(const char* p);
   void           SetSquadron(const char* s);
   void           SetSignature(const char* s);
   void           SetChatMacro(int n, const char* m);
   void           SetCreateDate(int d);
   void           SetRank(int r);
   void           SetPoints(int p);
   void           SetMedals(int m);
   void           SetCampaigns(int n);
   void           SetTrained(int n);
   void           SetFlightTime(int t);
   void           SetMissions(int m);
   void           SetKills(int k);
   void           SetLosses(int l);

   void           AddFlightTime(int t);
   void           AddPoints(int p);
   void           AddMedal(int m);
   void           AddMissions(int m);
   void           AddKills(int k);
   void           AddLosses(int l);

   bool           HasTrained(int n)            const;
   bool           HasCompletedCampaign(int id) const;
   void           SetCampaignComplete(int id);

   void           SetFlightModel(int n);
   void           SetFlyingStart(int n);
   void           SetLandingModel(int n);
   void           SetAILevel(int n);
   void           SetHUDMode(int n);
   void           SetHUDColor(int n);
   void           SetFriendlyFire(int n);
   void           SetGridMode(int n);
   void           SetGunsight(int n);

   void           ClearShowAward();

   Text           EncodeStats();
   void           DecodeStats(const char* stats);

   int            GetMissionPoints(ShipStats* stats, DWORD start_time);
   void           ProcessStats(ShipStats* stats, DWORD start_time);
   bool           EarnedAward(AwardInfo* a, ShipStats* s);

   static const char*   RankName(int rank);
   static const char*   RankAbrv(int rank);
   static int           RankFromName(const char* name);
   static Bitmap*       RankInsignia(int rank, int size);
   static const char*   RankDescription(int rank);
   static const char*   MedalName(int medal);
   static Bitmap*       MedalInsignia(int medal, int size);
   static const char*   MedalDescription(int medal);
   static int           CommandRankRequired(int ship_class);

   static List<Player>& GetRoster();
   static Player*       GetCurrentPlayer();
   static void          SelectPlayer(Player* p);
   static Player*       Create(const char* name);
   static void          Destroy(Player* p);
   static Player*       Find(const char* name);
   static void          Initialize();
   static void          Close();
   static void          Load();
   static void          Save();
   static bool          ConfigExists();
   static void          LoadAwardTables();

protected:
   Player();

   void                 CreateUniqueID();

   int         uid;
   Text        name;
   Text        pass;
   Text        squadron;
   Text        signature;
   Text        chat_macros[10];
   int         mfd[4];

   // stats:
   int         create_date;
   int         points;
   int         medals;        // bitmap of earned medals
   int         flight_time;
   int         missions;
   int         kills;
   int         losses;
   int         campaigns;     // bitmap of completed campaigns
   int         trained;       // id of highest training mission completed

   // gameplay options:
   int         flight_model;
   int         flying_start;
   int         landing_model;
   int         ai_level;
   int         hud_mode;
   int         hud_color;
   int         ff_level;
   int         grid;
   int         gunsight;

   // transient:
   AwardInfo*  award;
};

#endif Player_h