diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-12-18 01:49:36 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-12-18 01:49:36 -0300 |
commit | 76e68357de8c9d68864714d4c5d6134ea05837b1 (patch) | |
tree | 58a84074765e2cdd900def437d28373181d7107e /game/inventory.rpy | |
parent | 6966b0d86534654c010b32745c79d4fa02822fea (diff) | |
download | client-76e68357de8c9d68864714d4c5d6134ea05837b1.tar.gz client-76e68357de8c9d68864714d4c5d6134ea05837b1.tar.bz2 client-76e68357de8c9d68864714d4c5d6134ea05837b1.tar.xz client-76e68357de8c9d68864714d4c5d6134ea05837b1.zip |
Split player.rpy in four files
Diffstat (limited to 'game/inventory.rpy')
-rw-r--r-- | game/inventory.rpy | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/game/inventory.rpy b/game/inventory.rpy new file mode 100644 index 0000000..8551079 --- /dev/null +++ b/game/inventory.rpy @@ -0,0 +1,175 @@ +######################################################################################## +# 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: + imagebutton: + idle At(Composite( + (340, 340), + (0, 0), "gfx/square/bg.png", + (0, 0), "gfx/square/units/%d.png" % item["unit_id"], + (0, 0), "gfx/square/%d.png" % allunits[item["unit_id"]]["rare"], + ), czoom_70) + 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 + |