|
|
|
@ -1,4 +1,9 @@
|
|
|
|
|
import { BallState, Player, PlayerPhantom } from "../model/tactic/Player"
|
|
|
|
|
import {
|
|
|
|
|
BallState,
|
|
|
|
|
Player,
|
|
|
|
|
PlayerPhantom,
|
|
|
|
|
PlayerLike,
|
|
|
|
|
} from "../model/tactic/Player"
|
|
|
|
|
import { ratioWithinBase } from "../geo/Pos"
|
|
|
|
|
import {
|
|
|
|
|
ComponentId,
|
|
|
|
@ -44,7 +49,7 @@ export function getActionKind(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getActionKindBetween(
|
|
|
|
|
origin: Player | PlayerPhantom,
|
|
|
|
|
origin: PlayerLike,
|
|
|
|
|
target: TacticComponent | null,
|
|
|
|
|
state: BallState,
|
|
|
|
|
): { kind: ActionKind; nextState: BallState } {
|
|
|
|
@ -76,7 +81,6 @@ export function isActionValid(
|
|
|
|
|
origin.ballState != BallState.HOLDS_ORIGIN &&
|
|
|
|
|
origin.actions.find((a) => moves(a.type))
|
|
|
|
|
) {
|
|
|
|
|
console.log("a")
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
//Action is valid if the target is null
|
|
|
|
@ -95,7 +99,6 @@ export function isActionValid(
|
|
|
|
|
(hasBoundWith(target, origin, components) ||
|
|
|
|
|
hasBoundWith(origin, target, components))
|
|
|
|
|
) {
|
|
|
|
|
console.log("b")
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -104,7 +107,6 @@ export function isActionValid(
|
|
|
|
|
origin.actions.find((a) => a.target === target?.id) ||
|
|
|
|
|
target?.actions.find((a) => a.target === origin.id)
|
|
|
|
|
) {
|
|
|
|
|
console.log("c")
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -114,7 +116,6 @@ export function isActionValid(
|
|
|
|
|
if (areInSamePath(origin, target)) return false
|
|
|
|
|
|
|
|
|
|
if (alreadyHasAnAnteriorActionWith(origin, target, components)) {
|
|
|
|
|
console.log("e")
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -152,8 +153,8 @@ function hasBoundWith(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function alreadyHasAnAnteriorActionWith(
|
|
|
|
|
origin: Player | PlayerPhantom,
|
|
|
|
|
target: Player | PlayerPhantom,
|
|
|
|
|
origin: PlayerLike,
|
|
|
|
|
target: PlayerLike,
|
|
|
|
|
components: TacticComponent[],
|
|
|
|
|
): boolean {
|
|
|
|
|
const targetOrigin =
|
|
|
|
@ -174,7 +175,7 @@ function alreadyHasAnAnteriorActionWith(
|
|
|
|
|
for (let i = targetIdx; i < targetOriginPath.length; i++) {
|
|
|
|
|
const phantom = components.find(
|
|
|
|
|
(c) => c.id === targetOriginPath[i],
|
|
|
|
|
)! as Player | PlayerPhantom
|
|
|
|
|
)! as PlayerLike
|
|
|
|
|
if (
|
|
|
|
|
phantom.actions.find(
|
|
|
|
|
(a) =>
|
|
|
|
@ -191,7 +192,7 @@ function alreadyHasAnAnteriorActionWith(
|
|
|
|
|
for (let i = 0; i <= originIdx; i++) {
|
|
|
|
|
const phantom = components.find(
|
|
|
|
|
(c) => c.id === originOriginPath[i],
|
|
|
|
|
)! as Player | PlayerPhantom
|
|
|
|
|
)! as PlayerLike
|
|
|
|
|
if (
|
|
|
|
|
phantom.actions.find(
|
|
|
|
|
(a) =>
|
|
|
|
@ -208,7 +209,7 @@ function alreadyHasAnAnteriorActionWith(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createAction(
|
|
|
|
|
origin: Player | PlayerPhantom,
|
|
|
|
|
origin: PlayerLike,
|
|
|
|
|
courtBounds: DOMRect,
|
|
|
|
|
arrowHead: DOMRect,
|
|
|
|
|
content: TacticContent,
|
|
|
|
@ -418,7 +419,7 @@ export function removeAction(
|
|
|
|
|
* @param content
|
|
|
|
|
*/
|
|
|
|
|
export function spreadNewStateFromOriginStateChange(
|
|
|
|
|
origin: Player | PlayerPhantom,
|
|
|
|
|
origin: PlayerLike,
|
|
|
|
|
newState: BallState,
|
|
|
|
|
content: TacticContent,
|
|
|
|
|
): TacticContent {
|
|
|
|
@ -441,7 +442,7 @@ export function spreadNewStateFromOriginStateChange(
|
|
|
|
|
|
|
|
|
|
const actionTarget = content.components.find(
|
|
|
|
|
(c) => action.target === c.id,
|
|
|
|
|
)! as Player | PlayerPhantom
|
|
|
|
|
)! as PlayerLike
|
|
|
|
|
|
|
|
|
|
let targetState: BallState = actionTarget.ballState
|
|
|
|
|
let deleteAction = false
|
|
|
|
|