DisabledPolicy: a policy that doesn't
This commit is contained in:
		| @@ -398,6 +398,34 @@ func (f *FuncPolicy) Is(p Policy) bool { | ||||
| 	return ok && (f == fp) | ||||
| } | ||||
|  | ||||
| // A DisabledPolicy is never enabled. | ||||
| type DisabledPolicy struct { | ||||
| 	Msg cardsim.Message | ||||
| } | ||||
|  | ||||
| func (d *DisabledPolicy) OptionText(p *Player) (cardsim.Message, error) { | ||||
| 	return d.Msg, nil | ||||
| } | ||||
|  | ||||
| func (d *DisabledPolicy) Enact(*Player) (cardsim.Message, error) { | ||||
| 	return nil, ErrOptionNotEnabled | ||||
| } | ||||
|  | ||||
| func (d *DisabledPolicy) Enabled(*Player) bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func (d *DisabledPolicy) Unenact(*Player) error { | ||||
| 	return ErrPolicyNotEnacted | ||||
| } | ||||
|  | ||||
| func (d *DisabledPolicy) LastEnacted(int, Policy) {} | ||||
|  | ||||
| func (d *DisabledPolicy) Is(p Policy) bool { | ||||
| 	dp, ok := p.(*DisabledPolicy) | ||||
| 	return ok && (dp == d) | ||||
| } | ||||
|  | ||||
| // ShuffleIntoBottomHalf is a common "what to do with the card after?" behavior. | ||||
| func ShuffleIntoBottomHalf(c Card, p *Player, _ CardOption) error { | ||||
| 	p.Deck.InsertRandomBottom(0.5, c) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user