Python Python Collections Dungeon Game Hit points

Daniel Escobar
Daniel Escobar
2,580 Points

I need help with this Challenge Task

I am not sure what am I doing wrong. I tried so many ways. Can someone help me please.

movement.py
def move(player, direction):

    x, y, hp = player
    x1, y1 = direction


    if x + x1 <= 0:
        x += 1
        hp=- 5
    elif x + x1 >= 9:
        x -=1
        hp=- 5
    elif y + y1 <= 0:
        y += 1
        hp=- 5
    elif y + y1 >= 9:
        y -= 1
        hp=- 5
    else:
        x = x + x1
        y = y + y1

    return x, y, hp

1 Answer

Steven Parker
Steven Parker
168,137 Points

You've got the right idea, but there are a few implementation issues. Here are a few hints:

  • 0 and 9 are part of the grid, so the tests should allow them (just not anything beyond)
  • when a wall would be hit, the x or y should not be changed
  • when reducing hp, the subtracting assignment operator is "-=" (not "=-")