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

feat: display computer moves #78

Merged
merged 5 commits into from
Apr 24, 2022
Merged

feat: display computer moves #78

merged 5 commits into from
Apr 24, 2022

Conversation

adam-narozniak
Copy link
Collaborator

@adam-narozniak adam-narozniak commented Apr 24, 2022

Images were changed to buttons not accessible to a user
Also, hotfix to determineResults function to correctly display result.
image

@adam-narozniak adam-narozniak linked an issue Apr 24, 2022 that may be closed by this pull request
Images were changed to buttons not accessible to user
Also hotfix to determineResults function to correctly display winner.
Comment on lines 47 to 56
when (hand) {
Hand.ROCK -> {
binding.rockRBOpponent.isChecked = true
}
Hand.PAPER -> {
binding.paperRBOpponent.isChecked = true
}
else -> {
binding.scissorsRB.isChecked = true
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be exhaustive and not use else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, you're right. I've changed it now.

val secondBestPoints = scores[1].points
if (bestPoints > secondBestPoints) {
val bestScoreList = mutableListOf<Round.Score>()
for (score in scores){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use a filter method to follow a more Kotlin-functional style?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've changed it now.

Copy link
Collaborator

@leonardopennino leonardopennino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't agree with some design choice and I think that providing more abstraction would be better, for example:

    var gameService: OfflineGameService? = null
     var currentUserResult: Hand.Result? = null
     var computerPlayer: ComputerPlayer? = null

Why use hardcoded offline game service and not a general interface which could be both a offlinegameservice and an online one? Same discussion for computerplayer which might just be a Player (which internally can be extended with a computer player).
Other than that everything looks ok.

@panadax
Copy link
Collaborator

panadax commented Apr 24, 2022

I checked out your branch and I found a small issue. When I finished the game and then showed the results, I think it could be better to go back to the main page when I click the "back" button. For now, when I click back, it shows the last round and I can even click to play the game, but what's strange is that the computer moves on the user side.

@adam-narozniak
Copy link
Collaborator Author

@leonardopennino you're right. I've changed the gameService to the general one. As it's not critical I'll refactor the ComputerPlayer to inherit/implement the same things as User during the next sprint.

@adam-narozniak
Copy link
Collaborator Author

@panadax Thanks, I'll change it to go back to the main page for now. Later I think there should be a new fragment and buttons "play again" and "end".

After game over there is automatic transition to the main screen.
@adam-narozniak adam-narozniak added the Waiting for review This PR is waiting for review. label Apr 24, 2022
@gaetschwartz
Copy link
Collaborator

I think we should change the buttons. I'm personnally really not a big fan of the current ones. Maybe just using emojis could look better ?

@adam-narozniak
Copy link
Collaborator Author

Sure we can do that but I don't think that it should be done in this PR. A new issue , sth like buttons customization is needed, and there the same way a user can change the mode it will be able to change the style of buttons.

Comment on lines 76 to 78
delay(1000L)
resultNavigationCallback()
delay(1000L)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these delays for. You shouldn't add delays in the logic for no reason. Especially if it's to address a race condition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delays are to let users notice the steps in the game. Otherwise, the transition would be too fast to spot.
For example, a change from the result(win/draw/loss) fragment back to the main screen has a break in between (for a user to notice the effect). In the same way, there's a break between an opponent's move and a transition to the result(win/draw/loss) page (so that they know what another player's choice was).
I hope it clarifies.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, make sure to comment to explain when you add delay, as it's very unusual so it has to be justified.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've added comments.

@gaetschwartz
Copy link
Collaborator

164971834-1ef091aa-429c-4076-b914-834f58cab31e
The text is cut off here, that should be fixed.

@adam-narozniak
Copy link
Collaborator Author

adam-narozniak commented Apr 24, 2022

Yes, it is for a long time. Still, it's not this PR purpose for that. Also at the bottom, the buttons are cut.

Copy link
Collaborator

@gaetschwartz gaetschwartz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although the UI should be fixed this sprint imo.

@gaetschwartz
Copy link
Collaborator

c.f #79

@adam-narozniak
Copy link
Collaborator Author

Sure, I can work on that but in the next sprint. And it's because we work according to the scrum workflow. So, in such a case like that, if there's a bug that is not critical (and the time spent fixing it might take long), you should put it on the backlog and then decide whether to work on that according to the priorities during the next sprint planning. Also, I've already worked the required by course time for this week's sprint.

@adam-narozniak adam-narozniak merged commit 1fae130 into main Apr 24, 2022
@adam-narozniak adam-narozniak deleted the feat/computer-moves branch April 24, 2022 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting for review This PR is waiting for review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reflect - display the computer game choice in a game.
4 participants