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

Add resign button. #309

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jyotiskaghosh
Copy link
Contributor

@jyotiskaghosh jyotiskaghosh commented Dec 17, 2024

Also fix Shtra chat message and Star-Cry Dragon


func (m *Match) handleMesseges(message string) {

currentPlayer := m.CurrentPlayer().Player
Copy link
Owner

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oversight.


switch msgParts[0] {
case "/quit":
m.End(m.Opponent(currentPlayer), fmt.Sprintf("%s won by opponent resigning.", m.Opponent(currentPlayer).Username()))
Copy link
Owner

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

@jyotiskaghosh jyotiskaghosh changed the title Add "/quit" chat command Add resign button. Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants