fix steps bugs
continuous-integration/drone/push Build is passing Details

maxime 1 year ago
parent 9f69b92051
commit 95b89d87e4

@ -279,9 +279,11 @@ export function removePlayer(
if (action.type !== ActionKind.SHOOT) { if (action.type !== ActionKind.SHOOT) {
continue continue
} }
const actionTarget = content.components.find( if (typeof action.target !== "string")
(c) => c.id === action.target, continue
)! as PlayerLike const actionTarget = tryGetComponent<PlayerLike>(action.target, content.components)
if (actionTarget === undefined)
continue //the target was maybe removed
return ( return (
spreadNewStateFromOriginStateChange( spreadNewStateFromOriginStateChange(
actionTarget, actionTarget,

@ -6,7 +6,7 @@ import { ComponentId, StepContent, TacticComponent } from "../model/tactic/Tacti
import { overlaps } from "../geo/Box" import { overlaps } from "../geo/Box"
import { RackedCourtObject, RackedPlayer } from "./RackedItems" import { RackedCourtObject, RackedPlayer } from "./RackedItems"
import { getComponent, getOrigin, getPrecomputedPosition, tryGetComponent } from "./PlayerDomains" import { getComponent, getOrigin, getPrecomputedPosition, removePlayer, tryGetComponent } from "./PlayerDomains"
import { Action, ActionKind } from "../model/tactic/Action.ts" import { Action, ActionKind } from "../model/tactic/Action.ts"
import { spreadNewStateFromOriginStateChange } from "./ActionsDomains.ts" import { spreadNewStateFromOriginStateChange } from "./ActionsDomains.ts"
@ -437,14 +437,12 @@ export function drainTerminalStateOnChildContent(
const initialChildCompsCount = childContent.components.length const initialChildCompsCount = childContent.components.length
//filter out all frozen components that are not present on the parent's terminal state anymore for (const component of childContent.components) {
childContent = { if (component.type !== "phantom" && component.frozen && !tryGetComponent(component.id, parentTerminalState.components)) {
components: childContent.components.filter( if (component.type === "player")
(comp) => childContent = removePlayer(component, childContent)
comp.type === "phantom" || else childContent = {...childContent, components: childContent.components.filter(c => c.id !== component.id)}
!comp.frozen || }
tryGetComponent(comp.id, parentTerminalState.components),
),
} }
gotUpdated ||= childContent.components.length !== initialChildCompsCount gotUpdated ||= childContent.components.length !== initialChildCompsCount

Loading…
Cancel
Save