File size: 4,434 Bytes
657f2b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio

from util.champions import champions
from util.regions import regions


def output(*args):
    return f"inputs = {*args,}"


with gradio.Blocks() as demo:
    demo.title = "Faker Classifier"
    gradio.Markdown("""# Does Faker Win?""")
    with gradio.Row():
        # Blue Side
        with gradio.Column():
            gradio.Markdown("""## Blue Side""")
            blue_region = gradio.Dropdown(
                choices=regions,
                label="Team's Region",
                value="Korea",
                interactive=True,
            )
            blue_is_t1 = gradio.Checkbox(label="T1?", value=True)
            blue_top_champion = gradio.Dropdown(
                choices=champions,
                label="Top",
                value="Teemo",
                interactive=True,
            )
            blue_jungle_champion = gradio.Dropdown(
                choices=champions,
                label="Jungle",
                value="Teemo",
                interactive=True,
            )
            blue_mid_champion = gradio.Dropdown(
                choices=champions,
                label="Mid",
                value="Teemo",
                interactive=True,
            )
            blue_bot_champion = gradio.Dropdown(
                choices=champions,
                label="Bot",
                value="Teemo",
                interactive=True,
            )
            blue_support_champion = gradio.Dropdown(
                choices=champions,
                label="Support",
                value="Teemo",
                interactive=True,
            )

        # Red Side
        with gradio.Column():
            gradio.Markdown("""## Red Side""")
            red_region = gradio.Dropdown(
                choices=regions,
                label="Team's Region",
                value="Korea",
                interactive=True,
            )
            red_is_t1 = gradio.Checkbox(label="T1?")
            red_top_champion = gradio.Dropdown(
                choices=champions,
                label="Top",
                value="Teemo",
                interactive=True,
            )
            red_jungle_champion = gradio.Dropdown(
                choices=champions,
                label="Jungle",
                value="Teemo",
                interactive=True,
            )
            red_mid_champion = gradio.Dropdown(
                choices=champions,
                label="Mid",
                value="Teemo",
                interactive=True,
            )
            red_bot_champion = gradio.Dropdown(
                choices=champions,
                label="Bot",
                value="Teemo",
                interactive=True,
            )
            red_support_champion = gradio.Dropdown(
                choices=champions,
                label="Support",
                value="Teemo",
                interactive=True,
            )

        # Listeners
        red_is_t1.change(
            fn=lambda is_t1: not is_t1, inputs=red_is_t1, outputs=blue_is_t1
        )
        blue_is_t1.change(
            fn=lambda is_t1: not is_t1, inputs=blue_is_t1, outputs=red_is_t1
        )
        red_is_t1.change(
            fn=lambda is_t1: "Korea" if is_t1 else None,
            inputs=red_is_t1,
            outputs=red_region,
        )
        blue_is_t1.change(
            fn=lambda is_t1: "Korea" if is_t1 else None,
            inputs=blue_is_t1,
            outputs=blue_region,
        )
    gradio.Radio(
        ["Regular Season", "Playoffs", "Gauntlet", "International"],
        label="Tournament Type",
        interactive=True,
    ),

    # Output
    text_output = gradio.Textbox()
    output_btn = gradio.Button(value="Simulate match")
    output_btn.click(
        fn=output,
        inputs=[
            blue_is_t1,
            blue_top_champion,
            blue_jungle_champion,
            blue_mid_champion,
            blue_bot_champion,
            blue_support_champion,
            blue_region,
            red_is_t1,
            red_top_champion,
            red_jungle_champion,
            red_mid_champion,
            red_bot_champion,
            red_support_champion,
            red_region,
        ],
        outputs=text_output,
    )
    # text_button.click(flip_text, inputs=text_input, outputs=text_output)


demo.title = "Does Faker Win?"
demo.description = "TODO"
if __name__ == "__main__":
    demo.launch()