Skip to content

Commit

Permalink
FEAT: Prototypes for Counter Stack
Browse files Browse the repository at this point in the history
  • Loading branch information
Bratah123 committed Feb 20, 2023
1 parent 0489d06 commit e011751
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
6 changes: 6 additions & 0 deletions client/src/game/counter_stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Card from "./card";
import { Vector } from "js-sdsl";

export default class CounterStack {
counters: Vector<Card> = new Vector<Card>();
}
5 changes: 5 additions & 0 deletions client/src/game/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,9 @@ export default class Player {
this.playerState = PlayerState.BLOCKER_PHASE;
scene.uiHandler.setEndButtonToBlockerPhase();
}

setCounterPhase(scene: GameBoard) {
this.playerState = PlayerState.COUNTER_PHASE;
scene.uiHandler.setEndButtonToCounterPhase();
}
}
15 changes: 3 additions & 12 deletions client/src/handlers/game_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,8 @@ export default class GameHandler {
if (!attackingCard || !defendingCard) {
return;
}
// Check if the attacking card has any don!! attached
if (attackingCard.donAttached.length > 0) {
attackingCard.unHighlightBounds();
}
attackingCard.rest();

if (attackingCard.donAttached.length > 0) {
attackingCard.highlightBounds(0xff0000);
}

// calculate screen coord
let attackingCardXOnScreen = attackingCard.x;
let attackingCardYOnScreen = attackingCard.y;
Expand Down Expand Up @@ -481,7 +473,7 @@ export default class GameHandler {
if (this.player.playerState === PlayerState.BLOCKER_PHASE) {
console.log("Skipped block, going to counter phase");
callback(-3); // The code to inform server that user skipped block
this.player.playerState = PlayerState.COUNTER_PHASE;
this.player.setCounterPhase(this.scene)
}
// Unhighlight all blockers
this.player.characterArea.forEach((cardInField: Card) => {
Expand Down Expand Up @@ -524,7 +516,7 @@ export default class GameHandler {
informativeText.setText(`Opponent is attacking your ${card.name}`);
informativeText.y = 50;

this.player.playerState = PlayerState.COUNTER_PHASE;
this.player.setCounterPhase(this.scene);
skipBlockerButton.destroy();
}
});
Expand All @@ -537,9 +529,8 @@ export default class GameHandler {
}

if (totalBlockers == 0) {
// TODO: Go to Counter Phase
skipBlockerButton.destroy();
this.player.playerState = PlayerState.COUNTER_PHASE;
this.player.setCounterPhase(this.scene);
console.log("Go to Counter Phase");
return;
}
Expand Down
5 changes: 5 additions & 0 deletions client/src/handlers/ui_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ export default class UiHandler {
this.endTurnButton.buttonText.setText("BLOCKING...");
this.endTurnButton.buttonText.setFontSize(34);
}

setEndButtonToCounterPhase() {
this.endTurnButton.buttonText.setText("COUNTERING...");
this.endTurnButton.buttonText.setFontSize(34);
}
}

0 comments on commit e011751

Please sign in to comment.