diff options
| -rw-r--r-- | go/game/action.go | 18 | ||||
| -rw-r--r-- | go/game/ai.go | 28 | ||||
| -rw-r--r-- | go/game/areaEffect.go | 2 | ||||
| -rw-r--r-- | go/game/areaEffect_test.go | 4 | ||||
| -rw-r--r-- | go/game/artifact.go | 7 | ||||
| -rw-r--r-- | go/game/cardImplementations.go | 22 | ||||
| -rw-r--r-- | go/game/cardParsing.go | 2 | ||||
| -rw-r--r-- | go/game/equipment.go | 6 | ||||
| -rw-r--r-- | go/game/permanent.go | 80 | ||||
| -rw-r--r-- | go/game/player.go | 14 | ||||
| -rw-r--r-- | go/game/stack.go | 6 | ||||
| -rw-r--r-- | go/game/state.go | 32 | ||||
| -rw-r--r-- | go/game/unit.go | 19 | ||||
| -rw-r--r-- | go/game/unit_test.go | 2 | ||||
| -rw-r--r-- | go/ui/choice.go | 2 |
15 files changed, 120 insertions, 124 deletions
diff --git a/go/game/action.go b/go/game/action.go index 1e25cd67..f00c21cd 100644 --- a/go/game/action.go +++ b/go/game/action.go @@ -17,7 +17,7 @@ type Action interface { CheckTargets(*State) error PayCosts(s *State) bool - Resolve(s *State) + resolve(s *State) String() string } @@ -28,7 +28,7 @@ func (*PassPriority) Targets() *Targets { return nil } func (*PassPriority) Target() *Target { return nil } func (*PassPriority) CheckTargets(*State) error { return nil } func (*PassPriority) PayCosts(*State) bool { return true } -func (*PassPriority) Resolve(*State) {} +func (*PassPriority) resolve(*State) {} func (*PassPriority) String() string { return "pass" } func NewPassPriority(p *Player) Action { return &PassPriority{p} } @@ -42,7 +42,7 @@ func (sel *TargetSelection) Targets() *Targets { return sel.targets } func (sel *TargetSelection) Target() *Target { return sel.targets.ts[0] } func (sel *TargetSelection) CheckTargets(s *State) error { return sel.targets.CheckTargets(s) } func (*TargetSelection) PayCosts(*State) bool { return true } -func (*TargetSelection) Resolve(*State) {} +func (*TargetSelection) resolve(*State) {} func (*TargetSelection) String() string { return "target selection" } func newTargetSelection(player *Player, targets *Targets) Action { @@ -65,7 +65,7 @@ type ActionBase struct { } func (a *ActionBase) Source() interface{} { return a.source } -func (a *ActionBase) Resolve(s *State) { a.resolveFunc(s) } +func (a *ActionBase) resolve(s *State) { a.resolveFunc(s) } func (a *ActionBase) PayCosts(s *State) bool { return a.costFunc(s) } func (a *ActionBase) Targets() *Targets { return a.targets } func (a *ActionBase) Target() *Target { return a.targets.ts[0] } @@ -221,7 +221,7 @@ func NewAttackAction(u *Unit) *AttackAction { a.targets = newTargets(newTarget(u.Controller().gameState, attackActionTargetDesc, a)) a.resolveFunc = func(s *State) { - s.Fight(u, a.Target().sel[0].(Permanent)) + s.fight(u, a.Target().sel[0].(Permanent)) } a.costFunc = genAttackActionCost(u) @@ -272,7 +272,7 @@ type FullAction struct { tag string } -func NewFullAction(u *Unit, proto ActionFuncPrototype, desc string) *FullAction { +func newFullAction(u *Unit, proto ActionFuncPrototype, desc string) *FullAction { a := &FullAction{ ActionBase: ActionBase{ source: u, @@ -350,7 +350,7 @@ func (a *BuyAction) CheckTargets(s *State) error { return s.isValidBuy(a) } -func (a *BuyAction) Resolve(s *State) { +func (a *BuyAction) resolve(s *State) { a.player.Store.MoveCard(a.card(), a.player.DiscardPile) } @@ -399,12 +399,12 @@ func (a *UpkeepAction) PayCosts(*State) bool { return true } -func (a *UpkeepAction) Resolve(*State) { +func (a *UpkeepAction) resolve(*State) { p := a.player s := p.gameState for _, i := range a.Target().sel { u := i.(*Unit) - s.DestroyPermanent(u) + s.destroyPermanent(u) } // Keep and pay for the rest diff --git a/go/game/ai.go b/go/game/ai.go index 1aa0be62..31a16363 100644 --- a/go/game/ai.go +++ b/go/game/ai.go @@ -228,6 +228,20 @@ func attackAttackableEnemyPerm(ai *UnitAI) Action { return a } +func fullAction(ai *UnitAI) { + fullActions := ai.u.FullActions + idx := 0 + if len(fullActions) > 1 { + idx = ai.s.Rand.Intn(len(fullActions) - 1) + } + + a := fullActions[idx] + err := selectRandomTargets(ai.s.Rand, a.Targets()) + if err == nil { + ai.actions <- a + } +} + // 1. If enemy Unit in attack Range then // attack enemy Unit in Range // 2. While move action available do @@ -281,17 +295,7 @@ out: } } if !inEnemyAttackRange && ai.u.HasFullAction() { - fullActions := ai.u.Card().Impl.fullActions(ai.u) - idx := 0 - if len(fullActions) > 1 { - idx = ai.s.Rand.Intn(len(fullActions) - 1) - } - - a := fullActions[idx] - err := selectRandomTargets(ai.s.Rand, a.Targets()) - if err == nil { - ai.actions <- a - } + fullAction(ai) } // 2. @@ -341,7 +345,7 @@ func WanderingAI(ai *UnitAI, x int) { func TargetOrientedAI(ai *UnitAI) { // 1. if ai.u.HasFullAction() { - ai.u.FullAction() + fullAction(ai) } // if ai.t != nil { diff --git a/go/game/areaEffect.go b/go/game/areaEffect.go index 4cba29e9..ea97b31c 100644 --- a/go/game/areaEffect.go +++ b/go/game/areaEffect.go @@ -34,7 +34,7 @@ func newGrantFullActionEffect(cardPath string, f ActionFuncPrototype, desc, tag } u := p.(*Unit) - fa := NewFullAction(u, f, desc) + fa := newFullAction(u, f, desc) fa.tag = tag u.FullActions = append(u.FullActions, fa) } diff --git a/go/game/areaEffect_test.go b/go/game/areaEffect_test.go index 4f55bffd..3d8c8857 100644 --- a/go/game/areaEffect_test.go +++ b/go/game/areaEffect_test.go @@ -38,7 +38,7 @@ symbols: t.Fatalf("palisade did not enter tile %v", t0_0) } - s.DestroyPermanent(palisade) + s.destroyPermanent(palisade) if !left0_0 || palisade.Tile() != nil || t0_0.Permanent != nil { t.Fatalf("destroyed palisade did not leave tile %v", t0_0) } @@ -59,7 +59,7 @@ symbols: t.Fatalf("moved archer did not leave tile %v", t0_1) } - s.DestroyPermanent(archer) + s.destroyPermanent(archer) if !left0_1 || archer.Tile() != nil || t0_1.Permanent != nil { t.Fatalf("destroyed archer did not leave tile %v", t0_1) } diff --git a/go/game/artifact.go b/go/game/artifact.go index cbe01dc2..6edc975a 100644 --- a/go/game/artifact.go +++ b/go/game/artifact.go @@ -7,7 +7,7 @@ import ( ) type Artifact struct { - PermanentBase + permanentBase Solid int } @@ -17,7 +17,7 @@ func NewArtifactFromPath(cardPath string, tile *Tile, owner *Player) *Artifact { } func NewArtifact(card *Card, tile *Tile, owner *Player) *Artifact { - a := &Artifact{NewPermanentBase(card, tile, owner), 0} + a := &Artifact{newPermanentBase(card, tile, owner), 0} effects := card.getEffects() for _, e := range effects { @@ -34,9 +34,6 @@ func NewArtifact(card *Card, tile *Tile, owner *Player) *Artifact { return a } -func (a *Artifact) Fight(p Permanent) { -} - func (a *Artifact) IsDestroyed() bool { return a.Solid > 0 && a.Damage() >= a.Solid } diff --git a/go/game/cardImplementations.go b/go/game/cardImplementations.go index da348fe1..7055fe03 100644 --- a/go/game/cardImplementations.go +++ b/go/game/cardImplementations.go @@ -32,7 +32,7 @@ func (*advisorImpl) fullActions(u *Unit) []*FullAction { } } } - return []*FullAction{NewFullAction(u, resolvePrototype, "draw 1. exile 1")} + return []*FullAction{newFullAction(u, resolvePrototype, "draw 1. exile 1")} } type missionaryImpl struct{ cardImplementationBase } @@ -49,7 +49,7 @@ func (*missionaryImpl) fullActions(u *Unit) []*FullAction { } } s := u.Controller().gameState - a := NewFullAction(u, resolvePrototype, "put faith ...") + a := newFullAction(u, resolvePrototype, "put faith ...") a.targets = newTargets(newTarget(s, newTargetDesc("unit"), a)) return []*FullAction{a} } @@ -77,7 +77,7 @@ func (*pioneerImpl) fullActions(u *Unit) []*FullAction { return func(s *State) { target := a.Target().sel[0] if artifact, ok := target.(*Artifact); ok { - s.DestroyPermanent(artifact) + s.destroyPermanent(artifact) } else { tile := target.(*Tile) tile.neutralize() @@ -86,7 +86,7 @@ func (*pioneerImpl) fullActions(u *Unit) []*FullAction { } s := u.Controller().gameState - a := NewFullAction(u, resolvePrototype, "neutralize tile or artifact") + a := newFullAction(u, resolvePrototype, "neutralize tile or artifact") // TODO: add target disjunktion 'or' a.targets = newTargets(newTarget(s, newTargetDesc("adjacent tile or artifcat"), a)) return []*FullAction{a} @@ -104,7 +104,7 @@ func (*recruiterImpl) fullActions(u *Unit) []*FullAction { } s := u.Controller().gameState - a := NewFullAction(u, resolvePrototype, "create recruit") + a := newFullAction(u, resolvePrototype, "create recruit") a.targets = newTargets(newTarget(s, newTargetDesc("adjacent tile"), a)) return []*FullAction{a} } @@ -134,7 +134,7 @@ func (*taxCollectorImpl) fullActions(u *Unit) []*FullAction { } } - a := NewFullAction(u, resolvePrototype, "gain 2") + a := newFullAction(u, resolvePrototype, "gain 2") return []*FullAction{a} } @@ -154,7 +154,7 @@ func (*wormtongueImpl) fullActions(u *Unit) []*FullAction { } s := u.Controller().gameState - a := NewFullAction(u, resolvePrototype, "misinform") + a := newFullAction(u, resolvePrototype, "misinform") // TODO: implement player targeting a.targets = newTargets(newTarget(s, newTargetDesc("opponent"), a)) return []*FullAction{a} @@ -204,7 +204,7 @@ func (*fisherImpl) fullActions(u *Unit) []*FullAction { s.AddNewArtifact(NewCard("nautics/fish_trap"), t.Position, u.Controller()) } } - a := NewFullAction(u, resolvePrototype, "create fish trap") + a := newFullAction(u, resolvePrototype, "create fish trap") a.targets = newTargets(newTarget(s, newTargetDesc("adjacent free water tile"), a)) return []*FullAction{a} } @@ -256,7 +256,7 @@ type devourThePoorImpl struct{ cardImplementation } func (*devourThePoorImpl) onPlay(s *State, _ *Card, kraken *Player, _ *Targets) { for _, u := range s.EnemyUnits(kraken) { if u.Card().BuyCost < 7 { - s.DestroyPermanent(u) + s.destroyPermanent(u) } } } @@ -270,7 +270,7 @@ func (i *drownedSailorImpl) onPile(containing Permanent) { i.sailorImpl.onPile func (i *drownedSailorImpl) onUnpile(containing Permanent) { i.sailorImpl.onUnpile(containing) } func (*drownedSailorImpl) onDrop(sailor Permanent) { - sailor.Controller().gameState.DestroyPermanent(sailor) + sailor.Controller().gameState.destroyPermanent(sailor) } // TODO: implement death trigger @@ -301,7 +301,7 @@ func (*frostPylonImpl) spawnTiles(s *State, kraken *Player) (spawns []*Tile) { func (*frostPylonImpl) stateBasedActions(s *State, p Permanent) { if p.Marks(PermanentMarks.Crack) >= 3 { - s.DestroyPermanent(p) + s.destroyPermanent(p) } } diff --git a/go/game/cardParsing.go b/go/game/cardParsing.go index 934a487f..4371afd7 100644 --- a/go/game/cardParsing.go +++ b/go/game/cardParsing.go @@ -139,7 +139,7 @@ func (impl *dynamicCardImplementation) parseFullAction(fullAction string) { fullActions := make([]*FullAction, 0, len(resolveProtos)) for _, proto := range resolveProtos { - fullActions = append(fullActions, NewFullAction(u, proto, "")) + fullActions = append(fullActions, newFullAction(u, proto, "")) } return fullActions diff --git a/go/game/equipment.go b/go/game/equipment.go index 89821458..9e9860e8 100644 --- a/go/game/equipment.go +++ b/go/game/equipment.go @@ -20,17 +20,17 @@ func newEquipment(card *Card, containing interface{}, owner *Player) *Equipment case *Tile: e.tile = containing case *Unit: - AddPermanentToPile(containing, e) + addPermanentToPile(containing, e) } return e } func (e *Equipment) onDrop(p Permanent) { - e.PermanentBase.onDrop(p) + e.permanentBase.onDrop(p) e.Durability-- if e.Durability < 1 { - e.Controller().gameState.DestroyPermanent(e) + e.Controller().gameState.destroyPermanent(e) return } } diff --git a/go/game/permanent.go b/go/game/permanent.go index cd5cbfe6..78966cfe 100644 --- a/go/game/permanent.go +++ b/go/game/permanent.go @@ -24,25 +24,26 @@ type Permanent interface { Marks(PermanentMark) int adjustMarks(PermanentMark, int) - String() string - Fight(p Permanent) - AddDamage(damage int) IsDestroyed() bool Attackable() bool + String() string + CurrentlyAvailActions() []Action AvailActions() []Action IsAvailableTile(*Tile) bool + fight(p Permanent) + addDamage(damage int) setContainingPerm(p Permanent) addPermanentToPile(p Permanent) clearPile() - RemovePermanentFromPile(p Permanent) + removePermanentFromPile(p Permanent) onPile(containing Permanent) onUnpile(containing Permanent) onDrop(containing Permanent) } -type PermanentBase struct { +type permanentBase struct { card *Card tile *Tile damage int @@ -54,12 +55,12 @@ type PermanentBase struct { marks map[PermanentMark]int } -func NewPermanentBase(card *Card, tile *Tile, owner *Player) PermanentBase { +func newPermanentBase(card *Card, tile *Tile, owner *Player) permanentBase { if tile != nil && tile.Permanent != nil { log.Panicf("Tile at %v already occupied by %v", tile.Position, tile.Permanent) } - return PermanentBase{ + return permanentBase{ card: card, tile: tile, controller: owner, @@ -67,16 +68,16 @@ func NewPermanentBase(card *Card, tile *Tile, owner *Player) PermanentBase { } } -func (p *PermanentBase) Card() *Card { return p.card } -func (p *PermanentBase) Tile() *Tile { return p.tile } -func (p *PermanentBase) SetTile(t *Tile) { p.tile = t } -func (p *PermanentBase) Damage() int { return p.damage } -func (p *PermanentBase) ContainingPerm() Permanent { return p.containingPerm } -func (p *PermanentBase) Pile() []Permanent { return p.pile } -func (p *PermanentBase) Controller() *Player { return p.controller } -func (p *PermanentBase) Owner() *Player { return p.owner } +func (p *permanentBase) Card() *Card { return p.card } +func (p *permanentBase) Tile() *Tile { return p.tile } +func (p *permanentBase) SetTile(t *Tile) { p.tile = t } +func (p *permanentBase) Damage() int { return p.damage } +func (p *permanentBase) ContainingPerm() Permanent { return p.containingPerm } +func (p *permanentBase) Pile() []Permanent { return p.pile } +func (p *permanentBase) Controller() *Player { return p.controller } +func (p *permanentBase) Owner() *Player { return p.owner } -func (p *PermanentBase) String() string { +func (p *permanentBase) String() string { if p.Tile() != nil { return fmt.Sprintf("%s's %s@%v", p.Controller().Name, p.Card().Name, p.Tile().Position) @@ -96,22 +97,21 @@ func DealDamage(src, dest Permanent, damage int) { actualDamage = 0 } } - dest.AddDamage(actualDamage) + dest.addDamage(actualDamage) } -func (p *PermanentBase) AddDamage(damage int) { - p.damage += damage -} +func (p *permanentBase) addDamage(damage int) { p.damage += damage } +func (p *permanentBase) fight(Permanent) {} -func (p *PermanentBase) Effects() []string { +func (p *permanentBase) Effects() []string { return append(p.card.getEffects(), p.tmpEffects...) } -func (p *PermanentBase) HasEffect(effect string) bool { +func (p *permanentBase) HasEffect(effect string) bool { return slices.Contains(p.tmpEffects, effect) || p.card.hasEffect(effect) } -func (p *PermanentBase) XEffect(effect string) (int, error) { +func (p *permanentBase) XEffect(effect string) (int, error) { x, err := p.card.getXEffect(effect) for _, e := range p.tmpEffects { @@ -130,7 +130,7 @@ func (p *PermanentBase) XEffect(effect string) (int, error) { return x, err } -func (p *PermanentBase) Marks(mark PermanentMark) int { +func (p *permanentBase) Marks(mark PermanentMark) int { if amount, found := p.marks[mark]; found { return amount } @@ -138,7 +138,7 @@ func (p *PermanentBase) Marks(mark PermanentMark) int { return 0 } -func (p *PermanentBase) adjustMarks(mark PermanentMark, amount int) { +func (p *permanentBase) adjustMarks(mark PermanentMark, amount int) { if amount, found := p.marks[mark]; found { p.marks[mark] += amount } else { @@ -146,18 +146,18 @@ func (p *PermanentBase) adjustMarks(mark PermanentMark, amount int) { } } -func (p *PermanentBase) CurrentlyAvailActions() []Action { return nil } -func (p *PermanentBase) AvailActions() []Action { return nil } +func (p *permanentBase) CurrentlyAvailActions() []Action { return nil } +func (p *permanentBase) AvailActions() []Action { return nil } -func (p *PermanentBase) IsAvailableTile(tile *Tile) bool { +func (p *permanentBase) IsAvailableTile(tile *Tile) bool { return tile.IsAvailableForCard(p.card) } -func (p *PermanentBase) setContainingPerm(containing Permanent) { p.containingPerm = containing } -func (p *PermanentBase) addPermanentToPile(a Permanent) { p.pile = append(p.pile, a) } -func (p *PermanentBase) clearPile() { p.pile = nil } +func (p *permanentBase) setContainingPerm(containing Permanent) { p.containingPerm = containing } +func (p *permanentBase) addPermanentToPile(a Permanent) { p.pile = append(p.pile, a) } +func (p *permanentBase) clearPile() { p.pile = nil } -func (p *PermanentBase) RemovePermanentFromPile(rm Permanent) { +func (p *permanentBase) removePermanentFromPile(rm Permanent) { for i, piled := range p.pile { if piled != rm { continue @@ -169,26 +169,26 @@ func (p *PermanentBase) RemovePermanentFromPile(rm Permanent) { } } -func (b *PermanentBase) onPile(containing Permanent) { b.Card().Impl.onPile(containing) } -func (b *PermanentBase) onUnpile(containing Permanent) { b.Card().Impl.onUnpile(containing) } -func (b *PermanentBase) onDrop(dropped Permanent) { +func (b *permanentBase) onPile(containing Permanent) { b.Card().Impl.onPile(containing) } +func (b *permanentBase) onUnpile(containing Permanent) { b.Card().Impl.onUnpile(containing) } +func (b *permanentBase) onDrop(dropped Permanent) { b.onUnpile(dropped.ContainingPerm()) b.Card().Impl.onDrop(dropped) } -func AddPermanentToPile(containing, p Permanent) { +func addPermanentToPile(containing, p Permanent) { p.setContainingPerm(containing) containing.addPermanentToPile(p) p.onPile(containing) } -func RemovePermanentFromPile(containing, rm Permanent) { - containing.RemovePermanentFromPile(rm) +func removePermanentFromPile(containing, rm Permanent) { + containing.removePermanentFromPile(rm) rm.onUnpile(containing) rm.setContainingPerm(nil) } -func DropPile(containing Permanent) { +func dropPile(containing Permanent) { for _, p := range containing.Pile() { p.onDrop(p) p.setContainingPerm(nil) @@ -207,7 +207,7 @@ func enterTileOrPile(p Permanent, t *Tile) { if t.Permanent == nil { enterTile(p, t) } else { - AddPermanentToPile(t.Permanent, p) + addPermanentToPile(t.Permanent, p) p.SetTile(nil) } } diff --git a/go/game/player.go b/go/game/player.go index 4abe4d23..67a77a10 100644 --- a/go/game/player.go +++ b/go/game/player.go @@ -75,7 +75,7 @@ func (p *Player) gainResource(gain int) { p.Resource += gain } -func (p *Player) Upkeep() { +func (p *Player) upkeep() { p.gainResource(p.resourceGain()) // TODO: handle upkeep triggers @@ -99,21 +99,21 @@ func (p *Player) Upkeep() { } p.gameState.DeclareAction(a) - p.gameState.Stack.Resolve() + p.gameState.Stack.resolve() } -func (p *Player) ActionPhase() { +func (p *Player) actionPhase() { for { a := promptAction(p.Ctrl) if _, ok := a.(*PassPriority); ok { return } p.gameState.DeclareAction(a) - p.gameState.Stack.Resolve() + p.gameState.Stack.resolve() } } -func (p *Player) BuyPhase() { +func (p *Player) buyPhase() { s := p.gameState if p.Store.Size() == 0 && s.Map.HasStores() && len(p.knownStores) == 0 { return @@ -126,7 +126,7 @@ func (p *Player) BuyPhase() { if a.Targets().HasSelections() { s.DeclareAction(a) - s.Stack.Resolve() + s.Stack.resolve() } } @@ -140,7 +140,7 @@ func (p *Player) DiscardCard(c *Card) { p.Hand.MoveCard(c, p.DiscardPile) } -func (p *Player) DiscardPhase() { +func (p *Player) discardPhase() { if p.Hand.Size() == 0 { return } diff --git a/go/game/stack.go b/go/game/stack.go index a06af9f3..60f041b3 100644 --- a/go/game/stack.go +++ b/go/game/stack.go @@ -32,7 +32,7 @@ func (s *Stack) pop() { err := s.gameState.ValidateAction(a) if err == nil { - a.Resolve(s.gameState) + a.resolve(s.gameState) // Some action may be reused like full actions of permanents. // Reset their target selection to allow possible reuse. if t := a.Targets(); t != nil { @@ -43,9 +43,9 @@ func (s *Stack) pop() { s.gameState.broadcastNotification(newResolvedActionNotification(a, err)) } -func (s *Stack) Resolve() { +func (s *Stack) resolve() { for !s.IsEmpty() { - s.gameState.AllPassing(false) + s.gameState.allPassing(false) s.pop() s.gameState.stateBasedActions() } diff --git a/go/game/state.go b/go/game/state.go index 4af56b10..d98595b4 100644 --- a/go/game/state.go +++ b/go/game/state.go @@ -74,19 +74,19 @@ func (s *State) Loop() []*Player { p.Draw() s.ActivePhase = Phases.UpkeepPhase - p.Upkeep() - s.PhaseChange() + p.upkeep() + s.phaseChange() s.ActivePhase = Phases.ActionPhase - p.ActionPhase() - s.PhaseChange() + p.actionPhase() + s.phaseChange() s.ActivePhase = Phases.BuyPhase - p.BuyPhase() - s.PhaseChange() + p.buyPhase() + s.phaseChange() s.ActivePhase = Phases.DiscardPhase - p.DiscardPhase() + p.discardPhase() winners = s.Map.WinCondition(s) } @@ -100,7 +100,7 @@ func (s *State) stateBasedActions() { p.Card().Impl.stateBasedActions(s, p) if p.IsDestroyed() { - s.DestroyPermanent(p) + s.destroyPermanent(p) } } } @@ -254,7 +254,7 @@ func (s *State) DeclareAction(a Action) { s.broadcastNotification(newDeclaredActionNotification(a, err)) } -func (s *State) AllPassing(skipFirst bool) bool { +func (s *State) allPassing(skipFirst bool) bool { nPlayers := len(s.Players) i := 0 if skipFirst { @@ -275,10 +275,10 @@ func (s *State) AllPassing(skipFirst bool) bool { return true } -func (s *State) PhaseChange() { +func (s *State) phaseChange() { skipFirst := true - for !s.AllPassing(skipFirst) { - s.Stack.Resolve() + for !s.allPassing(skipFirst) { + s.Stack.resolve() skipFirst = false } } @@ -342,7 +342,7 @@ func removePtr[P *Unit](collection []P, ptr P) []P { return collection } -func (s *State) DestroyPermanent(p Permanent) { +func (s *State) destroyPermanent(p Permanent) { leaveTile(p) s.removePermanent(p) @@ -353,9 +353,9 @@ func (s *State) DestroyPermanent(p Permanent) { p.Owner().DiscardPile.AddCard(p.Card()) } -func (s *State) Fight(p1, p2 Permanent) { - p1.Fight(p2) - p2.Fight(p1) +func (s *State) fight(p1, p2 Permanent) { + p1.fight(p2) + p2.fight(p1) } func (s *State) MoveUnit(u *Unit, t *Tile) { diff --git a/go/game/unit.go b/go/game/unit.go index bc9cad3f..5b071d7b 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -11,7 +11,7 @@ const ( ) type Unit struct { - PermanentBase + permanentBase Health int Movement Movement Attack Attack @@ -45,7 +45,7 @@ func NewUnit(card *Card, tile *Tile, owner *Player) *Unit { } u := &Unit{ - PermanentBase: NewPermanentBase(card, tile, owner), + permanentBase: newPermanentBase(card, tile, owner), Health: card.Values["health"].(int), Movement: movement, Attack: attack, @@ -94,7 +94,7 @@ func (u *Unit) move(s *State, tile *Tile) { } if u.containingPerm != nil { - RemovePermanentFromPile(u.containingPerm, u) + removePermanentFromPile(u.containingPerm, u) } else { leaveTile(u) } @@ -158,7 +158,7 @@ func (u *Unit) AttackableEnemyPermanents(m *Map) []Permanent { return permanents } -func (u *Unit) Fight(p Permanent) { +func (u *Unit) fight(p Permanent) { r := DistanceBetweenPermanents(p, u) DealDamage(u, p, u.Attack.DamageInRange(r)) } @@ -176,9 +176,6 @@ func (u *Unit) HasFullAction() bool { return len(u.FullActions) > 0 } -func (u *Unit) FullAction() { -} - func (u *Unit) AvailSlowActions() (actions []Action) { if u.AvailMoveActions > 0 && u.Movement != INVALID_MOVEMENT() { actions = append(actions, NewMoveAction(u)) @@ -229,7 +226,7 @@ func (u *Unit) AvailActions() (actions []Action) { } func (u *Unit) onPile(containing Permanent) { - u.PermanentBase.onPile(containing) + u.permanentBase.onPile(containing) if baseUnit, ok := containing.(*Unit); ok { baseUnitAttackRange := baseUnit.Attack.MaxRange() for r, a := range u.Attack.attacks { @@ -243,7 +240,7 @@ func (u *Unit) onPile(containing Permanent) { } func (u *Unit) onUnpile(containing Permanent) { - u.PermanentBase.onUnpile(u) + u.permanentBase.onUnpile(u) if baseUnit, ok := containing.(*Unit); ok { for r, a := range baseUnit.Attack.attacks { if a == u.Attack.attacks[r] { @@ -273,11 +270,11 @@ func (u *Unit) removeFullAction(tag string) { } } -func (u *Unit) AddDamage(damage int) { +func (u *Unit) addDamage(damage int) { if u.Marks(UnitMarks.Ward) > 0 { u.adjustMarks(UnitMarks.Ward, -1) return } - u.PermanentBase.AddDamage(damage) + u.permanentBase.addDamage(damage) } diff --git a/go/game/unit_test.go b/go/game/unit_test.go index c4a92372..4b0ee8cc 100644 --- a/go/game/unit_test.go +++ b/go/game/unit_test.go @@ -74,7 +74,7 @@ symbols: t.Fatalf("fisher has still a valid atack") } - AddPermanentToPile(a, sword) + addPermanentToPile(a, sword) if a.Attack.attacks[0] != 2 { t.Fatalf("archer's mele attack is not 2") } diff --git a/go/ui/choice.go b/go/ui/choice.go index 04b8f725..28f03f72 100644 --- a/go/ui/choice.go +++ b/go/ui/choice.go @@ -14,8 +14,6 @@ type Choice struct { onClick func(*Choice, int, int) } -func choiceButtonOnClickDummy(b *SimpleButton) {} - func NewChoice(x, y int, choices []interface{}, onClick func(*Choice, int, int)) *Choice { c := &Choice{ TextBox: *(NewAutoTextBox(x, y, "")), |
