Вы сравниваете значения только один раз перед тем, как запустить l oop. Вы должны сравнивать значения на каждой итерации после выбора команды.
while start == 'yes':
command = input('').lower()
if command == 'w':
mario.x_location += 1
print(mario.x_location, mario.y_location, mario.z_location)
elif command == 's':
mario.x_location -= 1
print(mario.x_location, mario.y_location, mario.z_location)
elif command == 'a':
mario.z_location -= 1
print(mario.x_location, mario.y_location, mario.z_location)
elif command == 'd':
mario.z_location += 1
print(mario.x_location, mario.y_location, mario.z_location)
rules = [mario.x_location == coin.x,
mario.y_location == coin.y,
mario.z_location == coin.z]
if all(rules):
if mario.health == 3:
print('you collected a coin')
print('health: ', mario.health)
elif mario.health < 3:
print('You collected a coin and healed')
mario.health += 1
print('Health: ', mario.health)
Пример выполнения:
say yes: yes
w
1 0 0
a
1 0 -1
d
1 0 0
d
1 0 1
you collected a coin
health: 3