-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
61 lines (53 loc) · 1.75 KB
/
game.py
File metadata and controls
61 lines (53 loc) · 1.75 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
###################################################################
# FILE: game.py
# WRITER: Daniel Sinai
# DESCRIPTION: This program implements the Game class
###################################################################
import boggle_board_randomizer as bbr
from board import Board
class Game:
"""
This class manages the logical part of the game
"""
SCORE_POWER = 2
def __init__(self):
"""
This function initializes a new instance
"""
self.__game_board = self.create_board()
self.__words_list = self.__game_board.get_words_list()
self.__words_found = []
self.__path = []
def create_board(self):
"""
This function creates a new game board
:return: Board object
"""
game_board = Board(bbr.BOARD_SIZE)
game_board.init_board(bbr.randomize_board())
return game_board
def get_board_object(self):
"""
This function returns the current game board
:return: Board object
"""
return self.__game_board
def get_board_values(self):
"""
This function returns the game board values
:return: List of strings with the board values
"""
return self.__game_board.get_board_values()
def get_board_as_list(self):
"""
This function returns the game board as list of lists
:return: List of lists - game board
"""
return self.__game_board.get_board()
def calculate_word_score(self, path):
"""
This function calculates the score for the word founded
:param path: List of tuples - letters locations on the board
:return: Integer - score
"""
return (len(path)) ** self.SCORE_POWER