function Card:NotifyChanged() local clone = self:Clone() if self.engine then -- Lock in the current damage and modifier string for this card, so that the UI -- will have the correct values generated from this point in time. local min_persuasion, max_persuasion, details = self.engine:PreviewPersuasion( self ) clone.CalculatePersuasion = function( self ) return min_persuasion, max_persuasion, details end end self.deck.engine:BroadcastEvent( EVENT.CARD_CHANGED, self, clone ) return clone end
as you can see, on the third to last line, the self.deck part was completely unnecessary, as you can directly get the engine from self. However, if this is called on a card that's not in a deck, it will crash the game, since you're indexing on a nil value.
1. generate a card that's not in a deck with code.
2. call NotifyChange while this card is not part of any deck.
3. crash game.