-
Notifications
You must be signed in to change notification settings - Fork 18
/
game_def.py
44 lines (35 loc) · 1.2 KB
/
game_def.py
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
import streamlit as st
###############################################
#
#
# FUNCTIONS DEFINITION
#
#
################################################
# this little function helps us to clear text input by storing variable in temp
# counter +1 is a part of a neat trick to introduce focus on text field (explained further in the code)
def clear(ss_variable):
st.session_state["temp"] = st.session_state[ss_variable]
st.session_state[ss_variable] = ""
st.session_state["counter"] += 1
# before changing scene you have to clear out the temp
def temp_clear():
st.session_state["temp"] = ""
# function restarting session state
# in the future can be used for randomization
def restart_session():
st.session_state["health"] = 100
st.session_state["mana"] = 80
st.session_state["gold"] = 5
st.session_state["place"] = "introScene"
st.session_state["sheep_anger"] = 0
st.session_state["forest_trip"] = 0
st.session_state["sword"] = 0
st.session_state["dragon_alive"] = 1
st.session_state["dragon_hp"] = 20
st.session_state["scenes_counter"] = {
"intro_counter": 0,
"cave_counter": 0,
"trip_counter": 0,
"elf_counter": 0,
}