Support un-castable cards.

This commit is contained in:
Daniel Schmidt 2023-05-09 11:22:45 +02:00
parent c7616099db
commit 526fe76a45
2 changed files with 9 additions and 1 deletions

View File

@ -1307,8 +1307,12 @@ func (s *Session) PlayerCastHand(i int, target string) error {
cardId := s.currentFight.Hand[i]
// Only cast a card if points are available and subtract them.
// Only cast a card if castable and points are available and subtract them.
if card, _ := s.GetCard(cardId); card != nil {
if !card.Callbacks[CallbackOnCast].Present() {
return errors.New("card is not castable")
}
if s.currentFight.CurrentPoints < card.PointCost {
return errors.New("not enough points")
}

View File

@ -14,3 +14,7 @@ func (cb OwnedCallback) Call(args ...any) (any, error) {
return cb(args...)
}
func (cb OwnedCallback) Present() bool {
return cb != nil
}