-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexaustive_strategy.go
63 lines (50 loc) · 1.22 KB
/
exaustive_strategy.go
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
57
58
59
60
61
62
63
package main
type exaustiveStrat struct {
cc cardCatalogue
}
type cardCatalogue struct {
}
type cardInfo struct {
IsBasic bool
ComesInTapped bool
TapsFor []string
}
func contains(a []string, itemToCheck string) bool {
for _, val := range a {
if val == itemToCheck {
return true
}
}
return false
}
func (es exaustiveStrat) MainPhase(previousState *PlayerState) []PlayerState {
result := make([]PlayerState, 0)
cardsPlayed := make([]string, 0)
for _, cardFromHand := range previousState.hand {
liForCard, cardIsLand := es.cc.GetDetail(cardFromHand)
if !cardIsLand {
continue
}
if contains(cardsPlayed, cardFromHand) {
continue
}
nextState := previousState.Clone()
nextState.PlayCard(cardFromHand, liForCard.ComesInTapped)
result = append(result, *nextState)
cardsPlayed = append(cardsPlayed, cardFromHand)
}
if len(result) == 0 {
result = append(result, *previousState)
}
return result
}
func (es exaustiveStrat) DiscardPhase(previousState *PlayerState) []PlayerState {
result := []PlayerState{
*previousState,
}
return result
}
func (cc cardCatalogue) GetDetail(cardID string) (cardInfo, bool) {
resultInfo, resultOk := cardlist[cardID]
return resultInfo, resultOk
}