Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grab and various item moves to moves list #86

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added slp/moveTest/id_0.slp
Binary file not shown.
Binary file added slp/moveTest/id_22.slp
Binary file not shown.
Binary file added slp/moveTest/id_23.slp
Binary file not shown.
Binary file added slp/moveTest/id_24.slp
Binary file not shown.
Binary file added slp/moveTest/id_25.slp
Binary file not shown.
Binary file added slp/moveTest/id_26.slp
Binary file not shown.
Binary file added slp/moveTest/id_27.slp
Binary file not shown.
Binary file added slp/moveTest/id_28.slp
Binary file not shown.
Binary file added slp/moveTest/id_29.slp
Binary file not shown.
Binary file added slp/moveTest/id_2_to_21.slp
Binary file not shown.
Binary file added slp/moveTest/id_30.slp
Binary file not shown.
Binary file added slp/moveTest/id_31.slp
Binary file not shown.
Binary file added slp/moveTest/id_32.slp
Binary file not shown.
Binary file added slp/moveTest/id_33.slp
Binary file not shown.
Binary file added slp/moveTest/id_35.slp
Binary file not shown.
Binary file added slp/moveTest/id_36.slp
Binary file not shown.
Binary file added slp/moveTest/id_37.slp
Binary file not shown.
Binary file added slp/moveTest/id_38.slp
Binary file not shown.
Binary file added slp/moveTest/id_39.slp
Binary file not shown.
Binary file added slp/moveTest/id_40.slp
Binary file not shown.
Binary file added slp/moveTest/id_41.slp
Binary file not shown.
Binary file added slp/moveTest/id_42.slp
Binary file not shown.
Binary file added slp/moveTest/id_43.slp
Binary file not shown.
Binary file added slp/moveTest/id_44.slp
Binary file not shown.
Binary file added slp/moveTest/id_45.slp
Binary file not shown.
Binary file added slp/moveTest/id_46.slp
Binary file not shown.
161 changes: 161 additions & 0 deletions src/melee/moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export const UnknownMove: Move = {
};

