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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/usr/bin/env python
from User import User
from computer import Computer
from elements import *
import constants
import utility
import random
class Game:
def __init__(self):
self.board = Board()
self.bag = Bag()
self.dict = utility.get_dictionary()
self.user = User(self.bag)
self.computer = Computer(self.bag)
self.moves_log = []
def get_user_letters(self):
''' Return the list of user's Letters
@return: the list of user's Letters.
'''
return self.user.get_letters()
def get_computer_letters(self):
''' Return the list of computer's Letters
@return: the list of computer's Letters.
'''
return self.computer.get_letters()
def get_user(self):
return self.user
def get_computer(self):
return self.computer
def computer_make_move(self):
return self.computer.make_move(self.board,
self.dict,
self.moves_log)
def get_user_char_letters(self):
''' Return the list of user's letters, only the character
atribute of the Letter object.
@return: the list of user's letters.
'''
list = []
l = self.user.get_letters()
for e in l:
list.append(e.get_character())
return list
def get_computer_char_letters(self):
''' Return the list of user's letters, only the character
atribute of the Letter object.
@return: the list of user's letters.
'''
list = []
l = self.computer.get_letters()
for e in l:
list.append(e.get_character())
return list
def user_swap_letters(self, letters):
''' Return the given list of Letters to the bag, and take
the same amount of letters from the bag.
@param letters: the list of letters to put back.
@return: True if it is possible, otherwise False.
'''
res = self.user.swap_letters(self.bag, letters)
return res
def computer_swap_letters(self):
''' Return the an amount of Letters to the bag, and take
the same amount of letters from the bag.
@return: True if it is possible, otherwise False.
'''
amount = random.randint(1, 7)
res = self.computer.swap_letters(self.bag, amount)
return res
|