00001 /* $Id: game.h jjs $ */ 00002 /* 00003 Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl> 00004 Part of the Moros Project http://moros.sourceforge.net/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License version 3. 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY. 00010 00011 See the COPYING file for more details. 00012 */ 00013 #ifndef __GAME_H 00014 #define __GAME_H 00015 00016 #include <vector> 00017 #include <map> 00018 #include "party.h" 00019 #include "../general/channel.h" 00020 00022 00023 enum join_type { 00024 Open, 00025 Moderated, 00026 Spectators, 00027 Private 00028 }; 00029 00031 00032 enum goal_type { 00033 Mayor_player, 00034 Time, 00035 Victory_points, 00036 Target_city, 00037 Target_city_and_time 00038 }; 00039 00041 00042 #define state_defining 0 00043 #define state_editor 1 00044 #define state_game 2 00045 #define state_pauzed 3 00046 #define state_winner 4 00047 #define state_finished 5 00048 00049 class game { 00050 public: 00051 long id; 00052 long timestamp; 00053 std::string name; 00054 std::string description; 00055 std::string owner; 00056 int join; 00057 std::string join_str(); 00058 int goal; 00059 std::string goal_str(); 00060 std::string map; 00061 std::string url; 00062 std::string session; 00063 int state; 00064 vector<party> parties; 00065 00067 void save(channel *ch); 00068 void server_save(channel *ch); 00069 }; 00070 00072 extern map<long,game> games; 00073 00075 extern long game_number; 00076 00078 extern const char* join_types[]; 00079 00081 extern const int join_elms; 00082 00084 extern const char* goal_types[]; 00085 00087 extern const int goal_elms; 00088 00090 00093 long load_game(channel *ch); 00094 00096 game get_game(long id); 00097 00098 #endif