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

Added server side grace period support. #174

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

Added server side grace period support. #174

wants to merge 8 commits into from

Conversation

zond
Copy link
Owner

@zond zond commented Sep 15, 2021

  • Added two fields to Game: GracePeriodMinutes and GracePeriodsPerPlayer.
  • Added one field to GameMember: GracePeriodsUsed.
  • Added one field to PhaseMeta (present both anonymously in Phase and as Game.NewestPhaseMeta): GraceUsed.
  • Made phase resolution check grace period settings, and if GracePeriodMinutes > 0, GracePeriodsPerPlayer > 0, latest phase !GraceUsed, and at least one player with no orders, and not ready to resolve has GracePeriodsUsed < GracePeriodsPerPlayer they will have their GracePeriodsUsed bumped, the current phase will have GraceUsed set to true, be postponed, and the late players will be named and shamed in a message to the conference channel.

@JorenC, @tttppp, @johnpooch PTAL

@zond zond requested a review from tttppp September 15, 2021 19:29
@zond
Copy link
Owner Author

zond commented Sep 15, 2021

Also, this is not yet tested - I wanted to get a sanity check by visual inspection first.

p.Phase.Host,
); err != nil {
log.Errorf(p.Context, "AsyncSendMsgFunc(..., %v, %v, %+v, %q, %q): %v; fix it?", p.Phase.GameID, DiplicitySender, p.Variant.Nations, notificationBody, p.Phase.Host, err)
return false, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not super keen on these error conditions returning false. The grace period has been used up and the deadline has been postponed, so I think this should return true, even though the messages weren't sent.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Go custom is that if the error is non-nil, then everything else should be ignored. The "false" is just because we need something to return, and false is the default boolean value.

Also - the error will cause the wrapping transaction to roll back, and thus no grace period will actually be used.

@tttppp
Copy link
Collaborator

tttppp commented Sep 15, 2021

The logic looks right to me. This will allow a player to use all their grace periods on the same phase, but I think that's ok.

game/phase.go Outdated
allMembers = append(allMembers, string(nat))
}
notificationBody := fmt.Sprintf(
"%v weren't ready to resolve and gave no orders, since they still have grace periods phase resolution has been postponed %v (until %v).",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The English will still be a little off here for a single nation: "England weren't ready"

Copy link
Contributor

@JorenC JorenC Sep 15, 2021

Choose a reason for hiding this comment

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

%v missed the last deadline. They are using one of their grace periods of %v. The new deadline for this phase will be %v.

Copy link
Contributor

@JorenC JorenC Sep 15, 2021

Choose a reason for hiding this comment

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

I think that sounds better and explains it a bit clearer. It also works for all nations/variants.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Problem is that multiple users will be using their grace periods. How would you phrase that?

Copy link
Owner Author

Choose a reason for hiding this comment

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

@tttppp I changed the pluralization to be correct.

@JorenC
Copy link
Contributor

JorenC commented Sep 15, 2021

We should have a way to know in the client whether we're in a grace period.

I think we keep the current phase, so it would be "Spring 1902 (grace)".
I think we keep the current deadline (it has just been extended), so the deadline is fine.

We do need:

  • A token that we're currently in Grace.
  • A way to know which of the players is in Grace (especially me)

… grace, and preventing grace usage when it is set to true.
@zond
Copy link
Owner Author

zond commented Sep 16, 2021

We should have a way to know in the client whether we're in a grace period.

I added Phase.GraceUsed which will show this.

I think we keep the current phase, so it would be "Spring 1902 (grace)".

I don't understand - when grace period is used the current phase will just be extended.

I think we keep the current deadline (it has just been extended), so the deadline is fine.

Yes, exactly.

We do need:

  • A token that we're currently in Grace.

This is in the PR now.

  • A way to know which of the players is in Grace (especially me)

Why? You are not committed and need to commit, isn't that enough?

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.

3 participants