Initial pass at Golden Pack.
This commit is contained in:
+14
-8
@@ -94,9 +94,15 @@ func Observe(v *game.View, m *Memory) {
|
||||
switch {
|
||||
case e.Kind == game.LogBuy:
|
||||
if c, ok := cardByID(m.PrevShopRow, e.Source); ok {
|
||||
m.Opp.Known = append(m.Opp.Known, c)
|
||||
} else if c, ok := templateByName(e.CardName); ok {
|
||||
m.Opp.Known = append(m.Opp.Known, c)
|
||||
// An Avocado buy is set aside, not kept in the deck (Golden
|
||||
// pack): don't add it to the deck model.
|
||||
if c.Food != game.FoodAvocado {
|
||||
m.Opp.Known = append(m.Opp.Known, c)
|
||||
}
|
||||
} else if c, ok := templateByName(v.Pack, e.CardName); ok {
|
||||
if c.Food != game.FoodAvocado {
|
||||
m.Opp.Known = append(m.Opp.Known, c)
|
||||
}
|
||||
}
|
||||
case e.Kind == game.LogSell:
|
||||
m.removeOppCard(e.Source, e.CardName)
|
||||
@@ -179,15 +185,15 @@ func cardByID(cards []game.Card, id string) (game.Card, bool) {
|
||||
return game.Card{}, false
|
||||
}
|
||||
|
||||
// templateByName mints a reference copy of a named card from the printed
|
||||
// tier contents. The suit is whatever the first printed copy has — callers
|
||||
// only rely on stats and effects.
|
||||
func templateByName(name string) (game.Card, bool) {
|
||||
// templateByName mints a reference copy of a named card from the pack's
|
||||
// printed tier contents. The suit is whatever the first printed copy has —
|
||||
// callers only rely on stats and effects.
|
||||
func templateByName(pack, name string) (game.Card, bool) {
|
||||
if name == "" {
|
||||
return game.Card{}, false
|
||||
}
|
||||
for tier := 1; tier <= game.MaxRounds; tier++ {
|
||||
for _, c := range game.TierContents(tier) {
|
||||
for _, c := range game.TierContentsForPack(pack, tier) {
|
||||
if c.Name == name {
|
||||
return c, true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user