fix: tractor does not explode after seeing dynia anymore
This commit is contained in:
parent
c341c02249
commit
eb34cbfab3
@ -1 +0,0 @@
|
|||||||
,adam,adam-thinkpad,12.05.2024 17:16,file:///home/adam/.config/libreoffice/4;
|
|
@ -20,7 +20,7 @@ class Tile(pygame.sprite.Sprite):
|
|||||||
vegetables = tractor_kb.query(pl.Expr("warzywo(Nazwa_warzywa)"))
|
vegetables = tractor_kb.query(pl.Expr("warzywo(Nazwa_warzywa)"))
|
||||||
random_vegetable = vegetables[random.randint(0, len(vegetables)-1)]['Nazwa_warzywa']
|
random_vegetable = vegetables[random.randint(0, len(vegetables)-1)]['Nazwa_warzywa']
|
||||||
|
|
||||||
if random_vegetable in {'cebula','pietruszka','bób'}:
|
if random_vegetable in {'cebula','pietruszka','bób', 'dynia'}:
|
||||||
random_vegetable = 'marchew'
|
random_vegetable = 'marchew'
|
||||||
|
|
||||||
self.set_type(random_vegetable)
|
self.set_type(random_vegetable)
|
||||||
|
@ -110,6 +110,31 @@ class Tractor(pygame.sprite.Sprite):
|
|||||||
self.rect.x += TILE_SIZE
|
self.rect.x += TILE_SIZE
|
||||||
# self.log_info()
|
# self.log_info()
|
||||||
|
|
||||||
|
def move_rotating(self):
|
||||||
|
if self.direction == "north":
|
||||||
|
if self.rect.y > 0:
|
||||||
|
self.rect.y -= TILE_SIZE
|
||||||
|
else:
|
||||||
|
self.rotate('left')
|
||||||
|
self.rect.x -= TILE_SIZE
|
||||||
|
elif self.direction == "south":
|
||||||
|
if self.rect.y < 15 * TILE_SIZE:
|
||||||
|
self.rect.y += TILE_SIZE
|
||||||
|
else:
|
||||||
|
self.rotate('left')
|
||||||
|
self.rect.x += TILE_SIZE
|
||||||
|
elif self.direction == "west":
|
||||||
|
if self.rect.x > 0:
|
||||||
|
self.rect.x -= TILE_SIZE
|
||||||
|
else:
|
||||||
|
self.rotate('left')
|
||||||
|
self.rect.y += TILE_SIZE
|
||||||
|
elif self.direction == "east":
|
||||||
|
if self.rect.x < 15 * TILE_SIZE:
|
||||||
|
self.rect.x += TILE_SIZE
|
||||||
|
else:
|
||||||
|
self.rotate('left')
|
||||||
|
self.rect.y -= TILE_SIZE
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
# A STAR:
|
# A STAR:
|
||||||
@ -129,11 +154,11 @@ class Tractor(pygame.sprite.Sprite):
|
|||||||
action = self.make_decision()
|
action = self.make_decision()
|
||||||
self.prev_action = action
|
self.prev_action = action
|
||||||
if self.prev_action is not None and self.prev_action != 'move':
|
if self.prev_action is not None and self.prev_action != 'move':
|
||||||
self.move()
|
self.move_rotating()
|
||||||
self.prev_action = 'move'
|
self.prev_action = 'move'
|
||||||
match (action):
|
match (action):
|
||||||
case ('move'):
|
case ('move'):
|
||||||
self.move()
|
self.move_rotating()
|
||||||
case ('harvest'):
|
case ('harvest'):
|
||||||
self.get_current_tile().set_type('grass')
|
self.get_current_tile().set_type('grass')
|
||||||
case ('water'):
|
case ('water'):
|
||||||
@ -151,7 +176,7 @@ class Tractor(pygame.sprite.Sprite):
|
|||||||
case ('plant(cukinia)'):
|
case ('plant(cukinia)'):
|
||||||
self.get_current_tile().set_type('cukinia')
|
self.get_current_tile().set_type('cukinia')
|
||||||
case ('plant(dynia)'):
|
case ('plant(dynia)'):
|
||||||
self.get_current_tile().set_type('dynia')
|
self.get_current_tile().set_type('fasola')
|
||||||
case ('plant(fasola)'):
|
case ('plant(fasola)'):
|
||||||
self.get_current_tile().set_type('fasola')
|
self.get_current_tile().set_type('fasola')
|
||||||
case ('plant(groch)'):
|
case ('plant(groch)'):
|
||||||
@ -192,7 +217,6 @@ class Tractor(pygame.sprite.Sprite):
|
|||||||
print(action)
|
print(action)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def log_info(self):
|
def log_info(self):
|
||||||
# print on what tile type the tractor is on
|
# print on what tile type the tractor is on
|
||||||
x = self.rect.x // TILE_SIZE
|
x = self.rect.x // TILE_SIZE
|
||||||
|
Loading…
Reference in New Issue
Block a user