Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secret passageway bug #3

Closed
dragon-fire-fly opened this issue Oct 21, 2022 · 1 comment
Closed

Secret passageway bug #3

dragon-fire-fly opened this issue Oct 21, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dragon-fire-fly
Copy link
Owner

The check_for_secret_passageway() function is correctly returning the linked rooms, if present.

The dictionary is updating to show the secret passageway room is 0 spaces (use secret passageway), but when trying to move there, it takes the original number of steps, rather than 0, so may say you have not rolled enough.

secret_passageway_bug

The console is printing:

========================================
The rooms are the following distances: 
1- Kitchen: 0 space(s) (stay in room)
2- Ball Room: 3 space(s)
3- Conservatory: 6 space(s)
4- Billiard Room: 8 space(s)
5- Dining Room: 3 space(s)
6- Library: 10 space(s)
7- Lounge: 6 space(s)
8- Main Hall: 9 space(s)
9- Study: 0 space(s) (Use secret passageway)
Which room would you like to move towards?: 9
{'Kitchen': '0', 'Ball Room': '3', 'Conservatory': '6', 'Billiard Room': '8', 'Dining Room': '3',
 'Library': '10', 'Lounge': '6', 'Main Hall': '9', 'Study': '12'}
You have not rolled enough to reach the Study.
1. Move 3 spaces towards the Study
2. Stay at current location

The suspected offending code is:

room_distances = gameboard.room_distances()
print(f"Not updated from gameboard.room_distances: {room_distances}")

# move towards the desired room
new_player_location = player.move_player(player_location, desired_room, current_room, 
turn_die_roll, room_distances, ROOM_LOCATIONS)
gameboard.update_player_location([new_player_location])
@dragon-fire-fly dragon-fire-fly self-assigned this Oct 21, 2022
@dragon-fire-fly dragon-fire-fly added the bug Something isn't working label Oct 21, 2022
@dragon-fire-fly
Copy link
Owner Author

dragon-fire-fly commented Oct 30, 2022

This bug was caused by the gameboard.choose_room() function returning the name of the desired room, but not updating the room_distances dictionary.

This bug was fixed by returning both the desired room and the updated room_distances dictionary from gameboard.choose_room() function, and using tuple unpacking to access the variables.

The updated dictionary was then passed as an argument into player.move_player(), rather than using the original dictionary from before it checked for secret passageways.

The new code is as follows:

desired_room, room_distances = gameboard.choose_room()

    # move towards the desired room
    new_player_location = player.move_player(
        player_location,
        desired_room,
        current_room,
        turn_die_roll,
        room_distances,
        ROOM_LOCATIONS,
    )
    gameboard.update_player_location(new_player_location) 

The room distances before and after this change are shown below:

updated_room_distances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant