summaryrefslogtreecommitdiff
path: root/game/recruit.rpy
blob: 4d166d1d6f771326f584da1f3f2d9545130f8a6f (plain) (blame)
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
########################################################################################
#     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