const moves: { [id: number]: Move } = {
0: {
// This includes Grab, Grab Release, DK Cargo Grab, DK Cargo Grab Release, Barrel Cannon, and various Stage Hazards
id: 0,
name: "Grab",
shortName: "grab",
},
1: {
// This includes all thrown items, zair, luigi's taunt, samus bombs, etc
id: 1,
Expand Down Expand Up @@ -162,6 +168,161 @@ const moves: { [id: number]: Move } = {
name: "Edge Attack",
shortName: "edge",
},
63: {
id: 63,
name: "Beam Sword Jab",
shortName: "beamsword-jab",
},
64: {
id: 64,
name: "Beam Sword Tilt Attack",
shortName: "beamsword-tilt",
},
65: {
id: 65,
name: "Beam Sword Smash Attack",
shortName: "beamsword-smash",
},
66: {
id: 66,
name: "Beam Sword Dash Attack",
shortName: "beamsword-dash",
},
67: {
id: 67,
name: "Home Run Bat Jab",
shortName: "homerun-jab",
},
68: {
id: 68,
name: "Home Run Bat Tilt Attack",
shortName: "homerun-tilt",
},
69: {
id: 69,
name: "Home Run Bat Smash Attack",
shortName: "homerun-smash",
},
70: {
id: 70,
name: "Home Run Bat Dash Attack",
shortName: "homerun-dash",
},
71: {
id: 71,
name: "Parasol Jab",
shortName: "parasol-jab",
},
72: {
id: 72,
name: "Parasol Tilt Attack",
shortName: "parasol-tilt",
},
73: {
id: 73,
name: "Parasol Smash Attack",
shortName: "parasol-smash",
},
74: {
id: 74,
name: "Parasol Dash Attack",
shortName: "parasol-dash",
},
75: {
id: 75,
name: "Fan Jab",
shortName: "fan-jab",
},
76: {
id: 76,
name: "Fan Tilt Attack",
shortName: "fan-tilt",
},
77: {
id: 77,
name: "Fan Smash Attack",
shortName: "fan-smash",
},
78: {
id: 78,
name: "Fan Dash Attack",
shortName: "fan-dash",
},
79: {
id: 79,
name: "Star Rod Jab",
shortName: "starrod-jab",
},
80: {
id: 80,
name: "Star Rod Tilt Attack",
shortName: "starrod-tilt",
},
81: {
id: 81,
name: "Star Rod Smash Attack",
shortName: "starrod-smash",
},
82: {
id: 82,
name: "Star Rod Dash Attack",
shortName: "starrod-dash",
},
83: {
id: 83,
name: "Lip's Stick Jab",
shortName: "lipsstick-jab",
},
84: {
id: 84,
name: "Lip's Stick Tilt Attack",
shortName: "lipsstick-tilt",
},
85: {
id: 85,
name: "Lip's Stick Smash Attack",
shortName: "lipsstick-smash",
},
86: {
id: 86,
name: "Lip's Stick Dash Attack",
shortName: "lipsstick-dash",
},
87: {
id: 87,
name: "Open Parasol",
shortName: "open-parasol",
},
88: {
id: 88,
name: "Ray Gun Shoot",
shortName: "raygun-shoot",
},
89: {
id: 89,
name: "Fire Flower Shoot",
shortName: "fireflower-shoot",
},
90: {
id: 90,
name: "Screw Attack",
shortName: "screw-attack",
},
91: {
id: 91,
name: "Super Scope (Rapid)",
shortName: "super-scope-rapid",
},
92: {
id: 92,
name: "Super Scope (Charged)",
shortName: "super-scope-charged",
},
93: {
id: 93,
name: "Hammer",
shortName: "hammer",
},
};

export function getMoveInfo(moveId: number): Move {
Expand Down
12 changes: 12 additions & 0 deletions src/stats/combos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ function handleComboCompute(
lastHitBy: indices.playerIndex,
};

if (opntIsGrabbed || opntIsCommandGrabbed) {
const grabMove = {
playerIndex: indices.playerIndex,
frame: currentFrameNumber,
moveId: 0,
hitCount: 0,
damage: 0,
};

state.combo.moves.push(grabMove);
}

combos.push(state.combo);

// Track whether this is a new combo or not
Expand Down
12 changes: 12 additions & 0 deletions src/stats/conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ function handleConversionCompute(
damage: 0,
};

if (opntIsGrabbed || opntIsCommandGrabbed) {
const grabMove = {
playerIndex: indices.playerIndex,
frame: currentFrameNumber,
moveId: 0,
hitCount: 0,
damage: 0,
};

state.conversion.moves.push(grabMove);
}

state.conversion.moves.push(state.move);
}

Expand Down
2 changes: 1 addition & 1 deletion test/melee.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("when fetching move information", () => {
});

it("should handle unknown moves", () => {
expect(Melee.moves.getMoveInfo(69)).toEqual(unknownMove);
expect(Melee.moves.getMoveInfo(-1)).toEqual(unknownMove);
expect(Melee.moves.UnknownMove).toEqual(unknownMove);
});

Expand Down
177 changes: 177 additions & 0 deletions test/moves.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import { log } from "console";
import { getMoveName } from "../src/melee/moves";
import { SlippiGame } from "../src/SlippiGame";

describe("when calculating stats", () => {
it("the correct move ids should be determined", () => {
let game = new SlippiGame("slp/moveTest/id_0.slp");
let stats = game.getStats();

stats?.conversions.forEach((c) => {
c.moves.forEach((m) => {
expect(m.moveId).toEqual(0);
});
});

let moveIdCounter = 2;
game = new SlippiGame("slp/moveTest/id_2_to_21.slp");
stats = game.getStats();

stats?.conversions.forEach((c) => {
c.moves.forEach((m) => {
expect(m.moveId).toEqual(moveIdCounter);
moveIdCounter++;
});
});

// Kirby-Mario
game = new SlippiGame("slp/moveTest/id_22.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Lasers cause no hitstun and do not register as combo or conversion starters
// As such, this test case should be adjusted to not rely on those
// Kirby-Fox
game = new SlippiGame("slp/moveTest/id_23.slp");
stats = game.getStats();
//expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-CaptainFalcon
game = new SlippiGame("slp/moveTest/id_24.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-DK
game = new SlippiGame("slp/moveTest/id_25.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Bowser
game = new SlippiGame("slp/moveTest/id_26.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Link
game = new SlippiGame("slp/moveTest/id_27.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Sheik
game = new SlippiGame("slp/moveTest/id_28.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Ness
game = new SlippiGame("slp/moveTest/id_29.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Peach
game = new SlippiGame("slp/moveTest/id_30.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-IceClimbers
game = new SlippiGame("slp/moveTest/id_31.slp");
stats = game.getStats();
expect(stats?.conversions[0].moves[0].moveId).toEqual(moveIdCounter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(stats?.conversions[0].moves[0].moveId).toEqual(moveIdCounter);
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);

@cnkeats This should be conversion 1, this is currently using Kirby's neutral B.

moveIdCounter++;

// Kirby-Pikachu
game = new SlippiGame("slp/moveTest/id_32.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Samus
game = new SlippiGame("slp/moveTest/id_33.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Yoshi
// Unused - Kirby-Yoshi's Neutral Special's id is the same as a normal Neutral Special (18)
moveIdCounter++;

// Kirby-Jigglypuff
game = new SlippiGame("slp/moveTest/id_35.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Mewtwo
game = new SlippiGame("slp/moveTest/id_36.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Luigi
game = new SlippiGame("slp/moveTest/id_37.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Marth
game = new SlippiGame("slp/moveTest/id_38.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Zelda
game = new SlippiGame("slp/moveTest/id_39.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-YoungLink
game = new SlippiGame("slp/moveTest/id_40.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-DrMario
game = new SlippiGame("slp/moveTest/id_41.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Falco
game = new SlippiGame("slp/moveTest/id_42.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Pichu
game = new SlippiGame("slp/moveTest/id_43.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Game&Watch
game = new SlippiGame("slp/moveTest/id_44.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Ganondorf
game = new SlippiGame("slp/moveTest/id_45.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;

// Kirby-Roy
game = new SlippiGame("slp/moveTest/id_46.slp");
stats = game.getStats();
expect(stats?.conversions[1].moves[0].moveId).toEqual(moveIdCounter);
moveIdCounter++;
});
});