Money.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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: Money.h ////////////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: Money.h
  36. //
  37. // Created: Steven Johnson, October 2001
  38. //
  39. // Desc: @todo
  40. //
  41. //-----------------------------------------------------------------------------
  42. #pragma once
  43. #ifndef _MONEY_H_
  44. #define _MONEY_H_
  45. #include "Lib/BaseType.h"
  46. #include "Common/Debug.h"
  47. #include "Common/Snapshot.h"
  48. // ----------------------------------------------------------------------------------------------
  49. /**
  50. How much "money" (Tiberium, Gems, Magic Resource Boxes, whatever) the Player has.
  51. This is currently a Very Simple Class but is encapsulated
  52. in anticipation of future expansion.
  53. */
  54. class Money : public Snapshot
  55. {
  56. public:
  57. inline Money() : m_money(0), m_playerIndex(0)
  58. {
  59. }
  60. void init()
  61. {
  62. m_money = 0;
  63. }
  64. inline UnsignedInt countMoney() const
  65. {
  66. return m_money;
  67. }
  68. /// returns the actual amount withdrawn, which may be less than you want. (sorry, can't go into debt...)
  69. UnsignedInt withdraw(UnsignedInt amountToWithdraw, Bool playSound = TRUE);
  70. void deposit(UnsignedInt amountToDeposit, Bool playSound = TRUE);
  71. void setPlayerIndex(Int ndx) { m_playerIndex = ndx; }
  72. protected:
  73. // snapshot methods
  74. virtual void crc( Xfer *xfer );
  75. virtual void xfer( Xfer *xfer );
  76. virtual void loadPostProcess( void );
  77. private:
  78. UnsignedInt m_money; ///< amount of money
  79. Int m_playerIndex; ///< what is my player index?
  80. };
  81. #endif // _MONEY_H_