VictoryConditions.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: VictoryConditions.h //////////////////////////////////////////////////////
  24. // Generals multiplayer victory condition specifications
  25. // Author: Matthew D. Campbell, February 2002
  26. #pragma once
  27. #ifndef __VICTORYCONDITIONS_H__
  28. #define __VICTORYCONDITIONS_H__
  29. #include "Common/SubsystemInterface.h"
  30. #include "Lib/BaseType.h"
  31. class Player;
  32. /*
  33. * bitfield for specifying which victory conditions will apply in multiplayer games
  34. */
  35. enum VictoryType
  36. {
  37. VICTORY_NOBUILDINGS = 1,
  38. VICTORY_NOUNITS = 2,
  39. };
  40. /**
  41. * VictoryConditionsInterface class - maintains information about the game setup and
  42. * the contents of its slot list hroughout the game.
  43. */
  44. class VictoryConditionsInterface : public SubsystemInterface
  45. {
  46. public:
  47. VictoryConditionsInterface() { m_victoryConditions = 0; }
  48. virtual void init( void ) = 0;
  49. virtual void reset( void ) = 0;
  50. virtual void update( void ) = 0;
  51. inline void setVictoryConditions( Int victoryConditions ) { m_victoryConditions = victoryConditions; }
  52. inline Int getVictoryConditions( void ) { return m_victoryConditions; }
  53. virtual Bool hasAchievedVictory(Player *player) = 0; ///< has a specific player and his allies won?
  54. virtual Bool hasBeenDefeated(Player *player) = 0; ///< has a specific player and his allies lost?
  55. virtual Bool hasSinglePlayerBeenDefeated(Player *player) = 0; ///< has a specific player lost?
  56. virtual void cachePlayerPtrs( void ) = 0; ///< players have been created - cache the ones of interest
  57. virtual Bool isLocalAlliedVictory( void ) = 0; ///< convenience function
  58. virtual Bool isLocalAlliedDefeat( void ) = 0; ///< convenience function
  59. virtual Bool isLocalDefeat( void ) = 0; ///< convenience function
  60. virtual Bool amIObserver( void ) = 0; ///< Am I an observer?( need this for scripts )
  61. virtual UnsignedInt getEndFrame( void ) = 0; ///< on which frame was the game effectively over?
  62. protected:
  63. Int m_victoryConditions;
  64. };
  65. VictoryConditionsInterface * createVictoryConditions( void );
  66. extern VictoryConditionsInterface *TheVictoryConditions;
  67. #endif // __VICTORYCONDITIONS_H__