fixed placing monsters and boxes on the same cell (no longer possible)
This commit is contained in:
parent
1acb7d42d7
commit
2c1097d6a9
@ -69,6 +69,7 @@ class Creature(Agent):
|
||||
damage = attackValue - defenseValue
|
||||
if (damage > 0) and (damage + self.weapon1.damage - opponent.armor.mag_protection > 0):
|
||||
opponent.health = opponent.health - (damage + self.weapon1.damage - opponent.armor.mag_protection)
|
||||
|
||||
def defaultAttack(self,opponent):
|
||||
if self.weapon1.type == "Meele":
|
||||
self.meleeAttack(opponent)
|
||||
|
21
model.py
21
model.py
@ -9,12 +9,12 @@ import random
|
||||
x = 10
|
||||
y = 10
|
||||
step_counter = 0
|
||||
boxes_number = 5
|
||||
creatures_number = 5
|
||||
boxes_number = 10
|
||||
creatures_number = 10
|
||||
|
||||
|
||||
class GameMap(Model):
|
||||
def __init__(self, x, y, boxes_number):
|
||||
def __init__(self, x, y):
|
||||
self.grid = MultiGrid(x, y, False)
|
||||
self.schedule = RandomActivation(self) # agenci losowo po kolei wykonują swoje akcje
|
||||
# to jest potrzebne przy założeniu, że potwory chodzą?
|
||||
@ -30,23 +30,24 @@ class GameMap(Model):
|
||||
|
||||
for i in range(self.boxes_number):
|
||||
box = Box(i, self)
|
||||
self.schedule.add(box)
|
||||
#self.schedule.add(box)
|
||||
x = self.random.randrange(self.grid.width)
|
||||
y = self.random.randrange(self.grid.height)
|
||||
try:
|
||||
if self.grid.is_cell_empty((x, y)):
|
||||
self.grid.place_agent(box, (x, y))
|
||||
except:
|
||||
self.schedule.add(box)
|
||||
else:
|
||||
pass
|
||||
|
||||
for i in range(self.boxes_number, self.boxes_number+self.creatures_number): #taki range, żeby każdy agent miał poprawne unique_id
|
||||
#creature = Creature(i, self)
|
||||
creature = Creature(i, self, "Goblin", 0, 0, 0, 1, 1, WM2,A2, dice(6))
|
||||
self.schedule.add(creature)
|
||||
creature = Creature(i, self, "Goblin", 1, 1, 1, 1, 1, WM2,A2, dice(6))
|
||||
x = self.random.randrange(self.grid.width)
|
||||
y = self.random.randrange(self.grid.height)
|
||||
try:
|
||||
if self.grid.is_cell_empty((x, y)):
|
||||
self.grid.place_agent(creature, (x, y))
|
||||
except:
|
||||
self.schedule.add(creature)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user