field cost final
This commit is contained in:
parent
5e4af5773b
commit
8098a258f2
15
Board.py
15
Board.py
@ -11,17 +11,8 @@ def generate():
|
||||
for i in range(0, int(HORIZONTAL_TILES_NUMBER)):
|
||||
board.append([])
|
||||
for j in range(0, int(VERTICAL_TILES_NUMBER)):
|
||||
current_state = random.choice(states)
|
||||
current_cost = getCost(current_state)
|
||||
board[i].append(Field(int(i * TILE_SIZE), int(j * TILE_SIZE), current_state, current_cost))
|
||||
board[i].append(Field(int(i * TILE_SIZE), int(j * TILE_SIZE), random.choice(states)))
|
||||
|
||||
board[0][0] = Field(int(0 * TILE_SIZE), int(0 * TILE_SIZE), "TOOLS_FIELD", cost=0)
|
||||
board[1][0] = Field(int(1 * TILE_SIZE), int(0 * TILE_SIZE), "FUEL_FIELD", cost=0)
|
||||
board[0][0] = Field(int(0 * TILE_SIZE), int(0 * TILE_SIZE), "TOOLS_FIELD")
|
||||
board[1][0] = Field(int(1 * TILE_SIZE), int(0 * TILE_SIZE), "FUEL_FIELD")
|
||||
return board
|
||||
|
||||
def getCost(state):
|
||||
if state == 'toPlow': return 1
|
||||
if state == 'toSeed': return 2
|
||||
if state == 'toFertilize': return 3
|
||||
if state == 'toWater': return 4
|
||||
if state == 'toCut': return 5
|
||||
|
22
Field.py
22
Field.py
@ -1,9 +1,8 @@
|
||||
class Field:
|
||||
def __init__(self, horizontal_index, vertical_index, state, cost):
|
||||
def __init__(self, horizontal_index, vertical_index, state):
|
||||
self.__horizontal_index = horizontal_index
|
||||
self.__vertical_index = vertical_index
|
||||
self.__state = state
|
||||
self.__cost = cost
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@ -11,7 +10,18 @@ class Field:
|
||||
|
||||
@property
|
||||
def cost(self):
|
||||
return self.__cost
|
||||
if self.state == 'toPlow':
|
||||
return 1
|
||||
elif self.state == 'toSeed':
|
||||
return 2
|
||||
elif self.state == 'toFertilize':
|
||||
return 3
|
||||
elif self.state == 'toWater':
|
||||
return 4
|
||||
elif self.state == 'toCut':
|
||||
return 5
|
||||
else:
|
||||
return 0
|
||||
|
||||
@property
|
||||
def horizontal_index(self):
|
||||
@ -26,9 +36,3 @@ class Field:
|
||||
if state == "toPlow" or state == "toWater" or state == "toSeed" or \
|
||||
state == "toFertilize" or state == "toCut" or state == "TOOLS_FIELD" or state == "FUEL_FIELD":
|
||||
self.__state = state
|
||||
|
||||
@cost.setter
|
||||
def cost(self, cost):
|
||||
if cost == 1 or cost == 2 or cost == 3 or \
|
||||
cost == 4 or cost == 5 or cost == 0:
|
||||
self.__cost = cost
|
Loading…
Reference in New Issue
Block a user