From 3a71ba912a97701cbc92672efb16a8e773a1c5e8 Mon Sep 17 00:00:00 2001 From: Felipe M Date: Wed, 13 Mar 2024 18:42:39 +0100 Subject: [PATCH] models --- go.mod | 2 ++ go.sum | 2 ++ internal/models/models.go | 74 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 go.sum create mode 100644 internal/models/models.go diff --git a/go.mod b/go.mod index bd40c16..74afe0f 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module code.fmartingr.dev/fmartingr/ichi go 1.19 + +require github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3dfe1c9 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/internal/models/models.go b/internal/models/models.go new file mode 100644 index 0000000..1e958f9 --- /dev/null +++ b/internal/models/models.go @@ -0,0 +1,74 @@ +package models + +import ( + "container/list" + + "github.com/google/uuid" +) + +const MaxPlayers = 4 + +type ID uuid.UUID +type PlayerPhase int +type CardNumber int +type CardColor int +type CardSpecial int + +const ( + PlayerPhaseWaiting = iota + PlayerPhaseTurn + PlayerPhaseDraw + PlayerPhasePlay + PlayerPhaseIchi + PlayerPhasePass +) + +const ( + CardColorRed = iota + CardColorBlue + CardColorGreen + CardColorYellow +) + +const ( + CardSpecialPlus2 = iota + CardSpecialPlus4 + CardSpecialReverseTurn + CardSpecialColorChange + CardSpecialSkipTurn +) + +type Card struct { + Color CardColor + Number CardNumber + Special CardSpecial +} + +type Player struct { + ID ID + Name string + State *PlayerState + Cards map[ID]*Card +} + +type Game struct { + ID ID + MaxPlayers int + Players map[ID]*Player + Cards list.List + Stage GameStage + History list.List +} + +type GameHistory struct { + Player *Player + Card *Card + Action interface{} +} + +type GameStage struct { +} + +type PlayerState struct { + Phase PlayerPhase +}