-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempfile_1755683775906.py
More file actions
62 lines (49 loc) · 1.19 KB
/
Copy pathtempfile_1755683775906.py
File metadata and controls
62 lines (49 loc) · 1.19 KB
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
import asyncio
from GameServer import Card, Event
# 全局状态变量
subscribers = [] # 订阅者列表
event = None
gameInfo = None
choice = None
choose = False
actions = []
# 异步等待相关
_choice_future = None
def set_event(new_event: Event):
global event
event = new_event
def set_game_info(new_game_info):
global gameInfo
gameInfo = new_game_info
def set_choice(new_choice):
global choice
choice = new_choice
def set_choose_state(state: bool):
global choose
choose = state
def get_choose_state():
global choose
return choose
def reset_actions():
global actions
actions.clear()
def add_action(action):
global actions
actions.append(action)
def get_actions():
global actions
return actions
def create_choice_future():
global _choice_future
_choice_future = asyncio.Future()
return _choice_future
def set_choice_result(result):
global _choice_future, choice
if _choice_future and not _choice_future.done():
_choice_future.set_result(result)
choice = result
async def wait_for_choose():
"""等待选择完成"""
future = create_choice_future()
result = await future
return result