aboutsummaryrefslogtreecommitdiff
path: root/go/game/cardImplementations.go
blob: 8024e4fc50ee2ca124f0afe450b02ba795a445e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package game

type farmerImplementation struct {
	cardImplementationBase
}

type advisorImplementation struct {
	cardImplementationBase
}

func (impl *advisorImplementation) fullAction(u *Unit) []*FullAction {
	resolvePrototype := func(a Action) ActionResolveFunc {
		u := a.Source().(*Unit)
		return func(s *State) {
			controller := u.Controller()
			controller.DrawN(1)
			cards := controller.PromptHandCardSelection(0, 1)
			if cards != nil {
				controller.Deck.MoveCard(cards[0], s.Exile)
			}
		}
	}
	return []*FullAction{NewFullAction(u, resolvePrototype, "draw 1. exile 1")}
}

type missionaryImplementation struct {
	cardImplementationBase
}

func (impl *missionaryImplementation) fullAction(u *Unit) []*FullAction {
	resolvePrototype := func(a Action) ActionResolveFunc {
		u := a.Source().(*Unit)
		target := a.Targets().sel[0].(*Unit)
		return func(s *State) {
			faith, found := target.States[UnitMarks.Faith]
			if !found {
				target.States[UnitMarks.Faith] = 2
			} else {
				target.States[UnitMarks.Faith] = faith + 2
				if faith+2 > target.Card().BuyCost {
					target.controller = u.Controller()
				}
			}
		}
	}
	return []*FullAction{NewFullAction(u, resolvePrototype, "put faith ...")}
}

func init() {
	cardImplementations = map[string]cardImplementation{
		"base/advisor":    &advisorImplementation{},
		"base/missionary": &missionaryImplementation{},

		"misc/farmer": &farmerImplementation{},
	}
}