forked from vaendryl/Sunrider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade.rpy
291 lines (251 loc) · 10.9 KB
/
upgrade.rpy
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
screen upgrade:
modal True
add "Menu/upgrade_back.jpg"
text '{!s}$'.format(BM.money):
size 50
xpos 0.15
ypos 0.7
color '090'
outlines [(1,'000',0,0)]
imagebutton:
xpos 0.05 ypos 925
action Return("submit")
idle "Menu/submit.jpg"
hover "Menu/submit_hover.jpg"
imagebutton:
xpos 0.05 ypos 975
action Return("quit")
idle "Menu/return.jpg"
hover "Menu/return_hover.jpg"
if BM.selected == None:
$ BM.selected = sunrider
$ ship = BM.selected
$ can_use_melee = False
for weapon in ship.weapons:
if weapon.wtype == 'Melee':
$ can_use_melee = True
$ uses_kinetics = False
for weapon in ship.weapons:
if weapon.wtype == 'Kinetic' or weapon.wtype == 'Assault':
$ uses_kinetics = True
$ uses_lasers = False
for weapon in ship.weapons:
if weapon.wtype == 'Laser' or weapon.wtype == 'Pulse':
$ uses_lasers = True
#dictionaries are inherently unsorted, so this is needed ;_;
$ upgrade_list = []
$ upgrade_list.append(["BASIC -----------",None,None,None,None])
$ upgrade_list.append(ship.upgrades['max_hp'])
$ upgrade_list.append(ship.upgrades['max_en'])
$ upgrade_list.append(ship.upgrades['evasion'])
# $ upgrade_list.append(ship.upgrades['move_cost']) #probably should be set individually in design
if uses_kinetics:
$ upgrade_list.append(["KINETIC -----------",None,None,None,None])
$ upgrade_list.append(ship.upgrades['kinetic_dmg'])
$ upgrade_list.append(ship.upgrades['kinetic_acc'])
$ upgrade_list.append(ship.upgrades['kinetic_cost'])
if uses_lasers:
$ upgrade_list.append(["LASER -----------",None,None,None,None])
$ upgrade_list.append(ship.upgrades['energy_dmg'])
$ upgrade_list.append(ship.upgrades['energy_acc'])
$ upgrade_list.append(ship.upgrades['energy_cost'])
if ship.max_missiles > 0:
$ upgrade_list.append(["MISSILE -----------",None,None,None,None])
$ upgrade_list.append(ship.upgrades['missile_dmg'])
$ upgrade_list.append(ship.upgrades['missile_eccm'])
$ upgrade_list.append(ship.upgrades['missile_cost'])
$ upgrade_list.append(ship.upgrades['max_missiles'])
if can_use_melee:
$ upgrade_list.append(["MELEE -----------",None,None,None,None])
$ upgrade_list.append(ship.upgrades['melee_dmg'])
$ upgrade_list.append(ship.upgrades['melee_acc'])
$ upgrade_list.append(ship.upgrades['melee_cost'])
$ upgrade_list.append(["DEFENSES -----------",None,None,None,None])
if ship.shield_generation > 0:
$ upgrade_list.append(ship.upgrades['shield_generation'])
$ upgrade_list.append(ship.upgrades['shield_range'])
if ship.flak > 0:
$ upgrade_list.append(ship.upgrades['flak'])
$ upgrade_list.append(ship.upgrades['base_armor'])
if ship.repair > 0:
$ upgrade_list.append(ship.upgrades['repair'])
if ship == sunrider:
add "Menu/upgrade_sunrider.png"
if ship == blackjack:
add "Menu/upgrade_blackjack.png"
if ship == liberty:
add "Menu/upgrade_liberty.png"
if ship == phoenix:
add "Menu/upgrade_phoenix.png"
if ship == bianca:
add "Menu/upgrade_bianca.png"
if ship == seraphim:
add "Menu/upgrade_seraphim.png"
if ship == paladin:
add "Menu/upgrade_paladin.png"
textbutton 'DEBUG: reset upgrades (refunds money)':
xalign 1.0
ypos 0.0
text_size 30
text_color 'fff'
text_outlines [(1,'000',0,0)]
action Return('reset')
##defunct
# textbutton 'next ship':
# xpos 0.8
# ypos 0.1
# text_size 50
# text_color 'fff'
# text_outlines [(1,'000',0,0)]
# action Return('next')
## show icons of all the player ships in player_ships
$ count = 0
for iconship in player_ships:
$ icon = None
$ hovericon = None
$ xposition = 1640
if count % 2 != 0:
$ xposition = 1758
$ yposition = 441 + count * 70
if iconship.name == 'Sunrider':
$ icon = 'Menu/upgrade_sunrider_button.png'
$ hovericon = 'Menu/upgrade_sunrider_button_hover.png'
elif iconship.name == 'Liberty':
$ icon = 'Menu/upgrade_liberty_button.png'
$ hovericon = 'Menu/upgrade_liberty_button_hover.png'
elif iconship.name == 'Black Jack':
$ icon = 'Menu/upgrade_blackjack_button.png'
$ hovericon = 'Menu/upgrade_blackjack_button_hover.png'
elif iconship.name == 'Havoc':
$ icon = 'Menu/upgrade_havoc_button.png'
$ hovericon = 'Menu/upgrade_havoc_hover.png'
elif iconship.name == 'Phoenix':
$ icon = 'Menu/upgrade_phoenix_button.png'
$ hovericon = 'Menu/upgrade_phoenix_button_hover.png'
elif iconship.name == 'Seraphim':
$ icon = 'Menu/upgrade_seraphim_button.png'
$ hovericon = 'Menu/upgrade_seraphim_hover.png'
elif iconship.name == 'Bianca':
$ icon = 'Menu/upgrade_bianca_button.png'
$ hovericon = 'Menu/upgrade_bianca_hover.png'
elif iconship.name == 'Paladin':
$ icon = 'Menu/upgrade_paladin_button.png'
$ hovericon = 'Menu/upgrade_paladin_button_hover.png'
imagebutton:
xpos xposition
ypos yposition
action SetField(BM,'selected',iconship)
idle icon
hover hovericon
focus_mask True
$ count += 1
vbox:
area (40, 270, 1050, 440)
viewport id "upgrade_list":
draggable True
mousewheel True
scrollbars "vertical"
child_size (1050,2000)
vbox:
for upgrade in upgrade_list:
if upgrade[1] == None:
add "Menu/upgrade_blank.png"
else:
add "Menu/upgrade_item.png"
vbox:
ypos 10
xpos 20
spacing 23
for upgrade in upgrade_list:
if upgrade[1] == None:
text upgrade[0]:
color '000'
else:
$ name,level,increase,cost,multiplier = upgrade
$ attribute = ""
for key in ship.upgrades:
if ship.upgrades[key][0] == name:
$ attribute = key
$ current = getattr(ship,attribute)
hbox:
text name:
color '000'
min_width 460
if increase < 1:
text str(current*100)+'% -> '+ str((current+increase)*100)+'%':
color '000'
min_width 260
else:
text str(current)+' -> '+ str(current+increase):
color '000'
min_width 260
text str(level):
color '000'
min_width 110
text str(cost):
color '000'
min_width 120
if BM.money >= cost:
textbutton '+':
text_color 'fff'
action Return(['+', attribute])
hovered SetField(BM,'active_upgrade',upgrade)
unhovered SetField(BM,'active_upgrade',None)
else:
textbutton 'X':
text_color 'c00'
action NullAction()
hovered SetField(BM,'active_upgrade',upgrade)
unhovered SetField(BM,'active_upgrade',None)
for pending in BM.pending_upgrades:
if pending[0] == BM.selected and pending[1] == attribute:
textbutton '-':
text_color 'fff'
action Return(['-', attribute])
hovered SetField(BM,'active_upgrade',upgrade)
unhovered SetField(BM,'active_upgrade',None)
$ break
##show weapon icons and their stats##
if BM.active_upgrade != None:
$ name,level,increase,cost,multiplier = BM.active_upgrade
$ quantifier = ''
if increase < 1 or name == 'Missile Flak Resistance':
$ type = None
if name.find('Damage') != -1:
$ type = 'damage'
$ quantifier = 'DMG'
if name.find('Accuracy') != -1:
$ type = 'accuracy'
$ quantifier = '%'
if name.find('Energy Cost') != -1:
$ type = 'energy_use'
$ quantifier = 'EN'
if name.find('Flak Resistance') != -1:
$ type = 'eccm'
$ quantifier = ' Flak Resistance'
$ count = 0
for weapon in ship.weapons:
if name.find( weapon_type(weapon) ) == 0:
add weapon.lbl:
ypos (750 + count*140)
xpos 480
frame:
background Solid((255,255,255,255))
xpos 640
ypos (820 + count*140)
yanchor 0.5
has vbox
$ stat = getattr(weapon,type)
if increase < 1:
$ current = int(stat * (1.0+increase*(level-1)) )
$ next = int(stat * (1.0+increase * level ))
else:
$ current = stat + increase * (level-1)
$ next = stat + increase * level
if weapon.wtype == 'Rocket':
$ stat += 10
# text weapon.name:
# color '000'
text str(current)+quantifier+' -> '+ str(next) + quantifier:
color '000'
$ count += 1