Planeshift
economymanager.h
Go to the documentation of this file.
1
/*
2
* economymanager.h
3
*
4
* Copyright (C) 2005 Atomic Blue (info@planeshift.it, http://www.planeshift.it)
5
*
6
* Credits : Christian Svensson
7
*
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public License
10
* as published by the Free Software Foundation (version 2
11
* of the License).
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
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
*
20
* Creation Date: 11/Jan 2005
21
* Description : This is the header file for the economymanager
22
* This manager handles all the exchange/trade things and calculates
23
* prices and keeps histories of transactions and so on
24
*
25
*/
26
27
#ifndef ECONOMYMANAGER_HEADER
28
#define ECONOMYMANAGER_HEADER
29
30
//=============================================================================
31
// Crystal Space Includes
32
//=============================================================================
33
#include <csutil/hash.h>
34
#include <csutil/sysfunc.h>
35
36
//=============================================================================
37
// Project Includes
38
//=============================================================================
39
#include "
util/gameevent.h
"
40
41
//=============================================================================
42
// Local Includes
43
//=============================================================================
44
#include "
msgmanager.h
"
// Parent class
45
46
47
struct
TransactionEntity
:
public
csRefCount
48
{
49
PID
from
;
50
PID
to
;
51
52
csString
fromName
;
53
csString
toName
;
54
csString
itemName
;
55
56
unsigned
int
item
;
57
int
count
;
58
int
quality
;
59
unsigned
int
price
;
60
61
bool
moneyIn
;
62
int
stamp
;
63
64
TransactionEntity
() :
65
from(0), to(0), fromName(
"NA"
), toName(
"NA"
), itemName(
"NA"
), item(0),
66
count(0), quality(0), price(0), moneyIn(false), stamp(0)
67
{ }
68
};
69
70
struct
ItemSupplyDemandInfo
:
public
csRefCount
71
{
72
unsigned
int
itemId
;
73
unsigned
int
bought
;
74
unsigned
int
sold
;
75
};
76
77
class
EconomyManager
:
public
MessageManager
<EconomyManager>
78
{
79
public
:
80
EconomyManager
();
81
~
EconomyManager
();
82
83
void
HandleBuyMessage(
MsgEntry
* me,
Client
* client);
84
void
HandleSellMessage(
MsgEntry
* me,
Client
* client);
85
void
HandlePickupMessage(
MsgEntry
* me,
Client
* client);
86
void
HandleDropMessage(
MsgEntry
* me,
Client
* client);
87
void
HandleLootMessage(
MsgEntry
* me,
Client
* client);
88
89
void
AddTransaction(
TransactionEntity
* trans,
bool
sell,
const
char
* type);
90
91
TransactionEntity
* GetTransaction(
int
id
);
92
unsigned
int
GetTotalTransactions();
93
void
ClearTransactions();
94
void
ScheduleDrop(csTicks ticks,
bool
loop);
95
96
ItemSupplyDemandInfo
* GetItemSupplyDemandInfo(
unsigned
int
itemId);
97
98
struct
Economy
99
{
100
// Money flowing in to the economy
101
unsigned
int
lootValue
;
102
unsigned
int
sellingValue
;
103
unsigned
int
pickupsValue
;
104
// Money flowing out of the economy
105
unsigned
int
buyingValue
;
106
unsigned
int
droppedValue
;
107
108
Economy
() : lootValue(0), sellingValue(0), pickupsValue(0), buyingValue(0), droppedValue(0) { };
109
};
110
111
Economy
economy
;
112
113
protected
:
114
csArray< csRef<TransactionEntity> >
history
;
115
csHash< csRef<ItemSupplyDemandInfo> >
supplyDemandInfo
;
116
};
117
118
119
class
psEconomyDrop
:
public
psGameEvent
120
{
121
public
:
122
psEconomyDrop
(
EconomyManager
* manager,csTicks ticks,
bool
loop);
123
void
Trigger();
124
protected
:
125
EconomyManager
*
economy
;
126
csTicks
eachTimeTicks
;
127
bool
loop
;
128
};
129
130
#endif
131
ItemSupplyDemandInfo::itemId
unsigned int itemId
Definition:
economymanager.h:72
EconomyManager::Economy::lootValue
unsigned int lootValue
Definition:
economymanager.h:101
ItemSupplyDemandInfo::sold
unsigned int sold
Definition:
economymanager.h:74
TransactionEntity::itemName
csString itemName
Definition:
economymanager.h:54
TransactionEntity::toName
csString toName
Definition:
economymanager.h:53
TransactionEntity::to
PID to
Definition:
economymanager.h:50
msgmanager.h
TransactionEntity::from
PID from
Definition:
economymanager.h:49
MsgEntry
The structure of 1 queue entry (pointer to a message)
Definition:
message.h:143
TransactionEntity::count
int count
Definition:
economymanager.h:57
EconomyManager::history
csArray< csRef< TransactionEntity > > history
Definition:
economymanager.h:114
EconomyManager::Economy::buyingValue
unsigned int buyingValue
Definition:
economymanager.h:105
ItemSupplyDemandInfo::bought
unsigned int bought
Definition:
economymanager.h:73
TransactionEntity::item
unsigned int item
Definition:
economymanager.h:56
EconomyManager::Economy
Definition:
economymanager.h:98
ItemSupplyDemandInfo
Definition:
economymanager.h:70
gameevent.h
csRefCount
psEconomyDrop::loop
bool loop
Definition:
economymanager.h:127
EconomyManager::Economy::sellingValue
unsigned int sellingValue
Definition:
economymanager.h:102
TransactionEntity::quality
int quality
Definition:
economymanager.h:58
TransactionEntity
Definition:
economymanager.h:47
TransactionEntity::moneyIn
bool moneyIn
Definition:
economymanager.h:61
TransactionEntity::stamp
int stamp
Definition:
economymanager.h:62
EconomyManager::Economy::pickupsValue
unsigned int pickupsValue
Definition:
economymanager.h:103
Client
This class collects data of a netclient.
Definition:
client.h:95
EconomyManager::Economy::Economy
Economy()
Definition:
economymanager.h:108
TransactionEntity::TransactionEntity
TransactionEntity()
Definition:
economymanager.h:64
EconomyManager::supplyDemandInfo
csHash< csRef< ItemSupplyDemandInfo > > supplyDemandInfo
Definition:
economymanager.h:115
TransactionEntity::fromName
csString fromName
Definition:
economymanager.h:52
psEconomyDrop::eachTimeTicks
csTicks eachTimeTicks
Definition:
economymanager.h:126
EconomyManager::economy
Economy economy
Definition:
economymanager.h:111
TransactionEntity::price
unsigned int price
Definition:
economymanager.h:59
psEconomyDrop::economy
EconomyManager * economy
Definition:
economymanager.h:125
EconomyManager
Definition:
economymanager.h:77
psGameEvent
All scheduled events must inherit from this class.
Definition:
gameevent.h:36
psEconomyDrop
Definition:
economymanager.h:119
EconomyManager::Economy::droppedValue
unsigned int droppedValue
Definition:
economymanager.h:106
MessageManager
Provides a manager to facilitate subscriptions.
Definition:
msgmanager.h:106
server
economymanager.h
Generated on Sat Jun 19 2021 05:00:33 for Planeshift by
1.8.11