-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
61 lines (46 loc) · 1.38 KB
/
game.py
File metadata and controls
61 lines (46 loc) · 1.38 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
"""
This module defines class 'Game'
which represents a hole multiplayer game.
It contains following properties
1. number of rounds to win
2. list of players
3. number of players
4. sequence of players
"""
_sets_to_win = 4
_player_list = []
_player_seq = {}
class Game:
def __init__(self,
sets_to_win=_sets_to_win,
player_list=None,
player_seq=None):
if player_seq is None:
player_seq = _player_seq
if player_list is None:
player_list = _player_list
self.sets_to_win = sets_to_win
self.player_list = player_list
self.player_num = len(player_list)
self.player_seq = player_seq
def set_rtw(self, round_to_win):
"""
Reset sets to win for one game
:param round_to_win: A signed number
"""
self.sets_to_win = round_to_win
def set_pl(self, player_list):
"""
Reset player list for one game
:param player_list: List, consists players
:return:
"""
self.player_list = player_list
self.player_num = len(player_list)
def set_ps(self, player_seq):
"""
Reset player sequence for one game
:param player_seq: Dict, key in range(1, plyer_num + 1), value as player's ID
:return:
"""
self.player_seq = player_seq