######################################################################################## # 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 ######################################################################################## # Recruits init python: import json def recruit(t, a): global Player raw=send_packet("recruit", recruitdata(t, a)) rc=json_decode(raw) try: return int(rc) except: pass # Update data try: Player[rc["currency"][0]]=rc["currency"][1] except: renpy.notify("ERROR, Currency is undefined.") for unit in rc["units"]: _window_hide(None) if (debug): print str(unit) idx=inventoryplace() unit["unit_id"]=int(unit["unit_id"]) if (debug): print "Recruit index: %d" % idx print "Player inventory: %s" % str(Player["inv"]) print "Unit ID: %s" % str(unit["unit_id"]) print "Unit Name: %s" % str(allunits[int(unit["unit_id"])]["name"]) print "Unit Rarity: %d" % allunits[int(unit["unit_id"])]["rare"] Player["inv"][idx]=unit txt=allunits[int(unit["unit_id"])]["name"] rar=allunits[int(unit["unit_id"])]["rare"] star=star_write(rar) sprite=str(unit["unit_id"]) show_img("unit_"+sprite, at_list=[truecenter]) renpy.pause(0.1) renpy.call_screen("msgbox", "%s\n\nRecruited %d★ %s" % (star, rar, txt)) renpy.hide("unit_"+sprite) _window_show(None) # Return result if (rc["code"] == ERR_NOGEMS): renpy.notify("You don't have enough gems to complete.") if (rc["code"] == ERR_INVFULL): renpy.notify("You don't have enough space to complete!") return rc["code"] label tavern: $ show_img("bg tavern", False, ext=".jpg") # Validate scene bg tavern play music MUSIC_PARTY.id() fadein 0.5 window hide jump tv_loop label tv_loop: $currencies="{size=18}Crystals: %d | GP: %d{/size}" % (Player["crystals"], Player["gp"]) menu: "Recruit 1 units for 200 gems": $message=recruit(1, 1) #"Recruit 5 units for 1000 gems": # $message=recruit(1, 5) "Recruit 10 units for 2000 gems\n{i}One 4★ guaranteed!{/i}": $message=recruit(1, 10) "GP Tavern: Recruit 1 units for 1000 GP": $message=recruit(2, 1) "GP Tavern: Recruit 10 units for 10,000 GP\n{i}One Fairy or Mana Egg guaranteed!{/i}": $message=recruit(2, 10) "Chances & Info": # TODO WIP: Read JSON Instead "{b}Crystal Tavern{/b}" "\ 4★ chance: 0.75 %%\n\ 3★ chance: 2.00 %%\n\ 2★ chance: 15.00 %%\n\ 1★ chance: 82.25 %%" "{b}GP Tavern{/b}" "\ Fairies: 2.00 %%\n\ 1★ chance: 98.00 %%" "{b}This is a placeholder{/b}" "{i}It is possible to render each unit inidividual chance but we're not doing this (yet){/i}\nPlease be patient." "Do nothing\n[currencies]": jump restore if (message == OFFLINEMSG): "Server replies:" "[message]\n\nYou are offline?" return jump tv_loop