Skip to content

Commit

Permalink
Clean up tempeteuos tear
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterGerrard committed Aug 5, 2024
1 parent ec7fd68 commit 631435c
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 145 deletions.
16 changes: 15 additions & 1 deletion src/aac/lhw/m1s/Clones.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getRandomPos,
getRole,
} from "../../../gamestate/gameState";
import { pickOne, shuffle } from "../../../gamestate/helpers";
import { useMechanic } from "../../../gamestate/mechanics";
import { Player } from "../../../gamestate/Player";
import { useFullPartyProfile } from "../../../gamestate/Setup/ProfileContext";
Expand All @@ -15,7 +16,20 @@ export const BlackCatClones = () => {
useTitle("Clone Shenanigans");

const [mechanic, players, restart, moveTo] = useMechanic(
shenanigans1Jump,
() => {
const storeLocs = shuffle(["North", "South"] as const);
return shenanigans1Jump(
{
jumpSide: pickOne(["Left", "Right"] as const),
swipeSide: pickOne(["Left", "Right"] as const),
storeLocation: storeLocs[0],
},
{
jumpSide: pickOne(["Left", "Right"] as const),
storeLocation: storeLocs[1],
}
);
},
() =>
Designations.map<Player>((d) => ({
alive: true,
Expand Down
5 changes: 5 additions & 0 deletions src/aac/lhw/m1s/getJumpLocation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Point } from "@flatten-js/core";

export const getJumpLocation = (position: Point, rotation: number, jumpSide: "Left" | "Right") => position
.translate(0, jumpSide === "Left" ? -0.25 : 0.25)
.rotate((Math.PI * rotation) / 180, position);
15 changes: 8 additions & 7 deletions src/aac/lhw/m1s/jumpingOneTwoPaw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Mechanic,
repeat,
sequence,
sequence2,
withSafeSpot,
ZeroDamage,
} from "../../../gamestate/mechanics";
Expand Down Expand Up @@ -36,12 +37,12 @@ export const jumpingOneTwoPaw = (
position: Point,
rotation: number,
character: (position: Point, rotation: number) => React.ReactElement,
nextMechanic: (finalPosition: Point) => Mechanic<Player>,
nextMechanic: (finalPosition: Point) => Mechanic<Player> | null,
instant?: boolean
): Mechanic<Player> => {
const rot = rotation + (side === "Left" ? 0 : 180);
const jumpLocation = position
.translate(0, jumpSide === "Left" ? -0.25 : 0.25)
.translate(0, jumpSide === "Left" ? 0.25 : -0.25)
.rotate((Math.PI * rotation) / 180, position);
if (instant) {
return oneTwoPawHit1(side, jumpLocation, rotation, character, nextMechanic);
Expand Down Expand Up @@ -92,7 +93,7 @@ const oneTwoPawHit1 = (
position: Point,
rotation: number,
character: (position: Point, rotation: number) => React.ReactElement,
nextMechanic: (finalPosition: Point) => Mechanic<Player>
nextMechanic: (finalPosition: Point) => Mechanic<Player> | null
): Mechanic<Player> => {
const rot = rotation + (side === "Left" ? 0 : 180);
return composeMechanics([
Expand Down Expand Up @@ -120,10 +121,10 @@ const oneTwoPawHit2 = (
position: Point,
rotation: number,
character: (position: Point, rotation: number) => React.ReactElement,
nextMechanic: (finalPosition: Point) => Mechanic<Player>
nextMechanic: (finalPosition: Point) => Mechanic<Player> | null
): Mechanic<Player> => {
const rot = rotation + (side === "Left" ? 0 : 180);
return sequence([
return sequence2(
composeMechanics([
sequence([
automatic(
Expand All @@ -150,6 +151,6 @@ const oneTwoPawHit2 = (
]),
repeat(finalPositionMechanic(position, rotation, character), 2),
]),
nextMechanic(position),
]);
() => nextMechanic(position)
);
};
30 changes: 9 additions & 21 deletions src/aac/lhw/m1s/jumpingQuadrupleCrossing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import jumpLocPng from "./JumpLocation.png";
import { Tether } from "../../../components/standard-mechanic-elements/Tether";
import { Designation, distanceTo, isDps } from "../../../gamestate/gameState";
import { coneMechanic } from "../../../gamestate/Mechanics/ConeAoE";
import { getJumpLocation } from "./getJumpLocation";

const trueNorthVector = (d: Designation) => {
switch (d) {
Expand Down Expand Up @@ -102,12 +103,9 @@ export const jumpingQuadrupleCrossing = (
jumpSide: "Left" | "Right",
position: Point,
rotation: number,
character: (position: Point, rotation: number) => React.ReactElement,
nextMechanic: (finalPosition: Point) => Mechanic<Player>
character: (position: Point, rotation: number) => React.ReactElement
): Mechanic<Player> => {
const jumpLocation = position
.translate(0, jumpSide === "Left" ? -0.25 : 0.25)
.rotate((Math.PI * rotation) / 180, position);
const jumpLocation = getJumpLocation(position, rotation, jumpSide);
return {
applyDamage: () => ZeroDamage,
display: () => (
Expand Down Expand Up @@ -141,7 +139,6 @@ export const jumpingQuadrupleCrossing = (
jumpLocation,
rotation,
character,
nextMechanic,
ps
),
ps,
Expand All @@ -154,7 +151,6 @@ const jumpingQuadrupleCrossingBait1 = (
position: Point,
rotation: number,
character: (position: Point, rotation: number) => React.ReactElement,
nextMechanic: (finalPosition: Point) => Mechanic<Player>,
players: Player[]
): Mechanic<Player> => {
const angles = players
Expand Down Expand Up @@ -185,7 +181,6 @@ const jumpingQuadrupleCrossingBait1 = (
position,
rotation,
character,
nextMechanic,
ps,
angles
)
Expand All @@ -197,7 +192,6 @@ const jumpingQuadrupleCrossingBait2 = (
position: Point,
rotation: number,
character: (position: Point, rotation: number) => React.ReactElement,
nextMechanic: (finalPosition: Point) => Mechanic<Player>,
players: Player[],
bait1: number[]
): Mechanic<Player> => {
Expand All @@ -222,14 +216,10 @@ const jumpingQuadrupleCrossingBait2 = (
}
),
(_) =>
jumpingQuadrupleCrossingRehits(
jumpSide,
position,
rotation,
character,
nextMechanic,
[bait1, angles]
)
jumpingQuadrupleCrossingRehits(jumpSide, position, rotation, character, [
bait1,
angles,
])
);
};

Expand All @@ -238,7 +228,6 @@ const jumpingQuadrupleCrossingRehits = (
position: Point,
rotation: number,
character: (position: Point, rotation: number) => React.ReactElement,
nextMechanic: (finalPosition: Point) => Mechanic<Player>,
baits: number[][]
) => {
const [b, ...rest] = baits;
Expand All @@ -255,16 +244,15 @@ const jumpingQuadrupleCrossingRehits = (
return position.translate(offset);
}
),
(): Mechanic<Player> =>
(): Mechanic<Player> | null =>
rest.length > 0
? jumpingQuadrupleCrossingRehits(
jumpSide,
position,
rotation,
character,
nextMechanic,
rest
)
: nextMechanic(position)
: null
);
};
23 changes: 15 additions & 8 deletions src/aac/lhw/m1s/shenanigans/jump1.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { point } from "@flatten-js/core";
import { jumpingOneTwoPaw } from "../jumpingOneTwoPaw";
import { pickOne } from "../../../../gamestate/helpers";
import { BlackCat } from "../boss/BlackCat";
import { shenanigansStore1 } from "./store1";

export const shenanigans1Jump = () => {
const side = pickOne(["Left", "Right"] as const);
const jumpSide = pickOne(["Left", "Right"] as const);

export const shenanigans1Jump = (
jump1: {
jumpSide: "Left" | "Right";
swipeSide: "Left" | "Right";
storeLocation: "North" | "South";
},
jump2: {
jumpSide: "Left" | "Right";
storeLocation: "North" | "South";
}
) => {
return jumpingOneTwoPaw(
jumpSide,
side,
jump1.jumpSide,
jump1.swipeSide,
point(0.5, 0.5),
90,
(pos, rot) => <BlackCat position={pos} rotation={rot} />,
(p) => shenanigansStore1(jumpSide, side, p)
(p) =>
shenanigansStore1(jump1.jumpSide, jump1.swipeSide, jump1.storeLocation, p, jump2)
);
};
48 changes: 27 additions & 21 deletions src/aac/lhw/m1s/shenanigans/jump2.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Point } from "@flatten-js/core";
import { pickOne } from "../../../../gamestate/helpers";
import {
composeMechanics,
displayOnlyMechanic,
Mechanic,
ZeroDamage,
sequence2,
withBackgroundMechanic,
} from "../../../../gamestate/mechanics";
import { Player } from "../../../../gamestate/Player";
import { BlackCat } from "../boss/BlackCat";
import { BlackCatClone } from "../clone/BlackCatClone";
import { jumpingQuadrupleCrossing } from "../jumpingQuadrupleCrossing";
import { shenanigansStore2 } from "./store2";
import { getJumpLocation } from "../getJumpLocation";

export const shenanigansJump2 = (
store1: {
Expand All @@ -18,26 +19,31 @@ export const shenanigansJump2 = (
jumpSide: "Left" | "Right";
side: "Left" | "Right";
},
bossPosition: Point
bossPosition: Point,
jump2: {
jumpSide: "Left" | "Right";
storeLocation: "North" | "South";
}
): Mechanic<Player> => {
const jumpLoc = pickOne(["Left", "Right"] as const);
const bossRot = store1.jumpSide === "Left" ? 180 : 0;

return composeMechanics([
jumpingQuadrupleCrossing(
jumpLoc,
bossPosition,
bossRot,
(p, r) => <BlackCat position={p} rotation={r} />,
(p) => shenanigansStore2(jumpLoc, p, store1)
),
{
applyDamage: () => ZeroDamage,
display: () => (
<BlackCatClone position={store1.position} rotation={store1.rotation} />
return sequence2(
withBackgroundMechanic(
jumpingQuadrupleCrossing(
jump2.jumpSide,
bossPosition,
bossRot,
(p, r) => <BlackCat position={p} rotation={r} />
),
getSafeSpot: () => null,
progress: (ps) => [null, ps],
},
]);
displayOnlyMechanic(() => (
<BlackCatClone position={store1.position} rotation={store1.rotation} />
))
),
() =>
shenanigansStore2(
jump2.jumpSide,
getJumpLocation(bossPosition, bossRot, jump2.jumpSide),
store1
)
);
};
16 changes: 10 additions & 6 deletions src/aac/lhw/m1s/shenanigans/store1.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Point, point } from "@flatten-js/core";
import { pickOne } from "../../../../gamestate/helpers";
import { BlackCat } from "../boss/BlackCat";
import { Mechanic, ZeroDamage } from "../../../../gamestate/mechanics";
import { Player } from "../../../../gamestate/Player";
Expand All @@ -10,11 +9,15 @@ import { shenanigansJump2 } from "./jump2";
export const shenanigansStore1 = (
jumpSide: "Left" | "Right",
side: "Left" | "Right",
bossPosition: Point
storeLocation: "North" | "South",
bossPosition: Point,
jump2: {
jumpSide: "Left" | "Right";
storeLocation: "North" | "South";
}
): Mechanic<Player> => {
const storeClone = pickOne(["North", "South"] as const);
const cloneLoc = point(0.5, storeClone === "North" ? 0.375 : 0.625);
const cloneRot = storeClone === "North" ? 270 : 90;
const cloneLoc = point(0.5, storeLocation === "North" ? 0.375 : 0.625);
const cloneRot = storeLocation === "North" ? 270 : 90;

return {
applyDamage: () => ZeroDamage,
Expand All @@ -39,7 +42,8 @@ export const shenanigansStore1 = (
rotation: cloneRot,
side: side,
},
bossPosition
bossPosition,
jump2
),
ps,
],
Expand Down
13 changes: 10 additions & 3 deletions src/aac/lhw/m1s/shenanigans/store2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Mechanic, ZeroDamage } from "../../../../gamestate/mechanics";
import { Player } from "../../../../gamestate/Player";
import { BlackCatClone } from "../clone/BlackCatClone";
import { Tether } from "../../../../components/standard-mechanic-elements/Tether";
import { tempetuosTear1 } from "./tempetuousTear";
import { tempetuosTear } from "./tempetuousTear";

export const shenanigansStore2 = (
_jumpSide: "Left" | "Right",
jumpSide: "Left" | "Right",
bossPosition: Point,
store1: {
position: Point;
Expand Down Expand Up @@ -35,6 +35,13 @@ export const shenanigansStore2 = (
</>
),
getSafeSpot: () => null,
progress: (ps) => [tempetuosTear1(store1), ps],
progress: (ps) => [
tempetuosTear(store1, {
position: cloneLoc,
rotation: cloneRot,
jumpSide: jumpSide,
}),
ps,
],
};
};
Loading

0 comments on commit 631435c

Please sign in to comment.