You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.0 KiB
92 lines
2.0 KiB
import { Component, ComponentId } from "./Tactic"
|
|
import { Pos } from "../../geo/Pos.ts"
|
|
|
|
export type PlayerId = string
|
|
|
|
export type PlayerLike = Player | PlayerPhantom
|
|
|
|
export enum PlayerTeam {
|
|
Allies = "allies",
|
|
Opponents = "opponents",
|
|
}
|
|
|
|
export interface Player extends PlayerInfo, Component<"player", Pos> {
|
|
readonly id: PlayerId
|
|
}
|
|
|
|
/**
|
|
* All information about a player
|
|
*/
|
|
export interface PlayerInfo {
|
|
readonly id: string
|
|
/**
|
|
* the player's team
|
|
* */
|
|
readonly team: PlayerTeam
|
|
|
|
/**
|
|
* player's role
|
|
* */
|
|
readonly role: string
|
|
|
|
/**
|
|
* True if the player has a basketball
|
|
*/
|
|
readonly ballState: BallState
|
|
|
|
readonly pos: Pos
|
|
}
|
|
|
|
export enum BallState {
|
|
NONE,
|
|
HOLDS_ORIGIN,
|
|
HOLDS_BY_PASS,
|
|
PASSED,
|
|
PASSED_ORIGIN,
|
|
}
|
|
|
|
export interface Player extends Component<"player", Pos>, PlayerInfo {
|
|
/**
|
|
* True if the player has a basketball
|
|
*/
|
|
readonly ballState: BallState
|
|
|
|
readonly path: MovementPath | null
|
|
}
|
|
|
|
export interface MovementPath {
|
|
readonly items: ComponentId[]
|
|
}
|
|
|
|
/**
|
|
* The position of the phantom is known and fixed
|
|
*/
|
|
export type FixedPhantomPositioning = { type: "fixed" } & Pos
|
|
/**
|
|
* The position of the phantom is constrained to a given component.
|
|
* The actual position of the phantom is to determine given its environment.
|
|
*/
|
|
export type FollowsPhantomPositioning = { type: "follows"; attach: ComponentId }
|
|
|
|
/**
|
|
* Defines the different kind of positioning a phantom can have
|
|
*/
|
|
export type PhantomPositioning =
|
|
| FixedPhantomPositioning
|
|
| FollowsPhantomPositioning
|
|
|
|
/**
|
|
* A player phantom is a kind of component that represents the future state of a player
|
|
* according to the court's step information
|
|
*/
|
|
export interface PlayerPhantom
|
|
extends Component<"phantom", PhantomPositioning> {
|
|
readonly originPlayerId: ComponentId
|
|
readonly ballState: BallState
|
|
|
|
/**
|
|
* Defines a component this phantom will be attached to.
|
|
*/
|
|
readonly attachedTo?: ComponentId
|
|
}
|