Money.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /***********************************************************************
  2. *
  3. * SPACE TRADER 1.2.0
  4. *
  5. * Money.c
  6. *
  7. * Copyright (C) 2000-2002 Pieter Spronck, All Rights Reserved
  8. *
  9. * Additional coding by Sam Anderson (rulez2@home.com)
  10. * Additional coding by Samuel Goldstein (palm@fogbound.net)
  11. *
  12. * Some code of Matt Lee's Dope Wars program has been used.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  27. *
  28. * You can contact the author at space_trader@hotmail.com
  29. *
  30. * For those who are familiar with the classic game Elite: many of the
  31. * ideas in Space Trader are heavily inspired by Elite.
  32. *
  33. **********************************************************************/
  34. #include "external.h"
  35. // *************************************************************************
  36. // Functions Include:
  37. //
  38. // long CurrentWorth( void )
  39. // void PayInterest( void )
  40. //
  41. // *************************************************************************
  42. // Current worth of commander
  43. // *************************************************************************
  44. long CurrentWorth( void )
  45. {
  46. return (CurrentShipPrice( false ) + Credits - Debt + (MoonBought ? COSTMOON : 0));
  47. }
  48. // *************************************************************************
  49. // Pay interest on debt
  50. // *************************************************************************
  51. void PayInterest( void )
  52. {
  53. long IncDebt;
  54. if (Debt > 0)
  55. {
  56. IncDebt = max( 1, Debt / 10 );
  57. if (Credits > IncDebt)
  58. Credits -= IncDebt;
  59. else
  60. {
  61. Debt += (IncDebt - Credits);
  62. Credits = 0;
  63. }
  64. }
  65. }