From 2a5de88380209c0cbcb51a87c0c09fc0693d3f4b Mon Sep 17 00:00:00 2001 From: "maxime.batista" Date: Fri, 1 Mar 2024 18:30:24 +0100 Subject: [PATCH] Apply suggestions --- src/editor/PlayerDomains.ts | 32 +++++++++++++++++++++----------- src/model/tactic/Player.ts | 4 ---- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/editor/PlayerDomains.ts b/src/editor/PlayerDomains.ts index 3168b8d..0473d72 100644 --- a/src/editor/PlayerDomains.ts +++ b/src/editor/PlayerDomains.ts @@ -94,17 +94,27 @@ export function computePhantomPositioning( const segments = action.segments const lastSegment = segments[segments.length - 1] const lastSegmentStart = segments[segments.length - 2]?.next - const pivotPoint = - lastSegment.controlPoint ?? - (lastSegmentStart - ? typeof lastSegmentStart === "string" - ? document - .getElementById(lastSegmentStart)! - .getBoundingClientRect() - : lastSegmentStart - : playerBeforePhantom.type === "phantom" - ? computePhantomPositioning(playerBeforePhantom, content, area) - : playerBeforePhantom.pos) + let pivotPoint = lastSegment.controlPoint + + if (!pivotPoint) { + if (lastSegmentStart) { + pivotPoint = + typeof lastSegmentStart === "string" + ? document + .getElementById(lastSegmentStart)! + .getBoundingClientRect() + : lastSegmentStart + } else { + pivotPoint = + playerBeforePhantom.type === "phantom" + ? computePhantomPositioning( + playerBeforePhantom, + content, + area, + ) + : playerBeforePhantom.pos + } + } const segment = posWithinBase(relativeTo(referentPos, pivotPoint), area) const segmentLength = norm(segment) diff --git a/src/model/tactic/Player.ts b/src/model/tactic/Player.ts index a22eaee..2dee897 100644 --- a/src/model/tactic/Player.ts +++ b/src/model/tactic/Player.ts @@ -10,10 +10,6 @@ export enum PlayerTeam { Opponents = "opponents", } -export interface Player extends PlayerInfo, Component<"player", Pos> { - readonly id: PlayerId -} - /** * All information about a player */