mayankkejriwal/GNOME-p3

def _has_player_passed_go in card_utilities_actions is wrong?

Opened this issue · 1 comments

The function seems wrong, cannot check many situations

def _has_player_passed_go(current_position, new_position, go_position, rel_move):
"""
Function to determine whether the player passes, or is on, Go if the player moves from current position to new position.
:param current_position: An integer. Specifies the position from which the player is moving.
:param new_position: An integer. Specifies the position to which the player is moving.
:param go_position: An integer. Specifies the go position. In the default board, it is just set to 0.
:return: A boolean. True if the player is on, or has passed, go, and False otherwise.
"""
print('current_position, new_position, go_position', current_position, new_position, go_position, rel_move)
if new_position == go_position: # we've landed on go
return True

elif new_position == current_position and rel_move != 0:  # we've gone all round the board
    return True

elif current_position < new_position and rel_move < 0: # go forward but before passing go
        return True

elif current_position > new_position and rel_move > 0:
    return True

elif abs(rel_move) >= 40: #go over one round
    return True

return False # we've exhausted the possibilities. If it reaches here, we haven't passed go.