|
|
@ -1,34 +1,13 @@
|
|
|
|
import { equals, Pos, ratioWithinBase } from "../geo/Pos"
|
|
|
|
import { equals, Pos, ratioWithinBase } from "../geo/Pos"
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
import { BallState, Player, PlayerInfo, PlayerLike, PlayerPhantom, PlayerTeam } from "../model/tactic/Player"
|
|
|
|
BallState,
|
|
|
|
import { Ball, BALL_ID, BALL_TYPE, CourtObject } from "../model/tactic/CourtObjects"
|
|
|
|
Player,
|
|
|
|
import { ComponentId, StepContent, TacticComponent } from "../model/tactic/Tactic"
|
|
|
|
PlayerInfo,
|
|
|
|
|
|
|
|
PlayerLike,
|
|
|
|
|
|
|
|
PlayerPhantom,
|
|
|
|
|
|
|
|
PlayerTeam,
|
|
|
|
|
|
|
|
} from "../model/tactic/Player"
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
Ball,
|
|
|
|
|
|
|
|
BALL_ID,
|
|
|
|
|
|
|
|
BALL_TYPE,
|
|
|
|
|
|
|
|
CourtObject,
|
|
|
|
|
|
|
|
} from "../model/tactic/CourtObjects"
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
ComponentId,
|
|
|
|
|
|
|
|
StepContent,
|
|
|
|
|
|
|
|
TacticComponent,
|
|
|
|
|
|
|
|
} from "../model/tactic/Tactic"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { overlaps } from "../geo/Box"
|
|
|
|
import { overlaps } from "../geo/Box"
|
|
|
|
import { RackedCourtObject, RackedPlayer } from "./RackedItems"
|
|
|
|
import { RackedCourtObject, RackedPlayer } from "./RackedItems"
|
|
|
|
import {
|
|
|
|
import { getComponent, getOrigin, getPrecomputedPosition, tryGetComponent } from "./PlayerDomains"
|
|
|
|
getComponent,
|
|
|
|
import { Action, ActionKind } from "../model/tactic/Action.ts"
|
|
|
|
getOrigin,
|
|
|
|
|
|
|
|
getPrecomputedPosition,
|
|
|
|
|
|
|
|
tryGetComponent,
|
|
|
|
|
|
|
|
} from "./PlayerDomains"
|
|
|
|
|
|
|
|
import { ActionKind } from "../model/tactic/Action.ts"
|
|
|
|
|
|
|
|
import { spreadNewStateFromOriginStateChange } from "./ActionsDomains.ts"
|
|
|
|
import { spreadNewStateFromOriginStateChange } from "./ActionsDomains.ts"
|
|
|
|
|
|
|
|
|
|
|
|
export function placePlayerAt(
|
|
|
|
export function placePlayerAt(
|
|
|
@ -474,14 +453,9 @@ export function drainTerminalStateOnChildContent(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function mapToParentContent(content: StepContent): StepContent {
|
|
|
|
export function mapToParentContent(content: StepContent): StepContent {
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
function mapToParentActions(actions: Action[]): Action[] {
|
|
|
|
components: content.components.map((p) => {
|
|
|
|
return actions.map((a) => ({
|
|
|
|
if (p.type == "ball") return p
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
id: p.id + "-parent",
|
|
|
|
|
|
|
|
actions: p.actions.map((a) => ({
|
|
|
|
|
|
|
|
...a,
|
|
|
|
...a,
|
|
|
|
target: a.target + "-parent",
|
|
|
|
target: a.target + "-parent",
|
|
|
|
segments: a.segments.map((s) => ({
|
|
|
|
segments: a.segments.map((s) => ({
|
|
|
@ -491,8 +465,33 @@ export function mapToParentContent(content: StepContent): StepContent {
|
|
|
|
? s.next + "-parent"
|
|
|
|
? s.next + "-parent"
|
|
|
|
: s.next,
|
|
|
|
: s.next,
|
|
|
|
})),
|
|
|
|
})),
|
|
|
|
})),
|
|
|
|
}))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
components: content.components.map((p) => {
|
|
|
|
|
|
|
|
if (p.type == "ball") return p
|
|
|
|
|
|
|
|
if (p.type == "player") {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
id: p.id + "-parent",
|
|
|
|
|
|
|
|
actions: mapToParentActions(p.actions),
|
|
|
|
|
|
|
|
path: p.path && { items: p.path.items.map(p => p + "-parent") },
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...p,
|
|
|
|
|
|
|
|
pos: p.pos.type == "follows" ? { ...p.pos, attach: p.pos.attach + "-parent" } : p.pos,
|
|
|
|
|
|
|
|
id: p.id + "-parent",
|
|
|
|
|
|
|
|
originPlayerId: p.originPlayerId + "-parent",
|
|
|
|
|
|
|
|
actions: mapToParentActions(p.actions),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function selectContent(id: string, content: StepContent, parentContent: StepContent | null): StepContent {
|
|
|
|
|
|
|
|
return parentContent && id.endsWith("-parent") ? parentContent : content
|
|
|
|
|
|
|
|
}
|