author | celestar |
Wed, 14 Mar 2007 10:00:56 +0000 | |
branch | gamebalance |
changeset 9889 | cfd2278f9099 |
parent 9888 | 7cf72895ca8c |
child 9901 | a922f277ebfd |
permissions | -rw-r--r-- |
9881
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
1 |
/* $Id$ */ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
2 |
|
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
3 |
/** @file */ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
4 |
|
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
5 |
#include "economy_new.h" |
9888
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
6 |
#include "town.h" |
9881
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
7 |
|
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
8 |
/** The global economy */ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
9 |
CEconomy *_eco; |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
10 |
|
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
11 |
/** |
9888
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
12 |
* Adjust the global activity level by the cumulative activity level of all towns. |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
13 |
* This is to iron out the difference between the sum of all economic activites of |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
14 |
* all towns and the the product of the economic activity per capita times the |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
15 |
* population of the map. |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
16 |
*/ |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
17 |
void CEconomy::AdjustActivityByTowns() |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
18 |
{ |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
19 |
Town *t; |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
20 |
FixedT<int64, 16> total_activity = 0; |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
21 |
FixedT<int64, 16> old_activity = m_activity_level; |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
22 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
23 |
FOR_ALL_TOWNS(t) { |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
24 |
total_activity += (t->GetActivity() * t->population * m_activity_level); |
9889
cfd2278f9099
(svn r9165) [gamebalance] -Add: Towns now have different levels of wealth. Alas, it doesn't have any influence either up to now
celestar
parents:
9888
diff
changeset
|
25 |
DEBUG(eco, 6, "Obtained EAL of %f", (double)t->GetActivity()); |
9888
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
26 |
} |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
27 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
28 |
DEBUG(eco, 5, "Global EAL is %f", (double)m_activity_level * GetWorldPopulation()); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
29 |
DEBUG(eco, 5, "Total EAL of all towns is %f", (double)total_activity); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
30 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
31 |
m_activity_level = total_activity / GetWorldPopulation(); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
32 |
DEBUG(eco, 4, "Adjusting global EAL to %f (ratio %f)", (double)m_activity_level, (double)(m_activity_level/old_activity)); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
33 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
34 |
FOR_ALL_TOWNS(t) t->SetActivity(t->GetActivity() * old_activity / m_activity_level); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
35 |
} |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
36 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
37 |
/** |
9881
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
38 |
* Starts a new economy. As there can always be only one economy in place, |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
39 |
* deletes the one that is currently active |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
40 |
*/ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
41 |
void InitializeEconomy() |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
42 |
{ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
43 |
delete _eco; |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
44 |
_eco = new CEconomy; |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
45 |
assert(_eco != NULL); |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
46 |
} |