1 /*************************************************************************** 2 * Copyright (C) 2012 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 H2BATTLE_ARMY_H 24 #define H2BATTLE_ARMY_H 25 26 #include "army.h" 27 #include "bitmodes.h" 28 29 namespace Rand 30 { 31 class DeterministicRandomGenerator; 32 } 33 34 namespace Battle 35 { 36 class Unit; 37 class TroopsUidGenerator; 38 39 class Units : public std::vector<Unit *> 40 { 41 public: 42 Units(); 43 Units( const Units &, bool filter = false ); 44 virtual ~Units() = default; 45 46 Units & operator=( const Units & ) = delete; 47 48 Unit * FindMode( uint32_t mod ) const; 49 Unit * FindUID( uint32_t pid ) const; 50 51 void SortSlowest(); 52 void SortFastest(); 53 void SortArchers(); 54 }; 55 56 class Force : public Units, public BitModes 57 { 58 public: 59 Force( Army & parent, bool opposite, const Rand::DeterministicRandomGenerator & randomGenerator, TroopsUidGenerator & generator ); 60 Force( const Force & ) = delete; 61 62 ~Force() override; 63 64 Force & operator=( const Force & ) = delete; 65 66 HeroBase * GetCommander( void ); 67 const HeroBase * GetCommander( void ) const; 68 69 bool isValid( const bool considerBattlefieldArmy = true ) const; 70 bool HasMonster( const Monster & ) const; 71 u32 GetDeadHitPoints( void ) const; 72 u32 GetDeadCounts( void ) const; 73 int GetColor( void ) const; 74 int GetControl( void ) const; 75 uint32_t GetSurrenderCost( void ) const; 76 Troops GetKilledTroops( void ) const; 77 bool animateIdleUnits(); 78 void resetIdleAnimation(); 79 80 void NewTurn( void ); 81 void SyncArmyCount(); 82 83 static Unit * GetCurrentUnit( const Force & army1, const Force & army2, bool part1, int preferredColor ); 84 static void UpdateOrderUnits( const Force & army1, const Force & army2, const Unit * activeUnit, int preferredColor, const Units & orderHistory, Units & orders ); 85 86 private: 87 Army & army; 88 std::vector<u32> uids; 89 }; 90 } 91 92 #endif 93