From a72f4331a052c3e01ee27fc2cb96c9c12fed1651 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 20 Jan 2023 11:14:43 +0100 Subject: reformat using gofmtp --- go/client/main.go | 4 ++-- go/game/card.go | 1 - go/game/permanent.go | 5 +++++ go/game/range_test.go | 32 +++++++++++++++++++++++++------- go/game/tile.go | 3 ++- go/game/unit.go | 3 ++- go/ui/choice.go | 4 ++-- go/webtools/main.go | 2 -- 8 files changed, 38 insertions(+), 16 deletions(-) diff --git a/go/client/main.go b/go/client/main.go index ec8fff5e..13a07d0b 100644 --- a/go/client/main.go +++ b/go/client/main.go @@ -26,8 +26,7 @@ const ( HOVER_THRESHOLD = 60 ) -type HandLayer struct { -} +type HandLayer struct{} func (l *HandLayer) Draw(screen *ebiten.Image) { cardImg := assets.GetCard("base/archer", "en") @@ -56,6 +55,7 @@ func (h *hoverDetector) update(x, y int) { h.reset() } } + func (h *hoverDetector) reset() { h.ticks = 0 if h.resetFunc != nil { diff --git a/go/game/card.go b/go/game/card.go index bfa476a9..9d71cc9c 100644 --- a/go/game/card.go +++ b/go/game/card.go @@ -150,7 +150,6 @@ func (card *Card) getEffects() []string { return enEffects.([]string) } return effects.([]string) - } func NewCard(cardPath string) *Card { diff --git a/go/game/permanent.go b/go/game/permanent.go index 7a9988e1..e90bd833 100644 --- a/go/game/permanent.go +++ b/go/game/permanent.go @@ -40,18 +40,23 @@ func NewPermanentBase(card *Card, tile *Tile, owner *Player) PermanentBase { func (p *PermanentBase) GetCard() *Card { return p.Card } + func (p *PermanentBase) GetTile() *Tile { return p.Tile } + func (p *PermanentBase) GetDamage() int { return p.Damage } + func (p *PermanentBase) GetPile() []Permanent { return p.Pile } + func (p *PermanentBase) GetController() *Player { return p.Controller } + func (p *PermanentBase) GetOwner() *Player { return p.Owner } diff --git a/go/game/range_test.go b/go/game/range_test.go index afa164de..274b3b85 100644 --- a/go/game/range_test.go +++ b/go/game/range_test.go @@ -1,13 +1,14 @@ package game import ( - "golang.org/x/exp/slices" "testing" + + "golang.org/x/exp/slices" ) func TestPositionsInRange(t *testing.T) { origin := Position{0, 0} - positionsInRange1 := []Position{Position{0, 1}, Position{1, 0}, Position{1, 1}} + positionsInRange1 := []Position{{0, 1}, {1, 0}, {1, 1}} calculatedPositions := PositionsInRange(origin, 1, false) if len(positionsInRange1) != len(calculatedPositions) { t.Fatalf("Unexpected number of calculated positions") @@ -20,11 +21,28 @@ func TestPositionsInRange(t *testing.T) { } origin = Position{2, 2} - positionsInRange2 := []Position{Position{0, 1}, Position{0, 2}, Position{0, 3}, - Position{1, 0}, Position{1, 1}, Position{1, 2}, Position{1, 3}, Position{1, 4}, - Position{2, 0}, Position{2, 1}, Position{2, 3}, Position{2, 4}, - Position{3, 0}, Position{3, 1}, Position{3, 2}, Position{3, 3}, Position{3, 4}, - Position{4, 1}, Position{4, 2}, Position{4, 3}} + positionsInRange2 := []Position{ + {0, 1}, + {0, 2}, + {0, 3}, + {1, 0}, + {1, 1}, + {1, 2}, + {1, 3}, + {1, 4}, + {2, 0}, + {2, 1}, + {2, 3}, + {2, 4}, + {3, 0}, + {3, 1}, + {3, 2}, + {3, 3}, + {3, 4}, + {4, 1}, + {4, 2}, + {4, 3}, + } calculatedPositions = PositionsInRange(origin, 2, false) for _, p := range positionsInRange2 { diff --git a/go/game/tile.go b/go/game/tile.go index b8e8c83f..f66b4fb0 100644 --- a/go/game/tile.go +++ b/go/game/tile.go @@ -48,7 +48,8 @@ var TileTypes = struct { House: house, Farm: farm, Street: street, - Spawn: spawn} + Spawn: spawn, +} var TileNames = map[string]TileType{ "neutral": neutral, diff --git a/go/game/unit.go b/go/game/unit.go index b81ea8b3..028ff274 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -2,10 +2,11 @@ package game import ( "fmt" - "golang.org/x/exp/slices" "log" "strconv" "strings" + + "golang.org/x/exp/slices" ) type UnitState int diff --git a/go/ui/choice.go b/go/ui/choice.go index 9e9b7b2f..2020ed0a 100644 --- a/go/ui/choice.go +++ b/go/ui/choice.go @@ -16,8 +16,8 @@ type Choice struct { func choiceButtonOnClickDummy(b *SimpleButton) {} func NewChoice(x, y int, width, choiceHeight int, choices []string, - onClick func(*Choice, int, int)) *Choice { - + onClick func(*Choice, int, int), +) *Choice { c := &Choice{x, y, width, choiceHeight, choices, onClick, []Button{}} for i, choice := range c.choices { diff --git a/go/webtools/main.go b/go/webtools/main.go index 03fc9e37..4d03c770 100644 --- a/go/webtools/main.go +++ b/go/webtools/main.go @@ -6,8 +6,6 @@ import ( "muhq.space/muhqs-game/go/game" ) -const () - func jSRandomTileFromMap() js.Func { jsonFunc := js.FuncOf(func(this js.Value, args []js.Value) any { if len(args) != 2 { -- cgit v1.2.3