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 #ifndef H2MAPSFILEINFO_H 23 #define H2MAPSFILEINFO_H 24 25 #include <string> 26 #include <vector> 27 28 #include "gamedefs.h" 29 #include "math_base.h" 30 #include "types.h" 31 32 class StreamBase; 33 34 enum class GameVersion : int 35 { 36 SUCCESSION_WARS = 0, 37 PRICE_OF_LOYALTY = 1 38 }; 39 40 namespace Maps 41 { 42 struct FileInfo 43 { 44 FileInfo(); 45 FileInfo( const FileInfo & ); 46 47 ~FileInfo() = default; 48 49 FileInfo & operator=( const FileInfo & ); 50 51 bool ReadMP2( const std::string & ); 52 bool ReadSAV( const std::string & ); 53 54 bool operator==( const FileInfo & fi ) const 55 { 56 return file == fi.file; 57 } 58 static bool NameSorting( const FileInfo &, const FileInfo & ); 59 static bool FileSorting( const FileInfo &, const FileInfo & ); 60 61 bool isAllowCountPlayers( int playerCount ) const; 62 bool isMultiPlayerMap( void ) const; 63 int AllowCompHumanColors( void ) const; 64 int AllowHumanColors( void ) const; 65 int HumanOnlyColors( void ) const; 66 int ComputerOnlyColors( void ) const; 67 68 int KingdomRace( int color ) const; 69 70 uint32_t ConditionWins() const; 71 uint32_t ConditionLoss() const; 72 bool WinsCompAlsoWins( void ) const; 73 int WinsFindArtifactID( void ) const; 74 bool WinsFindUltimateArtifact( void ) const; 75 u32 WinsAccumulateGold( void ) const; 76 fheroes2::Point WinsMapsPositionObject( void ) const; 77 fheroes2::Point LossMapsPositionObject( void ) const; 78 u32 LossCountDays( void ) const; 79 80 std::string String( void ) const; 81 void Reset( void ); 82 83 std::string file; 84 std::string name; 85 std::string description; 86 87 u16 size_w; 88 u16 size_h; 89 u8 difficulty; 90 u8 races[KINGDOMMAX]; 91 u8 unions[KINGDOMMAX]; 92 93 u8 kingdom_colors; 94 u8 allow_human_colors; 95 u8 allow_comp_colors; 96 u8 rnd_races; 97 98 enum VictoryCondition : uint8_t 99 { 100 VICTORY_DEFEAT_EVERYONE = 0, 101 VICTORY_CAPTURE_TOWN = 1, 102 VICTORY_KILL_HERO = 2, 103 VICTORY_OBTAIN_ARTIFACT = 3, 104 VICTORY_DEFEAT_OTHER_SIDE = 4, 105 VICTORY_COLLECT_ENOUGH_GOLD = 5 106 }; 107 108 enum LossCondition : uint8_t 109 { 110 LOSS_DEFAULT = 0, 111 LOSS_TOWN = 1, 112 LOSS_HERO = 2, 113 LOSS_OUT_OF_TIME = 3 114 }; 115 116 uint8_t conditions_wins; // refer to VictoryCondition 117 bool comp_also_wins; 118 bool allow_normal_victory; 119 u16 wins1; 120 u16 wins2; 121 uint8_t conditions_loss; // refer to LossCondition 122 u16 loss1; 123 u16 loss2; 124 125 u32 localtime; 126 127 bool startWithHeroInEachCastle; 128 129 GameVersion _version; 130 131 private: 132 void FillUnions( const int side1Colors, const int side2Colors ); 133 }; 134 135 StreamBase & operator<<( StreamBase &, const FileInfo & ); 136 StreamBase & operator>>( StreamBase &, FileInfo & ); 137 } 138 139 using MapsFileInfoList = std::vector<Maps::FileInfo>; 140 141 namespace Maps 142 { 143 MapsFileInfoList PrepareMapsFileInfoList( const bool multi ); 144 } 145 146 #endif 147