crib/gamecommand.go

39 lines
706 B
Go
Raw Permalink Normal View History

2020-08-16 23:30:47 +00:00
package main
import "fmt"
2020-10-04 04:26:32 +00:00
// Game commands
const (
CommandEnd = -1
CommandRaw = 0
CommandContinue = 1
CommandThrow = 2
CommandCut = 3
CommandMessage = 4
)
2020-08-16 23:30:47 +00:00
2020-10-04 04:26:32 +00:00
type gameCommand struct {
2020-08-16 23:30:47 +00:00
Player int
Command int
Value string
}
2020-10-04 04:26:32 +00:00
func (gc gameCommand) ToStr() string {
2020-08-16 23:30:47 +00:00
var commandprinted string
switch gc.Command {
case CommandEnd:
commandprinted = "End"
case CommandRaw:
commandprinted = "Raw"
case CommandContinue:
commandprinted = "Continue"
case CommandCut:
commandprinted = "Cut"
case CommandThrow:
commandprinted = "Throw"
2020-08-20 00:05:17 +00:00
case CommandMessage:
commandprinted = "Message"
2020-08-16 23:30:47 +00:00
}
return fmt.Sprintf("Player %d - %s - %s", gc.Player, commandprinted, gc.Value)
}