-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add resign button. #309
base: master
Are you sure you want to change the base?
Add resign button. #309
Conversation
game/match/match.go
Outdated
|
||
func (m *Match) handleMesseges(message string) { | ||
|
||
currentPlayer := m.CurrentPlayer().Player |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this make it so you can win by typing /quit during the opponent's turn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oversight.
game/match/match.go
Outdated
|
||
switch msgParts[0] { | ||
case "/quit": | ||
m.End(m.Opponent(currentPlayer), fmt.Sprintf("%s won by opponent resigning.", m.Opponent(currentPlayer).Username())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since incoming chat events are of ParallelEvent type they will be handled in a separate non-blocking goroutine than the match logic itself which might cause some panics during runtime as it can dispose of the match and players (which closes channels and nils most slices and pointers) at the same time as some match logic is executed which is trying to use those references
Maybe a separate Forfeit event of SequentialEvent type could be created and sent by the client, or some other way to make sure the m.End call is called from inside the blocking eventloop queue
Also fix Shtra chat message and Star-Cry Dragon