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) {
continue
}
const actionTarget = content.components.find(
(c) => c.id === action.target,
)! as PlayerLike
if (typeof action.target !== "string")
continue
const actionTarget = tryGetComponent<PlayerLike>(action.target, content.components)
if (actionTarget === undefined)
continue //the target was maybe removed
return (
spreadNewStateFromOriginStateChange(
actionTarget,

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

Loading…
Cancel
Save