feat: gamemaster
This commit is contained in:
@@ -7,9 +7,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"galaxy/cronutil"
|
||||
"galaxy/lobby/internal/domain/common"
|
||||
|
||||
cron "github.com/robfig/cron/v3"
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
@@ -213,12 +213,6 @@ type NewGameInput struct {
|
||||
Now time.Time
|
||||
}
|
||||
|
||||
// standardCronParser parses the frozen five-field cron expression grammar
|
||||
// used by turn_schedule.
|
||||
var standardCronParser = cron.NewParser(
|
||||
cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow,
|
||||
)
|
||||
|
||||
// New validates input and returns a draft Game record. Validation errors
|
||||
// are returned verbatim so callers can surface them as invalid_request.
|
||||
func New(input NewGameInput) (Game, error) {
|
||||
@@ -401,7 +395,7 @@ func validateCronExpression(value string) error {
|
||||
if strings.TrimSpace(value) == "" {
|
||||
return fmt.Errorf("turn schedule must not be empty")
|
||||
}
|
||||
if _, err := standardCronParser.Parse(value); err != nil {
|
||||
if _, err := cronutil.Parse(value); err != nil {
|
||||
return fmt.Errorf("turn schedule must be a valid five-field cron expression: %w", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user