Spaces:
Sleeping
Sleeping
Commit
·
62a652e
1
Parent(s):
23f6bcb
refactor: move PlayerActivity auxiliary funtion to utils
Browse files- utils/mes_player_acitivity_model.py +20 -0
- utils/utils.py +6 -0
utils/mes_player_acitivity_model.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datetime import datetime
|
2 |
+
|
3 |
+
class PlayerActivity():
|
4 |
+
def __init__() -> None:
|
5 |
+
self.player_backend_user_id = None
|
6 |
+
self.login_timestamp_tw = datetime.now()
|
7 |
+
self.rendered_timestamp_tw = None
|
8 |
+
|
9 |
+
def render_finished(self, player_backend_user_id):
|
10 |
+
self.player_backend_user_id = player_backend_user_id
|
11 |
+
self.rendered_timestamp_tw = datetime.now()
|
12 |
+
|
13 |
+
def to_dict(self):
|
14 |
+
return {
|
15 |
+
'player_backend_user_id': self.player_backend_user_id,
|
16 |
+
'login_timestamp_tw': self.login_timestamp_tw,
|
17 |
+
'rendered_timestamp_tw': self.rendered_timestamp_tw
|
18 |
+
}
|
19 |
+
|
20 |
+
|
utils/utils.py
CHANGED
@@ -211,3 +211,9 @@ def render_player_data(player_info: gr.State):
|
|
211 |
player_achievements,
|
212 |
current_story,
|
213 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
player_achievements,
|
212 |
current_story,
|
213 |
)
|
214 |
+
|
215 |
+
def render_finished(player_activity, *args):
|
216 |
+
return player_activity.render_finished(*args)
|
217 |
+
|
218 |
+
def format_input(player_activity):
|
219 |
+
return player_activity.to_dict()
|