Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -152,6 +152,47 @@ def create_markdown_preview(history_df):
|
|
152 |
markdown += "\n"
|
153 |
return markdown
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
# ๐ฎ Main Game Application
|
156 |
def main():
|
157 |
st.title("๐ฑ Cat Rider ๐")
|
|
|
152 |
markdown += "\n"
|
153 |
return markdown
|
154 |
|
155 |
+
|
156 |
+
# ๐ Update game state with the result of the action
|
157 |
+
def update_game_state(game_state, situation, action, outcome, timestamp):
|
158 |
+
# Generate the encounter conclusion (success or failure)
|
159 |
+
conclusion = generate_encounter_conclusion(situation, action, outcome)
|
160 |
+
|
161 |
+
# Update stats based on the outcome
|
162 |
+
game_state = update_character_stats(game_state, outcome)
|
163 |
+
|
164 |
+
# Create a new record for the history
|
165 |
+
new_record = pd.DataFrame({
|
166 |
+
'user_id': [game_state['user_id']],
|
167 |
+
'timestamp': [timestamp],
|
168 |
+
'situation_id': [situation['id']],
|
169 |
+
'situation_name': [situation['name']],
|
170 |
+
'situation_emoji': [situation['emoji']],
|
171 |
+
'situation_type': [situation['type']],
|
172 |
+
'action_id': [action['id']],
|
173 |
+
'action_name': [action['name']],
|
174 |
+
'action_emoji': [action['emoji']],
|
175 |
+
'action_type': [action['type']],
|
176 |
+
'outcome': [outcome],
|
177 |
+
'conclusion': [conclusion],
|
178 |
+
'gear_strength': [game_state['gear_strength']],
|
179 |
+
'rider_skill': [game_state['rider_skill']],
|
180 |
+
'score': [game_state['score']]
|
181 |
+
})
|
182 |
+
|
183 |
+
# Add the new record to the game history DataFrame
|
184 |
+
game_state['history_df'] = pd.concat([game_state['history_df'], new_record], ignore_index=True)
|
185 |
+
|
186 |
+
# Update the history of actions (tracking how many times each action was used)
|
187 |
+
if action['id'] in game_state['history']:
|
188 |
+
game_state['history'][action['id']] += 1 if outcome else -1
|
189 |
+
else:
|
190 |
+
game_state['history'][action['id']] = 1 if outcome else -1
|
191 |
+
|
192 |
+
return game_state
|
193 |
+
|
194 |
+
|
195 |
+
|
196 |
# ๐ฎ Main Game Application
|
197 |
def main():
|
198 |
st.title("๐ฑ Cat Rider ๐")
|