-
Notifications
You must be signed in to change notification settings - Fork 3
/
players.py
61 lines (44 loc) · 1.73 KB
/
players.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class Player():
"""Player wrapper."""
def __init__(self, sid, hit_id, assignment_id, worker_id, ip):
self.sid = sid
self.ip = ip
self.assignment_id = assignment_id
self.hit_id = hit_id
self.worker_id = worker_id
self.partner = None
self.dialogue_id = None
self.oracle_sid = None
self.questioner_sid = None
self.role = "None"
self.namespace = "None"
def is_oracle(self):
return self.role.find("Oracle") > -1
def is_questioner(self):
return self.role.find("Questioner") > -1
def is_qualified(self):
return not self.namespace.startswith("/q_")
class QualifyOracle(Player):
"""Oracle that needs to qualify."""
def __init__(self, sid, hit_id, assignment_id, worker_id, ip):
Player.__init__(self, sid, hit_id, assignment_id, worker_id, ip)
self.namespace = '/q_oracle'
self.role = 'QualifyOracle'
class Oracle(Player):
"""Oracle."""
def __init__(self, sid, hit_id, assignment_id, worker_id, ip):
Player.__init__(self, sid, hit_id, assignment_id, worker_id, ip)
self.namespace = '/oracle'
self.role = 'Oracle'
class QualifyQuestioner(Player):
"""Questioner that needs to qualify."""
def __init__(self, sid, hit_id, assignment_id, worker_id, ip):
Player.__init__(self, sid, hit_id, assignment_id, worker_id, ip)
self.namespace = '/q_questioner'
self.role = 'QualifyQuestioner'
class Questioner(Player):
"""Questioner. """
def __init__(self, sid, hit_id, assignment_id, worker_id, ip):
Player.__init__(self, sid, hit_id, assignment_id, worker_id, ip)
self.namespace = '/questioner'
self.role = 'Questioner'