root/src/gameData.py @ 302

Revision 302, 2.9 KB (checked in by ecoughlan, 2 years ago)

More updates

Line 
1'''
2Created on Mar 24, 2012
3
4@author: Michael
5'''
6
7import copy
8from globals import *
9
10
11class GameData:
12    '''
13        holds all of the game data for our game.
14    '''
15
16    def __init__(self, state):
17        '''
18            initializes based on a given state.
19        '''
20        self.oldState = copy.deepcopy(state)
21        self.currentState = state
22
23    def endTurn(self):
24        '''
25            ends the turn, updating states as necessary.
26
27            input type: none
28            return type: none
29        '''
30        change = self.oldState.calcTurnChange()
31        self.currentState.updateSpec(change)
32        self.currentState.endTurn()
33        self.oldState = copy.deepcopy(self.currentState)
34
35    def getMoney(self):
36        """
37            gets the current level of money.
38
39            input type: none
40            return type: int
41        """
42        return self.currentState.getMoney()
43
44    def undoTurn(self):
45        """
46            undoes all buildings and actions for this turn.
47
48            input type: none
49            return type: none
50        """
51        self.currentState = copy.deepcopy(self.oldState)
52
53    def deleteBuilding(self, blockNumber, indexNumber):
54        """
55            deletes the selected building from the map.
56
57            input type: blockNumber(int), indexNumber(int)
58            return type: none
59        """
60        self.currentState.deleteBuilding(blockNumber, indexNumber)
61
62    def getBlockBuildings(self, blockNumber):
63        """
64            returns the images associated with the buildings that exist in the
65            designated block.
66
67            input type: blockNumber(int)
68            return type: none
69        """
70        return self.currentState.getBlockBuildings(blockNumber)
71
72    def blockHasSpace(self, blockNumber):
73        """
74            returns whether the designated block has space for more buildings.
75
76            input type: blockNumber(int)
77            return type: boolean
78        """
79        return self.currentState.blockHasSpace(blockNumber)
80
81    def build(self, building, blockNumber):
82        """
83            builds the building. Assumes there are enough stats and space on
84            the designated block.
85
86            input type: building(str), blockNumber(int)
87            return type: none
88        """
89        self.currentState.addBuilding(building, blockNumber)
90
91    def research(self, researchType, value):
92        """
93            adds research to the designated type.
94
95            input type: type(int), value(int)
96            return type: none
97        """
98        self.currentState.research(researchType, value)
99
100    def getSpec(self):
101        """
102            returns the spec containing values of current resources.
103
104            input type: none
105            return type: spec
106        """
107        return self.currentState.getSpec()
Note: See TracBrowser for help on using the browser.