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
|
########################################################################################
# This file is part of Spheres.
# Copyright (C) 2019 Jesusalva
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
########################################################################################
# Player data displays
init python:
def inventoryplace():
global Player
# Return next free slot index
try:
return Player["inv"].index(None)
except:
return len(Player["inv"])
def get_inventory():
raw=send_packet("get_inv", "")
pt=json_decode(raw)
if (pt == ERR_JSONDECODER):
return ERR_JSONDECODER
if (pt == FAILUREMSG):
# TODO: msgbox you're offline, quit
return ERR_LOGIN_DEFAULT
print "get_inv(): "+str(pt)
return pt
screen inventory(blank=False, filters="True"):
# window
# hbox
vpgrid:
cols 4
spacing 5
draggable True
mousewheel True
scrollbars "vertical"
side_xalign 0.5
xoffset 15
#yoffset 45
#xfill True
yfill True
# The close button returns -1 and comes first
imagebutton:
if not blank:
idle At("gfx/square/back_idle.png", czoom_70)
hover At("gfx/square/back_hover.png", czoom_70)
else:
idle At("gfx/square/bg.png", czoom_70)
action Return(-1)
for i, item in enumerate(Player["inv"]):
# We don't care for None items
if item is not None:
# Needed because eval :rolling_eyes:
#$ ir=copy.copy(item["rare"])
#$ print str(locals())
python:
evl=False
#print "---- repr"
try:
alu=allunits[item["unit_id"]]
except:
alu={}
stdout("ERROR, alu: not defined, index %d" % i)
evl=eval(filters, globals(), locals())
#print str(evl)
#print str(filters)
#print str(item)
#print str(alu)
if evl:
python:
show_img("square_%d" % item["unit_id"], False)
try:
btn=At("square_%d" % item["unit_id"], czoom_70)
except:
btn=At("square_0", czoom_70)
traceback.print_exc()
stdout("[ERROR] ATCODE FOR square_%d is INVALID" % item["unit_id"])
#btn=At("square_10000300", czoom_70)
imagebutton:
idle btn
action Return(i)
#alternate "Show the char data chart"
screen char_details(un, hpval, akval, idx):
style_prefix "confirm"
frame:
at msgbox_emp
vbox:
xalign 0.5
yalign 0.5
spacing 30
label _("{b}%s{/b}\n%s\n\nHP: %d\nATK: %d\nLv %d/%d\nEXP: %d") % (
star_write(un["rare"]), un["name"],
hpval, akval,
Player["inv"][idx]["level"],
un["max_level"],
Player["inv"][idx]["exp"]):
style "confirm_prompt"
xalign 0.5
hbox:
xalign 0.5
spacing 100
textbutton _("Merge") action [SensitiveIf(Player["inv"][idx]["level"] < un["max_level"]), Return(-1)]
textbutton _("Evolve") action [SensitiveIf(evocheck(Player["inv"][idx]["level"], un)), Return(-2)]
hbox:
xalign 0.5
spacing 100
textbutton _("Ok") action Return(0)
## Right-click and escape answer "no".
key "game_menu" action Return(0)
# Show inventory button
label inventory:
play music MUSIC_PARTY.id() fadein 0.5
$ hud_clear()
# Try to update inventory
$ inv=get_inventory()
python:
try:
renpy.call_screen("msgbox", "Error: %d" % int(inv))
except:
Player["inv"]=dlist()
for a in inv:
Player["inv"].append(a)
label show_inv:
call screen inventory
if (_return >= 0):
$stdout("Selected unit index %d" % _return)
$un=allunits[Player["inv"][_return]["unit_id"]]
$show_img("unit_"+str(un["unit_id"]), at_list=[truecenter])
$hpval=readjust_status(un["rare"], un["job"],
True)*Player["inv"][_return]["level"]+un["hp"]
$akval=readjust_status(un["rare"], un["job"],
False)*Player["inv"][_return]["level"]+un["strength"]
$ret=renpy.call_screen("char_details", un, hpval, akval, _return)
# Proccess input
if ret == -1:
$who=_return
call upgrade_pre
elif ret == -2:
$who=_return
call evolve_pre
$renpy.hide("unit_"+str(un["unit_id"]))
else:
jump restore
jump show_inv
|