Skip to content

Commit

Permalink
Merge 99b6001 into 807f161
Browse files Browse the repository at this point in the history
  • Loading branch information
Ckoenig1 committed Aug 5, 2021
2 parents 807f161 + 99b6001 commit 7c690e4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
Binary file added slp/facingDirection.slp
Binary file not shown.
Binary file removed slp/techTest.slp
Binary file not shown.
Binary file added slp/techTester.slp
Binary file not shown.
22 changes: 18 additions & 4 deletions src/stats/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ export class ActionsComputer implements StatComputer<ActionCountsType[]> {
down: 0,
},
groundTechCount: {
backward: 0,
forward: 0,
// tech away/in are in reference to the opponents position and not the stage
away: 0,
in: 0,
neutral: 0,
fail: 0,
},
Expand Down Expand Up @@ -137,6 +138,7 @@ function didStartLedgegrab(currentAnimation: State, previousAnimation: State): b

function handleActionCompute(state: PlayerActionState, indices: PlayerIndexedType, frame: FrameEntryType): void {
const playerFrame = frame.players[indices.playerIndex]!.post;
const opponentFrame = frame.players[indices.opponentIndex]!.post;
const incrementCount = (field: string, condition: boolean): void => {
if (!condition) {
return;
Expand Down Expand Up @@ -183,9 +185,21 @@ function handleActionCompute(state: PlayerActionState, indices: PlayerIndexedTyp
if (newAnimation) {
const didMissTech = didMissGroundTech(currentAnimation);
incrementCount("groundTechCount.fail", didMissTech);
incrementCount("groundTechCount.forward", currentAnimation === State.FORWARD_TECH);
let opponentDir = 1;
let facingOpponent = false;

if (playerFrame.positionX! > opponentFrame.positionX!) {
opponentDir = -1;
}
if (playerFrame.facingDirection == opponentDir) {
facingOpponent = true;
}

incrementCount("groundTechCount.in", currentAnimation === State.FORWARD_TECH && facingOpponent);
incrementCount("groundTechCount.in", currentAnimation === State.BACKWARD_TECH && !facingOpponent);
incrementCount("groundTechCount.neutral", currentAnimation === State.NEUTRAL_TECH);
incrementCount("groundTechCount.backward", currentAnimation === State.BACKWARD_TECH);
incrementCount("groundTechCount.away", currentAnimation === State.BACKWARD_TECH && facingOpponent);
incrementCount("groundTechCount.away", currentAnimation === State.FORWARD_TECH && !facingOpponent);

incrementCount("wallTechCount.success", currentAnimation === State.WALL_TECH);
incrementCount("wallTechCount.fail", currentAnimation === State.MISSED_WALL_TECH);
Expand Down
5 changes: 3 additions & 2 deletions src/stats/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ export interface ActionCountsType {
down: number;
};
groundTechCount: {
backward: number;
forward: number;
// tech away/in are in reference to the opponents position and not the stage
away: number;
in: number;
neutral: number;
fail: number;
};
Expand Down
8 changes: 6 additions & 2 deletions test/stats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,13 @@ describe("when calculating stats", () => {
});

it("should count techs only a single time", () => {
const game = new SlippiGame("slp/techTest.slp");
const game = new SlippiGame("slp/techTester.slp");
const game2 = new SlippiGame("slp/facingDirection.slp");
const stats = game.getStats();
expect(stats?.actionCounts[1].groundTechCount).toEqual({ backward: 2, forward: 1, neutral: 8, fail: 4 });
const stats2 = game2.getStats();
expect(stats?.actionCounts[0].groundTechCount).toEqual({ in: 4, away: 4, neutral: 4, fail: 4 });
// 3 of these tech aways are not facing the opponent
expect(stats2?.actionCounts[1].groundTechCount).toEqual({ in: 1, away: 4, neutral: 4, fail: 11 });
expect(stats?.actionCounts[1].wallTechCount).toEqual({ success: 0, fail: 0 });
});
});
Expand Down

0 comments on commit 7c690e4

Please sign in to comment.