aboutsummaryrefslogtreecommitdiff
path: root/go/game/cardParsing.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/cardParsing.go')
-rw-r--r--go/game/cardParsing.go33
1 files changed, 17 insertions, 16 deletions
diff --git a/go/game/cardParsing.go b/go/game/cardParsing.go
index 3a316c4f..afdefe54 100644
--- a/go/game/cardParsing.go
+++ b/go/game/cardParsing.go
@@ -8,10 +8,10 @@ import (
)
type parsedCardImplementation struct {
- card *Card
- spawnTilesFunc func(*State, *Player) []*Tile
- genFullActionPrototypes func(*Unit) []*FullActionPrototype
- genFreeActionPrototypes func(Permanent) []*FreeActionPrototype
+ card *Card
+ spawnTilesFunc func(*State, *Player) []*Tile
+ genFullActions func(*Unit) []*FullAction
+ genFreeActions func(Permanent) []*FreeAction
}
func (impl *parsedCardImplementation) spawnTiles(s *State, p *Player) []*Tile {
@@ -21,16 +21,16 @@ func (impl *parsedCardImplementation) spawnTiles(s *State, p *Player) []*Tile {
return nil
}
-func (impl *parsedCardImplementation) fullActionPrototypes(u *Unit) []*FullActionPrototype {
- if impl.genFullActionPrototypes != nil {
- return impl.genFullActionPrototypes(u)
+func (impl *parsedCardImplementation) fullActions(u *Unit) []*FullAction {
+ if impl.genFullActions != nil {
+ return impl.genFullActions(u)
}
return nil
}
-func (impl *parsedCardImplementation) freeActionPrototypes(p Permanent) []*FreeActionPrototype {
- if impl.genFreeActionPrototypes != nil {
- return impl.genFreeActionPrototypes(p)
+func (impl *parsedCardImplementation) freeActions(p Permanent) []*FreeAction {
+ if impl.genFreeActions != nil {
+ return impl.genFreeActions(p)
}
return nil
}
@@ -55,7 +55,7 @@ func (impl *parsedCardImplementation) parseEffect(effect string) {
}
func (impl *parsedCardImplementation) parseFullAction(fullAction string) {
- var resolveProtos []func(*State, *Unit) func(*State)
+ var resolveProtos []ActionFuncPrototype
gainRessourceRegex := regexp.MustCompile(`gain [1-9][0-9]* resource`)
if find := gainRessourceRegex.Find([]byte(fullAction)); find != nil {
@@ -65,7 +65,8 @@ func (impl *parsedCardImplementation) parseFullAction(fullAction string) {
log.Fatalf("Failed to parse resource gain full action: %s", err)
}
- resolveProto := func(_ *State, u *Unit) func(*State) {
+ resolveProto := func(a Action) ActionResolveFunc {
+ u := a.Source().(*Unit)
return func(*State) {
u.controller.gainResource(gain)
}
@@ -74,14 +75,14 @@ func (impl *parsedCardImplementation) parseFullAction(fullAction string) {
}
if resolveProtos != nil {
- impl.genFullActionPrototypes = func(u *Unit) []*FullActionPrototype {
- fullActionPrototypes := make([]*FullActionPrototype, 0, len(resolveProtos))
+ impl.genFullActions = func(u *Unit) []*FullAction {
+ fullActions := make([]*FullAction, 0, len(resolveProtos))
for _, proto := range resolveProtos {
- fullActionPrototypes = append(fullActionPrototypes, NewFullActionPrototype(u, proto))
+ fullActions = append(fullActions, NewFullAction(u, proto, ""))
}
- return fullActionPrototypes
+ return fullActions
}
}
}