Skip to main content

neon_crisp / Modules / card/card / Card

Class: Card

card/card.Card

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Card(hp, atk, id, displayData, attackActions, onDamageActions, onStateChangeActions, onHealthAtOrBelowZero, onTurn, onGameStart, onTargeted, onAfterAttack, onBeforeAttack): Card

Parameters

NameType
hpnumber
atknumber
idstring
displayDataCardDisplayData
attackActionsActionTitle[]
onDamageActionsActionTitle[]
onStateChangeActionsActionTitle[]
onHealthAtOrBelowZeroActionTitle[]
onTurnActionTitle[]
onGameStartActionTitle[]
onTargetedActionTitle[]
onAfterAttackActionTitle[]
onBeforeAttackActionTitle[]

Returns

Card

Defined in

card/card.ts:41

Properties

atk

atk: number

Defined in

card/card.ts:24


displayData

displayData: CardDisplayData

Defined in

card/card.ts:36


hp

hp: number

Defined in

card/card.ts:23


id

id: string

Defined in

card/card.ts:26


incomingDamage

incomingDamage: number

Defined in

card/card.ts:37


onAfterAttack

onAfterAttack: Action[]

Defined in

card/card.ts:34


onAttack

onAttack: Action[]

Defined in

card/card.ts:27


onBeforeAttack

onBeforeAttack: Action[]

Defined in

card/card.ts:35


onDamage

onDamage: Action[]

Defined in

card/card.ts:28


onGameStart

onGameStart: Action[]

Defined in

card/card.ts:32


onHealthAtOrBelowZero

onHealthAtOrBelowZero: Action[]

Defined in

card/card.ts:30


onStateChange

onStateChange: Action[]

Defined in

card/card.ts:29


onTargeted

onTargeted: Action[]

Defined in

card/card.ts:33


onTurn

onTurn: Action[]

Defined in

card/card.ts:31


state

state: Record<string, any>

Defined in

card/card.ts:38


uid

uid: string

Defined in

card/card.ts:25


used

used: boolean

Defined in

card/card.ts:39

Methods

freezeCheck

freezeCheck(): boolean

Returns

boolean

Defined in

card/card.ts:122


getCardRenderData

getCardRenderData(): CardRenderData

This is the accepted way of getting a cards info for displaying data in the game. This function should return you everything you need to render or update the card

Returns

CardRenderData

Defined in

card/card.ts:136


handleFreeze

handleFreeze(): void

Returns

void

Defined in

card/card.ts:125


handleOnAfterAttack

handleOnAfterAttack(attackingCard, defendingCard, gameContext): void

this is to handle all on after attack actions and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:286


handleOnAttack

handleOnAttack(attackingCard, defendingCard, gameContext): void

this is to handle all on attack actions and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:198


handleOnBeforeAttack

handleOnBeforeAttack(attackingCard, defendingCard, gameContext): void

this is to handle all on before attack actions and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:275


handleOnCardStateChange

handleOnCardStateChange(attackingCard, defendingCard, gameContext): void

this is to handle all on state change actions and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:225


handleOnDamage

handleOnDamage(attackingCard, defendingCard, gameContext): void

this is to handle all on damage actions and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:211


handleOnGameStart

handleOnGameStart(attackingCard, defendingCard, gameContext): void

this is to handle all on game start actions and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:266


handleOnHeathAtOrBelowZero

handleOnHeathAtOrBelowZero(attackingCard, defendingCard, gameContext): void

this is to handle all on health on or below zero and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:234


handleOnTargeted

handleOnTargeted(attackingCard, defendingCard, gameContext): void

this is to handle all on targeted actions and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:255


handleOnTurn

handleOnTurn(attackingCard, defendingCard, gameContext): void

this is to handle all on turn actions and should only be called by game context

Parameters

NameType
attackingCardCard
defendingCardCard
gameContextGameContext

Returns

void

Defined in

card/card.ts:243


informCardGameObjectThatStateMayHaveChanged

informCardGameObjectThatStateMayHaveChanged(): void

Returns

void

Defined in

card/card.ts:148


mutateState

mutateState(newState): void

This is the the internal way to change a cards state. mutates card state. And does NOT registers an on state change hook should only be used in an init hook or internally to change cards state like clone or setState

Parameters

NameType
newStateRecord<string, any>

Returns

void

Example

card.setState({bubble:1});

Defined in

card/card.ts:163


receiveDamage

receiveDamage(incomingDamage, attackingCard, gameContext): void

This is the expected way to damage a card. Adds damage onto the card to be handled in the next handleOnDamage hook call. And registers an on damage hook to be called so the incoming damage can be removed

Parameters

NameType
incomingDamagenumber
attackingCardCard
gameContextGameContext

Returns

void

Example

card.receiveDamage(5, attackingCard,gameContext);

Defined in

card/card.ts:189


registerCardGameObjId

registerCardGameObjId(id): Card

This is the accepted adding a game object id to a card so that you can find the game obj from the card or the card from the game object.

Parameters

NameType
idhash

Returns

Card

Defined in

card/card.ts:143


setState

setState(newState, attackingCard, gameContext): void

This is the expected way to change a cards state. mutates card state. And registers an on state change hook to be called so the the new state can be reacted to

Parameters

NameType
newStateRecord<string, any>
attackingCardCard
gameContextGameContext

Returns

void

Example

card.setState({bubble:1}, attackingCard,gameContext);

Defined in

card/card.ts:175


clone

clone(cardToClone): Card

Clones card and returns new card. Only used to clone game state.

Parameters

NameType
cardToCloneCard

Returns

Card

Defined in

card/card.ts:100