Skip to content

Commit

Permalink
adding wall tech/ground tech action counts (#73)
Browse files Browse the repository at this point in the history
* adds tech action counts

* adds tech action counts

* moved test variable

* style change
  • Loading branch information
Ckoenig1 committed May 26, 2021
1 parent dd0418f commit b88c7af
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Binary file added slp/techTest.slp
Binary file not shown.
25 changes: 25 additions & 0 deletions src/stats/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ export class ActionsComputer implements StatComputer<ActionCountsType[]> {
back: 0,
down: 0,
},
groundTechCount: {
backward: 0,
forward: 0,
neutral: 0,
fail: 0,
},
wallTechCount: {
success: 0,
fail: 0,
},
};
const playerState: PlayerActionState = {
playerCounts: playerCounts,
Expand All @@ -66,6 +76,10 @@ export class ActionsComputer implements StatComputer<ActionCountsType[]> {
}
}

function didMissGroundTech(animation: State): boolean {
return animation === State.TECH_MISS_DOWN || animation === State.TECH_MISS_UP;
}

function isRolling(animation: State): boolean {
return animation === State.ROLL_BACKWARD || animation === State.ROLL_FORWARD;
}
Expand Down Expand Up @@ -166,6 +180,17 @@ function handleActionCompute(state: PlayerActionState, indices: PlayerIndexedTyp
incrementCount("throwCount.down", currentAnimation === State.THROW_DOWN && newAnimation);
incrementCount("throwCount.back", currentAnimation === State.THROW_BACK && newAnimation);

if (newAnimation) {
const didMissTech = didMissGroundTech(currentAnimation);
incrementCount("groundTechCount.fail", didMissTech);
incrementCount("groundTechCount.forward", currentAnimation === State.FORWARD_TECH);
incrementCount("groundTechCount.neutral", currentAnimation === State.NEUTRAL_TECH);
incrementCount("groundTechCount.backward", currentAnimation === State.BACKWARD_TECH);

incrementCount("wallTechCount.success", currentAnimation === State.WALL_TECH);
incrementCount("wallTechCount.fail", currentAnimation === State.MISSED_WALL_TECH);
}

if (isAerialAttack(currentAnimation)) {
incrementCount("lCancelCount.success", playerFrame.lCancelStatus === 1);
incrementCount("lCancelCount.fail", playerFrame.lCancelStatus === 2);
Expand Down
15 changes: 15 additions & 0 deletions src/stats/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ export interface ActionCountsType {
back: number;
down: number;
};
groundTechCount: {
backward: number;
forward: number;
neutral: number;
fail: number;
};
wallTechCount: {
success: number;
fail: number;
};
}

export interface InputCountsType {
Expand Down Expand Up @@ -145,6 +155,11 @@ export enum State {
GUARD_ON = 0xb2,
TECH_MISS_UP = 0xb7,
TECH_MISS_DOWN = 0xbf,
NEUTRAL_TECH = 0xc7,
FORWARD_TECH = 0xc8,
BACKWARD_TECH = 0xc9,
WALL_TECH = 0xca,
MISSED_WALL_TECH = 0xf7,
DASH = 0x14,
TURN = 0x12,
LANDING_FALL_SPECIAL = 0x2b,
Expand Down
7 changes: 7 additions & 0 deletions test/stats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ describe("when calculating stats", () => {
expect(fox.conversionCount).toBe(2);
});
});

it("should count techs only a single time", () => {
const game = new SlippiGame("slp/techTest.slp");
const stats = game.getStats();
expect(stats?.actionCounts[1].groundTechCount).toEqual({ backward: 2, forward: 1, neutral: 8, fail: 4 });
expect(stats?.actionCounts[1].wallTechCount).toEqual({ success: 0, fail: 0 });
});
});

describe("when calculating stock information", () => {
Expand Down

0 comments on commit b88c7af

Please sign in to comment.