1 // Crimson Fields -- a game of tactical warfare
2 // Copyright (C) 2000-2007 Jens Granseuer
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
19 /////////////////////////////////////////////////////////////////////
20 // player.h
21 /////////////////////////////////////////////////////////////////////
22 
23 #ifndef _INCLUDE_PLAYER_H
24 #define _INCLUDE_PLAYER_H
25 
26 #include "fileio.h"
27 #include "gamedefs.h"
28 #include "color.h"
29 
30 #define MODE_IDLE	1   // no unit selected
31 #define MODE_BUSY	2   // unit selected
32 #define MODE_DIG	3   // for pioneers
33 #define MODE_CONSTRUCTION	4   // for depot builders
34 #define MODE_SWEEP	5   // for mine-sweepers
35 
36 class Player {
37 public:
Player(void)38   Player( void ) : p_name(0) {}
39   int Load( MemBuffer &file );
40   int Save( MemBuffer &file ) const;
41 
Briefing(void)42   signed char Briefing( void ) const { return p_briefing; }
ID(void)43   unsigned char ID( void ) const { return p_id; }
Mode(void)44   unsigned char Mode( void ) const { return p_mode; }
Name(void)45   const char *Name( void ) const { return p_name; }
NameID(void)46   signed char NameID( void ) const { return p_name_id; }
47   const char *Password( void ) const;
Type(void)48   unsigned char Type( void ) const { return p_type; }
IsHuman(void)49   bool IsHuman( void ) const { return p_type == HUMAN; }
IsRemote(void)50   bool IsRemote( void ) const { return p_remote; }
IsInteractive(void)51   bool IsInteractive( void ) const { return IsHuman() && !IsRemote(); }
52 
SetBriefing(signed char brief)53   void SetBriefing( signed char brief ) { p_briefing = brief; }
SetMode(unsigned char mode)54   void SetMode( unsigned char mode ) { p_mode = mode; }
SetType(unsigned char type)55   void SetType( unsigned char type ) { p_type = type; }
SetRemote(bool remote)56   void SetRemote( bool remote ) { p_remote = remote; }
57   void SetPassword( const char *password );
SetName(const char * name)58   void SetName( const char *name ) { p_name = name; }
59 
Success(signed char success)60   unsigned char Success( signed char success ) { p_success += success; return p_success; }
61   unsigned short Units( short delta );
62 
LightColor(void)63   const Color &LightColor( void ) const { return p_col_light; }
DarkColor(void)64   const Color &DarkColor( void ) const { return p_col_dark; }
65 
66 private:
67   unsigned char p_id;
68   unsigned char p_mode;
69   unsigned char p_type;       // COMPUTER or HUMAN
70   bool p_remote;              // remote player in network game
71 
72   unsigned short p_units;
73 
74   unsigned char p_success;    // if p_success == 100 the level is completed
75   signed char p_briefing;
76 
77   signed char p_name_id;
78   const char *p_name;
79   string p_password;
80 
81   Color p_col_light;
82   Color p_col_dark;
83 };
84 
85 #endif	/* _INCLUDE_PLAYER_H */
86 
87