-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApartment.gd
135 lines (103 loc) · 3.08 KB
/
Apartment.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
extends 'Building.gd'
tool
const type := Global.BuildingType.APARTMENT_BUILDING
const effects := [Global.StatType.POPULATION_CAP]
var building_name = 'Apartment Building'
var description = 'Provides housing for the ultimate pollution producers: people.'
func init(world):
.init(world)
supports_boost = false
update_upgrade_label()
update_recruiter_action()
add_upgrade_action(level, levels)
# notify any interested listeners that there might be some changes
emit_signal("info_updated", self, Global.StatType.POPULATION_CAP, get_population_cap())
world.connect("info_updated", self, "_on_world_info_updated")
func init_data():
levels = [
{
'number': 1,
'description': 'Tiny apartment building.',
'base_population_cap': 100,
},
{
'number': 2,
'description': 'Small apartment building.',
'base_population_cap': 5000,
},
{
'number': 3,
'description': 'Not quite medium apartment building.',
'base_population_cap': 100000,
},
{
'number': 4,
'description': 'Medium-sized apartment building.',
'base_population_cap': 500000,
},
{
'number': 5,
'description': 'Above-average apartment building',
'base_population_cap': 5000000,
},
{
'number': 6,
'description': 'Big apartment building.',
'base_population_cap': 10000000,
},
{
'number': 7,
'description': 'Huge apartment building.',
'base_population_cap': 50000000,
},
{
'number': 8,
'description': 'Gigantic apartment building.',
'base_population_cap': 200000000,
},
{
'number': 9,
'description': 'Colossal apartment building.',
'base_population_cap': 1000000000,
},
]
current_level = levels[0]
func get_stats():
return [
Global.new_stat(Global.StatType.LEVEL, level),
Global.new_stat(Global.StatType.POPULATION_CAP, get_population_cap()),
]
func get_population_cap():
return current_level['base_population_cap']
func get_property(property):
if property == Global.StatType.POPULATION_CAP:
return get_population_cap()
func get_level_upgrade_price(level):
if level < 8:
return int(pow(100, level))
else:
return int(pow(100, 7)) * int(pow(2, level - 7))
func get_actions():
return $actions.get_children()
func post_level_upgrade():
emit_signal("info_updated", self, Global.StatType.POPULATION_CAP, get_population_cap())
func perform_action(action, count):
if action.name == 'level_upgrade':
set_level(level + 1)
return
match action.name:
'recruiter':
world.hire_recruiter(count)
action.price = world.get_recruiter_price()
func update_recruiter_action():
$actions/recruiter.description = 'Hire a recruiter to help you get more people into your planet paradise. Each recruiter recruits one person per cycle. Recruiters are shared between all apartment buildings. Current recruiters in the world: ' + str(world.recruiters)
$actions/recruiter.price = world.get_recruiter_price()
func _serialize():
return {}
func _deserialize(_data):
update()
func _on_world_info_updated(_world, item, _value):
if item == Global.StatType.MONEY:
update_upgrade_label()
if item == Global.StatType.RECRUITERS:
update_recruiter_action()