1 /*************************************************************************** 2 * Copyright (C) 2009 by Andrey Afletdinov <fheroes2@gmail.com> * 3 * * 4 * Part of the Free Heroes2 Engine: * 5 * http://sourceforge.net/projects/fheroes2 * 6 * * 7 * This program is free software; you can redistribute it and/or modify * 8 * it under the terms of the GNU General Public License as published by * 9 * the Free Software Foundation; either version 2 of the License, or * 10 * (at your option) any later version. * 11 * * 12 * This program is distributed in the hope that it will be useful, * 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 * GNU General Public License for more details. * 16 * * 17 * You should have received a copy of the GNU General Public License * 18 * along with this program; if not, write to the * 19 * Free Software Foundation, Inc., * 20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 21 ***************************************************************************/ 22 23 #ifndef H2GAMEOVER_H 24 #define H2GAMEOVER_H 25 26 #include <string> 27 28 #include "game_mode.h" 29 30 class StreamBase; 31 32 namespace GameOver 33 { 34 enum conditions_t : uint32_t 35 { 36 COND_NONE = 0x00000000, 37 38 WINS_ALL = 0x00000001, 39 WINS_TOWN = 0x00000002, 40 WINS_HERO = 0x00000004, 41 WINS_ARTIFACT = 0x00000008, 42 WINS_SIDE = 0x00000010, 43 WINS_GOLD = 0x00000020, 44 45 WINS = WINS_ALL | WINS_TOWN | WINS_HERO | WINS_ARTIFACT | WINS_SIDE | WINS_GOLD, 46 47 LOSS_ALL = 0x00000100, 48 LOSS_TOWN = 0x00000200, 49 LOSS_HERO = 0x00000400, 50 LOSS_TIME = 0x00000800, 51 // These loss conditions apply if the enemy player won because of the corresponding win condition 52 LOSS_ENEMY_WINS_TOWN = 0x00010000, 53 LOSS_ENEMY_WINS_HERO = 0x00020000, 54 LOSS_ENEMY_WINS_ARTIFACT = 0x00040000, 55 LOSS_ENEMY_WINS_GOLD = 0x00080000, 56 57 LOSS = LOSS_ALL | LOSS_TOWN | LOSS_HERO | LOSS_TIME | LOSS_ENEMY_WINS_TOWN | LOSS_ENEMY_WINS_HERO | LOSS_ENEMY_WINS_ARTIFACT | LOSS_ENEMY_WINS_GOLD, 58 LOSS_ENEMY_WINS = LOSS_ENEMY_WINS_TOWN | LOSS_ENEMY_WINS_HERO | LOSS_ENEMY_WINS_ARTIFACT | LOSS_ENEMY_WINS_GOLD 59 }; 60 61 const char * GetString( uint32_t cond ); 62 std::string GetActualDescription( uint32_t cond ); 63 64 class Result 65 { 66 public: 67 static Result & Get( void ); 68 69 void Reset(); // Resets everything 70 void ResetResult(); // Resets just the result 71 72 uint32_t GetResult() const; 73 fheroes2::GameMode LocalCheckGameOver(); 74 75 private: 76 friend StreamBase & operator<<( StreamBase &, const Result & ); 77 friend StreamBase & operator>>( StreamBase &, Result & ); 78 79 Result(); 80 81 int colors; 82 uint32_t result; 83 bool continueAfterVictory; 84 }; 85 86 StreamBase & operator<<( StreamBase &, const Result & ); 87 StreamBase & operator>>( StreamBase &, Result & ); 88 } 89 90 #endif 91