neon_crisp / Modules / gameContextManger/gameContext/gameContext / GameContext
Class: GameContext
gameContextManger/gameContext/gameContext.GameContext
Table of contents
Constructors
Properties
Methods
- OnAfterAttack
- OnBeforeAttack
- OnGameStart
- OnHeathAtOrBelowZero
- OnTargeted
- OnTurn
- addCardToDeck
- addCardToHand
- addMana
- canSpendMana
- drawCard
- findCardLocation
- getAllCards
- getCardInHandForId
- getDeck
- getHand
- getTarget
- moveCard
- onAttack
- onCardStateChange
- onDamage
- processNextActionInQue
- registerActionIntent
- removeCard
- removeCardFromHand
- spawnCard
- spendMana
- updateRound
- updateTurn
- updateUsed
Constructors
constructor
• new GameContext(oldGameContext?): GameContext
Parameters
| Name | Type |
|---|---|
oldGameContext? | GameContext |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:18
Properties
actionQue
• actionQue: ActionIntent[]
Defined in
gameContextManger/gameContext/gameContext.ts:16
currentAction
• currentAction: undefined | ActionHook
Defined in
gameContextManger/gameContext/gameContext.ts:17
deckA
• deckA: Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:8
deckB
• deckB: Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:9
discardA
• discardA: Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:10
discardB
• discardB: Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:11
handA
• handA: Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:6
handB
• handB: Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:7
manaA
• manaA: number
Defined in
gameContextManger/gameContext/gameContext.ts:12
manaB
• manaB: number
Defined in
gameContextManger/gameContext/gameContext.ts:13
round
• round: number
Defined in
gameContextManger/gameContext/gameContext.ts:14
turn
• turn: number
Defined in
gameContextManger/gameContext/gameContext.ts:15
Methods
OnAfterAttack
▸ OnAfterAttack(attackingCard, defendingCard): void
this is to handle all on after attack and should only be called by game context
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:245
OnBeforeAttack
▸ OnBeforeAttack(attackingCard, defendingCard): void
this is to handle all on before attack and should only be called by game context
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:233
OnGameStart
▸ OnGameStart(attackingCard, defendingCard): void
this is to handle all on game start and should only be called by game context
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:208
OnHeathAtOrBelowZero
▸ OnHeathAtOrBelowZero(attackingCard, defendingCard): void
this is to handle all on health on or below zero and should only be called by game context
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:184
OnTargeted
▸ OnTargeted(attackingCard, defendingCard): void
this is to handle all on targeted and should only be called by game context
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:220
OnTurn
▸ OnTurn(attackingCard, defendingCard): void
this is to handle all on turn and should only be called by game context
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:196
addCardToDeck
▸ addCardToDeck(deck, card): GameContext
Parameters
| Name | Type |
|---|---|
deck | "A" | "B" |
card | Card |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:403
addCardToHand
▸ addCardToHand(hand, card): GameContext
Parameters
| Name | Type |
|---|---|
hand | "A" | "B" |
card | Card |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:397
addMana
▸ addMana(amount, hand): void
Parameters
| Name | Type |
|---|---|
amount | number |
hand | "A" | "B" |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:66
canSpendMana
▸ canSpendMana(cost, hand): boolean
Parameters
| Name | Type |
|---|---|
cost | number |
hand | "A" | "B" |
Returns
boolean
Defined in
gameContextManger/gameContext/gameContext.ts:48
drawCard
▸ drawCard(deck): void
Parameters
| Name | Type |
|---|---|
deck | "A" | "B" |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:408
findCardLocation
▸ findCardLocation(cardId): undefined | { index: number ; list: "HAND" | "DECK" | "DISCARD" ; owner: "A" | "B" }
Parameters
| Name | Type |
|---|---|
cardId | string |
Returns
undefined | { index: number ; list: "HAND" | "DECK" | "DISCARD" ; owner: "A" | "B" }
Defined in
gameContextManger/gameContext/gameContext.ts:322
getAllCards
▸ getAllCards(): Card[]
Returns
Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:314
getCardInHandForId
▸ getCardInHandForId(cardId): undefined | Card
Parameters
| Name | Type |
|---|---|
cardId | string |
Returns
undefined | Card
Defined in
gameContextManger/gameContext/gameContext.ts:317
getDeck
▸ getDeck(deck): Card[]
Parameters
| Name | Type |
|---|---|
deck | "A" | "B" |
Returns
Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:275
getHand
▸ getHand(hand): Card[]
Parameters
| Name | Type |
|---|---|
hand | "A" | "B" |
Returns
Card[]
Defined in
gameContextManger/gameContext/gameContext.ts:271
getTarget
▸ getTarget(hand, strategy, attackingCard): Card
Parameters
| Name | Type |
|---|---|
hand | "A" | "B" |
strategy | "RANDOM" |
attackingCard | Card |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:417
moveCard
▸ moveCard(hand, fromIndex, toIndex): GameContext
Parameters
| Name | Type |
|---|---|
hand | "A" | "B" |
fromIndex | number |
toIndex | number |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:279
onAttack
▸ onAttack(attackingCard, defendingCard): void
this is to handel all on attack actions for every card and should only be called by processNextActionInQue
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:144
onCardStateChange
▸ onCardStateChange(attackingCard, defendingCard): void
this is to handle all on state change actions and should only be called by game context
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:170
onDamage
▸ onDamage(attackingCard, defendingCard): void
this is to handel all on damage actions for every card and should only be called by processNextActionInQue
Parameters
| Name | Type |
|---|---|
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:157
processNextActionInQue
▸ processNextActionInQue(): void
will take then next action in the action que find the correct handler for said action and call it. This is what keeps the game state moving forward should only be called by game context manager unless writing tests.
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:104
registerActionIntent
▸ registerActionIntent(hook, attackingCard, defendingCard): void
This is how a new action is added to the game. Anything you want to do starts here. Cards can call this on the game context they have access too. But outside of the card they should be called on game context manger. Because this game context is incorporeal and a new one will be created and that one will be the main game context until another one is created.
Parameters
| Name | Type |
|---|---|
hook | ActionHook |
attackingCard | Card |
defendingCard | Card |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:88
removeCard
▸ removeCard(cardId): GameContext
Parameters
| Name | Type |
|---|---|
cardId | string |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:392
removeCardFromHand
▸ removeCardFromHand(hand, cardId): GameContext
Parameters
| Name | Type |
|---|---|
hand | "A" | "B" |
cardId | string |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:294
spawnCard
▸ spawnCard(hand, cardId): void
Parameters
| Name | Type |
|---|---|
hand | "A" | "B" |
cardId | string |
Returns
void
Defined in
gameContextManger/gameContext/gameContext.ts:428
spendMana
▸ spendMana(cost, hand): boolean
Parameters
| Name | Type |
|---|---|
cost | number |
hand | "A" | "B" |
Returns
boolean
Defined in
gameContextManger/gameContext/gameContext.ts:55
updateRound
▸ updateRound(newRound): GameContext
Parameters
| Name | Type |
|---|---|
newRound | number |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:261
updateTurn
▸ updateTurn(newTurn): GameContext
Parameters
| Name | Type |
|---|---|
newTurn | number |
Returns
Defined in
gameContextManger/gameContext/gameContext.ts:266
updateUsed
▸ updateUsed(hand): void
Parameters
| Name | Type |
|---|---|
hand | "A" | "B" |
Returns
void