Skip to content
New issue

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

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

Already on GitHub? # to your account

cd force flag now calls visit to reset character when cd'ing to home #128

Merged
merged 7 commits into from
Sep 24, 2021

Conversation

zoomiti
Copy link
Contributor

@zoomiti zoomiti commented Sep 24, 2021

This pull request resolves #123, by instead of hard coding the changing of the location in change_dir(), offloading this to the visit() method in game.rs.

@facundoolano
Copy link
Owner

facundoolano commented Sep 24, 2021

Change the code a bit to make it more obvious (haven't tested it). Do you mind adding a test case that checks the character is healed when cd -f to home?

@zoomiti
Copy link
Contributor Author

zoomiti commented Sep 24, 2021

I'll add the test but I think your change doesn't compile because game.visit doesn't take a reference.

$ cargo b
   Compiling rpg-cli v1.0.0 (~/rpg-cli)
error[E0308]: mismatched types
   --> src/command.rs:118:20
    |
118 |         game.visit(&dest)
    |                    ^^^^^
    |                    |
    |                    expected struct `location::Location`, found `&location::Location`
    |                    help: consider removing the borrow: `dest`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `rpg-cli` due to previous error

@facundoolano
Copy link
Owner

True, coding from the browser 😬

@zoomiti
Copy link
Contributor Author

zoomiti commented Sep 24, 2021

Looks like some whitespace made it fail the tests. I'll fix it later when I get a chance to write the test.

@facundoolano
Copy link
Owner

thanks!

@zoomiti
Copy link
Contributor Author

zoomiti commented Sep 24, 2021

Should be fixed now, I made sure to check the white space of the new test too.

@facundoolano facundoolano merged commit 7dd7c4b into facundoolano:main Sep 24, 2021
@facundoolano
Copy link
Owner

thanks!

@zoomiti
Copy link
Contributor Author

zoomiti commented Sep 24, 2021

Glad I could help! It helped me learn rust so thanks for letting me contribute!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Going to $HOME with --force flag doesn't reset character stats or apply ring/status effects
2 participants