#!/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