diff --git a/koboldsim/cardtypes.go b/koboldsim/cardtypes.go index e20d151..d2b04d0 100644 --- a/koboldsim/cardtypes.go +++ b/koboldsim/cardtypes.go @@ -48,6 +48,11 @@ type SwitchingCard struct { After func(Card, *Player, CardOption) error Policies []Policy lastPolicy Policy + + // ShowUnavailable controls whether options for which Enabled() = false + // should be presented to the player at all. Indexes for "last enacted" + // still refer to the original list, not the shortened one. + ShowUnavailable bool } // Title implements Card. @@ -71,7 +76,7 @@ func (s *SwitchingCard) EventText(*Player) (cardsim.Message, error) { } // Options implements Card. -func (s *SwitchingCard) Options(*Player) ([]CardOption, error) { +func (s *SwitchingCard) Options(player *Player) ([]CardOption, error) { lastIdx := -1 for i, p := range s.Policies { if p.Is(s.lastPolicy) { @@ -79,10 +84,12 @@ func (s *SwitchingCard) Options(*Player) ([]CardOption, error) { break } } - ret := make([]CardOption, len(s.Policies)) - for i, p := range s.Policies { + ret := make([]CardOption, 0, len(s.Policies)) + for _, p := range s.Policies { p.LastEnacted(lastIdx, s.lastPolicy) - ret[i] = p + if s.ShowUnavailable || p.Enabled(player) { + ret = append(ret, p) + } } return ret, nil }