From 631435ca8d4674e9ff649e7342123c3c7c5ff9ec Mon Sep 17 00:00:00 2001 From: Jess Law <32jezza@gmail.com> Date: Tue, 6 Aug 2024 00:17:52 +0100 Subject: [PATCH] Clean up tempeteuos tear --- src/aac/lhw/m1s/Clones.tsx | 16 +- src/aac/lhw/m1s/getJumpLocation.ts | 5 + src/aac/lhw/m1s/jumpingOneTwoPaw.tsx | 15 +- src/aac/lhw/m1s/jumpingQuadrupleCrossing.tsx | 30 +--- src/aac/lhw/m1s/shenanigans/jump1.tsx | 23 ++- src/aac/lhw/m1s/shenanigans/jump2.tsx | 48 +++--- src/aac/lhw/m1s/shenanigans/store1.tsx | 16 +- src/aac/lhw/m1s/shenanigans/store2.tsx | 13 +- .../lhw/m1s/shenanigans/tempetuousTear.tsx | 162 ++++++++++-------- src/gamestate/mechanics.tsx | 54 +++++- 10 files changed, 237 insertions(+), 145 deletions(-) create mode 100644 src/aac/lhw/m1s/getJumpLocation.ts diff --git a/src/aac/lhw/m1s/Clones.tsx b/src/aac/lhw/m1s/Clones.tsx index 9ff04be..3c6d66c 100644 --- a/src/aac/lhw/m1s/Clones.tsx +++ b/src/aac/lhw/m1s/Clones.tsx @@ -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"; @@ -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((d) => ({ alive: true, diff --git a/src/aac/lhw/m1s/getJumpLocation.ts b/src/aac/lhw/m1s/getJumpLocation.ts new file mode 100644 index 0000000..0984334 --- /dev/null +++ b/src/aac/lhw/m1s/getJumpLocation.ts @@ -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); \ No newline at end of file diff --git a/src/aac/lhw/m1s/jumpingOneTwoPaw.tsx b/src/aac/lhw/m1s/jumpingOneTwoPaw.tsx index 055518b..1c6a05f 100644 --- a/src/aac/lhw/m1s/jumpingOneTwoPaw.tsx +++ b/src/aac/lhw/m1s/jumpingOneTwoPaw.tsx @@ -5,6 +5,7 @@ import { Mechanic, repeat, sequence, + sequence2, withSafeSpot, ZeroDamage, } from "../../../gamestate/mechanics"; @@ -36,12 +37,12 @@ export const jumpingOneTwoPaw = ( position: Point, rotation: number, character: (position: Point, rotation: number) => React.ReactElement, - nextMechanic: (finalPosition: Point) => Mechanic, + nextMechanic: (finalPosition: Point) => Mechanic | null, instant?: boolean ): Mechanic => { 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); @@ -92,7 +93,7 @@ const oneTwoPawHit1 = ( position: Point, rotation: number, character: (position: Point, rotation: number) => React.ReactElement, - nextMechanic: (finalPosition: Point) => Mechanic + nextMechanic: (finalPosition: Point) => Mechanic | null ): Mechanic => { const rot = rotation + (side === "Left" ? 0 : 180); return composeMechanics([ @@ -120,10 +121,10 @@ const oneTwoPawHit2 = ( position: Point, rotation: number, character: (position: Point, rotation: number) => React.ReactElement, - nextMechanic: (finalPosition: Point) => Mechanic + nextMechanic: (finalPosition: Point) => Mechanic | null ): Mechanic => { const rot = rotation + (side === "Left" ? 0 : 180); - return sequence([ + return sequence2( composeMechanics([ sequence([ automatic( @@ -150,6 +151,6 @@ const oneTwoPawHit2 = ( ]), repeat(finalPositionMechanic(position, rotation, character), 2), ]), - nextMechanic(position), - ]); + () => nextMechanic(position) + ); }; diff --git a/src/aac/lhw/m1s/jumpingQuadrupleCrossing.tsx b/src/aac/lhw/m1s/jumpingQuadrupleCrossing.tsx index dd7d16f..3cfecc7 100644 --- a/src/aac/lhw/m1s/jumpingQuadrupleCrossing.tsx +++ b/src/aac/lhw/m1s/jumpingQuadrupleCrossing.tsx @@ -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) { @@ -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 + character: (position: Point, rotation: number) => React.ReactElement ): Mechanic => { - 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: () => ( @@ -141,7 +139,6 @@ export const jumpingQuadrupleCrossing = ( jumpLocation, rotation, character, - nextMechanic, ps ), ps, @@ -154,7 +151,6 @@ const jumpingQuadrupleCrossingBait1 = ( position: Point, rotation: number, character: (position: Point, rotation: number) => React.ReactElement, - nextMechanic: (finalPosition: Point) => Mechanic, players: Player[] ): Mechanic => { const angles = players @@ -185,7 +181,6 @@ const jumpingQuadrupleCrossingBait1 = ( position, rotation, character, - nextMechanic, ps, angles ) @@ -197,7 +192,6 @@ const jumpingQuadrupleCrossingBait2 = ( position: Point, rotation: number, character: (position: Point, rotation: number) => React.ReactElement, - nextMechanic: (finalPosition: Point) => Mechanic, players: Player[], bait1: number[] ): Mechanic => { @@ -222,14 +216,10 @@ const jumpingQuadrupleCrossingBait2 = ( } ), (_) => - jumpingQuadrupleCrossingRehits( - jumpSide, - position, - rotation, - character, - nextMechanic, - [bait1, angles] - ) + jumpingQuadrupleCrossingRehits(jumpSide, position, rotation, character, [ + bait1, + angles, + ]) ); }; @@ -238,7 +228,6 @@ const jumpingQuadrupleCrossingRehits = ( position: Point, rotation: number, character: (position: Point, rotation: number) => React.ReactElement, - nextMechanic: (finalPosition: Point) => Mechanic, baits: number[][] ) => { const [b, ...rest] = baits; @@ -255,16 +244,15 @@ const jumpingQuadrupleCrossingRehits = ( return position.translate(offset); } ), - (): Mechanic => + (): Mechanic | null => rest.length > 0 ? jumpingQuadrupleCrossingRehits( jumpSide, position, rotation, character, - nextMechanic, rest ) - : nextMechanic(position) + : null ); }; diff --git a/src/aac/lhw/m1s/shenanigans/jump1.tsx b/src/aac/lhw/m1s/shenanigans/jump1.tsx index b1727f4..aca93b9 100644 --- a/src/aac/lhw/m1s/shenanigans/jump1.tsx +++ b/src/aac/lhw/m1s/shenanigans/jump1.tsx @@ -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) => , - (p) => shenanigansStore1(jumpSide, side, p) + (p) => + shenanigansStore1(jump1.jumpSide, jump1.swipeSide, jump1.storeLocation, p, jump2) ); }; diff --git a/src/aac/lhw/m1s/shenanigans/jump2.tsx b/src/aac/lhw/m1s/shenanigans/jump2.tsx index c312fba..769b193 100644 --- a/src/aac/lhw/m1s/shenanigans/jump2.tsx +++ b/src/aac/lhw/m1s/shenanigans/jump2.tsx @@ -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: { @@ -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 => { - const jumpLoc = pickOne(["Left", "Right"] as const); const bossRot = store1.jumpSide === "Left" ? 180 : 0; - return composeMechanics([ - jumpingQuadrupleCrossing( - jumpLoc, - bossPosition, - bossRot, - (p, r) => , - (p) => shenanigansStore2(jumpLoc, p, store1) - ), - { - applyDamage: () => ZeroDamage, - display: () => ( - + return sequence2( + withBackgroundMechanic( + jumpingQuadrupleCrossing( + jump2.jumpSide, + bossPosition, + bossRot, + (p, r) => ), - getSafeSpot: () => null, - progress: (ps) => [null, ps], - }, - ]); + displayOnlyMechanic(() => ( + + )) + ), + () => + shenanigansStore2( + jump2.jumpSide, + getJumpLocation(bossPosition, bossRot, jump2.jumpSide), + store1 + ) + ); }; diff --git a/src/aac/lhw/m1s/shenanigans/store1.tsx b/src/aac/lhw/m1s/shenanigans/store1.tsx index 7c492f7..5346cd1 100644 --- a/src/aac/lhw/m1s/shenanigans/store1.tsx +++ b/src/aac/lhw/m1s/shenanigans/store1.tsx @@ -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"; @@ -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 => { - 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, @@ -39,7 +42,8 @@ export const shenanigansStore1 = ( rotation: cloneRot, side: side, }, - bossPosition + bossPosition, + jump2 ), ps, ], diff --git a/src/aac/lhw/m1s/shenanigans/store2.tsx b/src/aac/lhw/m1s/shenanigans/store2.tsx index 0ff91a1..285960b 100644 --- a/src/aac/lhw/m1s/shenanigans/store2.tsx +++ b/src/aac/lhw/m1s/shenanigans/store2.tsx @@ -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; @@ -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, + ], }; }; diff --git a/src/aac/lhw/m1s/shenanigans/tempetuousTear.tsx b/src/aac/lhw/m1s/shenanigans/tempetuousTear.tsx index a0c888e..955ae7b 100644 --- a/src/aac/lhw/m1s/shenanigans/tempetuousTear.tsx +++ b/src/aac/lhw/m1s/shenanigans/tempetuousTear.tsx @@ -2,10 +2,10 @@ import { Point, point, vector } from "@flatten-js/core"; import { jumpingOneTwoPaw } from "../jumpingOneTwoPaw"; import { BlackCat } from "../boss/BlackCat"; import { + automatic, composeMechanics, - emptyMechanic, Mechanic, - sequence, + withBackgroundMechanic, ZeroDamage, } from "../../../../gamestate/mechanics"; import { BlackCatClone } from "../clone/BlackCatClone"; @@ -14,12 +14,19 @@ import { Tether } from "../../../../components/standard-mechanic-elements/Tether import { Player } from "../../../../gamestate/Player"; import { lineMechanic } from "../../../../gamestate/Mechanics/LineAoE"; -export const tempetuosTear1 = (store1: { - position: Point; - rotation: number; - jumpSide: "Left" | "Right"; - side: "Left" | "Right"; -}) => { +export const tempetuosTear = ( + store1: { + position: Point; + rotation: number; + jumpSide: "Left" | "Right"; + side: "Left" | "Right"; + }, + store2?: { + position: Point; + rotation: number; + jumpSide: "Left" | "Right"; + } +): Mechanic => { const bossLoc = point( (store1.jumpSide === "Left" && store1.position.y > 0.5) || (store1.jumpSide !== "Left" && store1.position.y < 0.5) @@ -27,81 +34,84 @@ export const tempetuosTear1 = (store1: { : 0.75, 0.5 ); + console.log({ store1, bossLoc }); const safeCol = - (store1.rotation < 180 && store1.side === "Left") || - (store1.rotation > 180 && store1.side === "Right") + (store1.rotation < 180 && store1.side === "Right") || + (store1.rotation > 180 && store1.side === "Left") ? bossLoc.x - 0.1 : bossLoc.x + 0.1; - return sequence([ - { - applyDamage: () => ZeroDamage, - display: () => ( - <> - + return { + applyDamage: () => ZeroDamage, + display: () => ( + <> + + + {store2 && ( - - - ), - getSafeSpot: (_ps, p) => - point(safeCol, getGroup(p.designation) === "Group1" ? 0.4 : 0.6), - progress: (ps) => [ - composeMechanics( - ps + )} + + + ), + getSafeSpot: (_ps, p) => + point(safeCol, getGroup(p.designation) === "Group1" ? 0.4 : 0.6), + progress: (ps) => [ + withBackgroundMechanic( + composeMechanics([ + ...ps .filter((p) => getRole(p.designation) === "Healer") .map>((p) => - lineMechanic( - bossLoc, - vector(0, 1).angleTo(vector(bossLoc, p.position)), - 0.1, - { - damage: 3.5, - debuffRequirement: null, - instaKill: null, - roleRequirement: null, - split: true, - } + automatic( + lineMechanic( + bossLoc, + vector(0, 1).angleTo(vector(bossLoc, p.position)), + 0.1, + { + damage: 3.5, + debuffRequirement: null, + instaKill: null, + roleRequirement: null, + split: true, + } + ), + 1500 ) - ) - ), - ps, - ], - }, - composeMechanics([ - { - applyDamage: () => ZeroDamage, - display: () => ( - 0.5) || - (store1.jumpSide !== "Left" && store1.position.y < 0.5) - ? 0.25 - : 0.75, - 0.5 - )} - rotation={90} - /> - ), - getSafeSpot: (_ps, p) => - point(safeCol, getGroup(p.designation) === "Group1" ? 0.4 : 0.6), - progress: (ps) => [null, ps], - }, - jumpingOneTwoPaw( - store1.jumpSide, - store1.side, - store1.position, - store1.rotation, - (pos, rot) => , - emptyMechanic, - true + ), + jumpingOneTwoPaw( + store1.jumpSide, + store1.side, + store1.position, + store1.rotation, + (p, r) => , + () => null, + true + ), + ]), + { + applyDamage: () => ZeroDamage, + display: () => ( + <> + + {store2 && ( + + )} + + ), + getSafeSpot: () => null, + progress: (ps) => [null, ps], + } ), - ]), - ]); + ps, + ], + }; }; diff --git a/src/gamestate/mechanics.tsx b/src/gamestate/mechanics.tsx index ef7aa6a..fd2ab72 100644 --- a/src/gamestate/mechanics.tsx +++ b/src/gamestate/mechanics.tsx @@ -1,6 +1,6 @@ import { Point, point } from "@flatten-js/core"; import { Designation } from "./gameState"; -import { Fragment, useCallback, useEffect, useState } from "react"; +import React, { Fragment, useCallback, useEffect, useState } from "react"; import { Debuff, LightPlayer, Player } from "./Player"; export type Mechanic = { @@ -180,7 +180,7 @@ export const sequence = ( export const sequence2 = ( mechanic1: Mechanic, - mechanic2: (ps: TPlayer[]) => Mechanic + mechanic2: (ps: TPlayer[]) => Mechanic | null ): Mechanic => { return { ...mechanic1, @@ -262,6 +262,56 @@ export const composeMechanics = ( }; }; +export const withBackgroundMechanic = ( + mainMechanic: Mechanic, + backgroundMechanic: Mechanic +): Mechanic => { + return { + applyDamage: (players) => { + const d1 = mainMechanic.applyDamage(players); + const d2 = backgroundMechanic.applyDamage(players); + return { + H1: d1.H1 + d2.H1, + H2: d1.H2 + d2.H2, + R1: d1.R1 + d2.R1, + R2: d1.R2 + d2.R2, + M1: d1.M1 + d2.M1, + M2: d1.M2 + d2.M2, + MT: d1.MT + d2.MT, + OT: d1.OT + d2.OT, + }; + }, + getSafeSpot: mainMechanic.getSafeSpot, + autoProgress: mainMechanic.autoProgress, + progress: (ps) => { + let players = ps; + const [nm, nextPs] = mainMechanic.progress(players); + players = nextPs; + if (nm === null) { + return [null, players]; + } + return [withBackgroundMechanic(nm, backgroundMechanic), players]; + }, + display: (ps, disableAnimation) => ( + <> + {backgroundMechanic.display(ps, disableAnimation)} + {mainMechanic.display(ps, disableAnimation)} + + ), + }; +}; + +export const displayOnlyMechanic = ( + display: () => React.ReactElement +): Mechanic => { + return { + applyDamage: () => ZeroDamage, + getSafeSpot: () => null, + progress: (ps) => [null, ps], + display: display, + }; +}; + export const FinishedMechanic: Mechanic = { applyDamage: () => ZeroDamage, display: () => (