Add new arg "delay" to delay board updates by x milliseconds (#48)

Co-authored-by: Brad Van Vugt <1531419+bvanvugt@users.noreply.github.com>
This commit is contained in:
Luke Mitchell 2021-07-04 13:48:56 -07:00 committed by GitHub
parent d42f5f46cc
commit 97fbcb3376
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -100,6 +100,7 @@ var Sequential bool
var GameType string
var ViewMap bool
var Seed int64
var TurnDelay int32
var playCmd = &cobra.Command{
Use: "play",
@ -121,6 +122,7 @@ func init() {
playCmd.Flags().StringVarP(&GameType, "gametype", "g", "standard", "Type of Game Rules")
playCmd.Flags().BoolVarP(&ViewMap, "viewmap", "v", false, "View the Map Each Turn")
playCmd.Flags().Int64VarP(&Seed, "seed", "r", time.Now().UTC().UnixNano(), "Random Seed")
playCmd.Flags().Int32VarP(&TurnDelay, "delay", "d", 0, "Turn Delay in Milliseconds")
}
var run = func(cmd *cobra.Command, args []string) {
@ -156,6 +158,10 @@ var run = func(cmd *cobra.Command, args []string) {
} else {
log.Printf("[%v]: State: %v OutOfBounds: %v\n", Turn, state, outOfBounds)
}
if TurnDelay > 0 {
time.Sleep(time.Duration(TurnDelay) * time.Millisecond)
}
}
if GameType == "solo" {