Planeshift
bankmanager.h
Go to the documentation of this file.
1 /*
2 * bankmanager.h - Author: Mike Gist
3 *
4 * Copyright (C) 2007 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5 *
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation (version 2 of the License)
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 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 */
19 
20 #ifndef __BANKMANAGER_H__
21 #define __BANKMANAGER_H__
22 //=============================================================================
23 // Project Includes
24 //=============================================================================
25 #include "util/gameevent.h"
26 
27 //=============================================================================
28 // Local Includes
29 //=============================================================================
30 #include "msgmanager.h"
31 
32 class psMoneyGameEvent;
33 class Client;
34 
35 class BankManager : public MessageManager<BankManager>
36 {
37 public:
38  BankManager();
39  ~BankManager();
40  inline void StartBanking(Client* client, bool guild)
41  {
42  SendBankWindow(client, guild, true);
43  }
44  void ProcessTax();
45 
46 protected:
47  struct MoneyEvent
48  {
49  uint id;
50  uint taxid;
51  bool guild;
52  int nextEvent; // YearsFrom1900:DaysSinceJan1st e.g. 107000 for Jan 1st 2007
53  int interval; // In days
55  csString paid;
56  csString npaid;
57  csString fnpaid;
59  int lateBy;
60  bool updateDate;
62  };
63 
64 
65  template<class T>
66  void TaxAccount(T guildOrChar, MoneyEvent &monEvt, int index);
67 
68 private:
69  void SendBankWindow(Client* client, bool guild, bool forceOpen);
70  void WithdrawFunds(Client* client, bool guild, int circles, int octas, int hexas, int trias);
71  void DepositFunds(Client* client, bool guild, int circles, int octas, int hexas, int trias);
72  void ExchangeFunds(Client* client, bool guild, int coins, int coin);
73  psMoney* GetTotalFunds(psCharacter* pschar, bool guild);
74  void HandleBanking(MsgEntry* me, Client* client);
75  int CoinsForExchange(psCharacter* pschar, bool guild, int type, float fee);
76  int CalculateAccountLevel(psCharacter* pschar, bool guild);
77  inline float CalculateFee(psCharacter* pschar, bool guild);
78 
79  csArray<MoneyEvent> monEvts;
80 
81  MathScript* accountCharLvlScript;
82  MathScript* accountGuildLvlScript;
83  MathScript* CalcBankFeeScript;
84 };
85 
86 
88 {
89 public:
90 
91  psMoneyGameEvent(int delayTicks, BankManager* bankMan);
92 
93  virtual void Trigger()
94  {
95  bankManager->ProcessTax(); // Abstract event processing function
96  }
97 
98 private:
99  BankManager* bankManager;
100 };
101 
102 #endif // __BANKMANAGER_H__
void ProcessTax()
uint32 InstanceID
Definition: psconst.h:64
A MathScript is a mini-program to run.
Definition: mathscript.h:442
void StartBanking(Client *client, bool guild)
Definition: bankmanager.h:40
void TaxAccount(T guildOrChar, MoneyEvent &monEvt, int index)
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
virtual void Trigger()
Abstract event processing function.
Definition: bankmanager.h:93
This class collects data of a netclient.
Definition: client.h:95
All scheduled events must inherit from this class.
Definition: gameevent.h:36
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106