forked from ElliotSea/BitcoinHack2019
/
Game.py
67 lines (43 loc) · 1.64 KB
/
Game.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
62
63
64
65
66
67
import pandas as pd
from Bank import Bank
from Player import Player
from Dice import Dice
from Space import Space
import config
class Game:
"""Tracks gameplay"""
def __init__(self):
self.round = 0
self.players = None
self.bank = Bank()
self.board = []
self.dice = Dice()
self.getPlayers(config.num_players)
self.getBoard(config.board_filename)
self.passDice()
def getPlayers(self, num_players):
if (num_players < 2) or (8 < num_players):
raise ValueError('A game must have 2-8 players. You input %d ')
self.players = [Player(p) for p in range(1, num_players + 1)]
self.playersRemain = num_players # wut
def getBoard(self, file):
board_df = pd.read_csv(file)
for _, attributes in board_df.iterrows():
if attributes['class'] == 'Street':
self.board.append(Space.Street(attributes))
if attributes['class'] == 'Utility':
self.board.append(Space.Utility(attributes))
if attributes['class'] == 'Railroad':
self.board.append(Space.Railroad(attributes))
if attributes['class'] == 'Tax':
self.board.append(Space.Tax(attributes))
if attributes['class'] == 'Chance':
self.board.append(Space.Chance())
if attributes['class'] == 'Chest':
self.board.append(Space.Chest())
if attributes['class'] in ['Jail', 'Idle']:
self.board.append([])
def passDice(self):
self.dice = Dice()
def updateRound(self):
self.round += 1