|
|
@ -13,20 +13,24 @@ import { BasketCourt } from "../components/editor/BasketCourt"
|
|
|
|
import plainCourt from "../assets/court/full_court.svg"
|
|
|
|
import plainCourt from "../assets/court/full_court.svg"
|
|
|
|
import halfCourt from "../assets/court/half_court.svg"
|
|
|
|
import halfCourt from "../assets/court/half_court.svg"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { BallPiece } from "../components/editor/BallPiece"
|
|
|
|
|
|
|
|
|
|
|
|
import { Rack } from "../components/Rack"
|
|
|
|
import { Rack } from "../components/Rack"
|
|
|
|
import { PlayerPiece } from "../components/editor/PlayerPiece"
|
|
|
|
import { PlayerPiece } from "../components/editor/PlayerPiece"
|
|
|
|
|
|
|
|
|
|
|
|
import { BallPiece } from "../components/editor/BallPiece"
|
|
|
|
|
|
|
|
import { Player } from "../tactic/Player"
|
|
|
|
import { Player } from "../tactic/Player"
|
|
|
|
|
|
|
|
|
|
|
|
import { Tactic, TacticContent } from "../tactic/Tactic"
|
|
|
|
import { Tactic, TacticContent } from "../tactic/Tactic"
|
|
|
|
import { fetchAPI } from "../Fetcher"
|
|
|
|
import { fetchAPI } from "../Fetcher"
|
|
|
|
import { Team } from "../tactic/Team"
|
|
|
|
import { Team } from "../tactic/Team"
|
|
|
|
import { calculateRatio } from "../Utils"
|
|
|
|
import { calculateRatio } from "../Utils"
|
|
|
|
|
|
|
|
|
|
|
|
import SavingState, {
|
|
|
|
import SavingState, {
|
|
|
|
SaveState,
|
|
|
|
SaveState,
|
|
|
|
SaveStates,
|
|
|
|
SaveStates,
|
|
|
|
} from "../components/editor/SavingState"
|
|
|
|
} from "../components/editor/SavingState"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { CourtObject } from "../tactic/CourtObjects"
|
|
|
|
|
|
|
|
|
|
|
|
const ERROR_STYLE: CSSProperties = {
|
|
|
|
const ERROR_STYLE: CSSProperties = {
|
|
|
|
borderColor: "red",
|
|
|
|
borderColor: "red",
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -56,6 +60,8 @@ interface RackedPlayer {
|
|
|
|
key: string
|
|
|
|
key: string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type RackedCourtObject = { key: "ball" }
|
|
|
|
|
|
|
|
|
|
|
|
export default function Editor({ id, name, courtType, content }: EditorProps) {
|
|
|
|
export default function Editor({ id, name, courtType, content }: EditorProps) {
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
|
|
|
|
|
|
|
@ -122,24 +128,21 @@ function EditorView({
|
|
|
|
getRackPlayers(Team.Opponents, content.players),
|
|
|
|
getRackPlayers(Team.Opponents, content.players),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const [showBall, setShowBall] = useState(
|
|
|
|
const [objects, setObjects] = useState<RackedCourtObject[]>(
|
|
|
|
content.players.find((p) => p.hasBall) == undefined,
|
|
|
|
isBallOnCourt(content) ? [] : [{ key: "ball" }],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const ballPiece = useRef<HTMLDivElement>(null)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const courtDivContentRef = useRef<HTMLDivElement>(null)
|
|
|
|
const courtDivContentRef = useRef<HTMLDivElement>(null)
|
|
|
|
|
|
|
|
|
|
|
|
const canDetach = (ref: HTMLDivElement) => {
|
|
|
|
const isBoundsOnCourt = (bounds: DOMRect) => {
|
|
|
|
const refBounds = ref.getBoundingClientRect()
|
|
|
|
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
|
|
|
|
|
|
|
|
// check if refBounds overlaps courtBounds
|
|
|
|
// check if refBounds overlaps courtBounds
|
|
|
|
return !(
|
|
|
|
return !(
|
|
|
|
refBounds.top > courtBounds.bottom ||
|
|
|
|
bounds.top > courtBounds.bottom ||
|
|
|
|
refBounds.right < courtBounds.left ||
|
|
|
|
bounds.right < courtBounds.left ||
|
|
|
|
refBounds.bottom < courtBounds.top ||
|
|
|
|
bounds.bottom < courtBounds.top ||
|
|
|
|
refBounds.left > courtBounds.right
|
|
|
|
bounds.left > courtBounds.right
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -151,6 +154,7 @@ function EditorView({
|
|
|
|
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
setContent((content) => {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
players: [
|
|
|
|
players: [
|
|
|
|
...content.players,
|
|
|
|
...content.players,
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -166,39 +170,185 @@ function EditorView({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const onBallDrop = (ref: HTMLDivElement) => {
|
|
|
|
const onObjectDetach = (
|
|
|
|
const ballBounds = ref.getBoundingClientRect()
|
|
|
|
ref: HTMLDivElement,
|
|
|
|
let ballAssigned = false
|
|
|
|
rackedObject: RackedCourtObject,
|
|
|
|
|
|
|
|
) => {
|
|
|
|
|
|
|
|
const refBounds = ref.getBoundingClientRect()
|
|
|
|
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
const { x, y } = calculateRatio(refBounds, courtBounds)
|
|
|
|
const players = content.players.map((player) => {
|
|
|
|
|
|
|
|
if (ballAssigned) {
|
|
|
|
let courtObject: CourtObject
|
|
|
|
return { ...player, hasBall: false }
|
|
|
|
|
|
|
|
}
|
|
|
|
switch (rackedObject.key) {
|
|
|
|
const playerBounds = document
|
|
|
|
case "ball":
|
|
|
|
.getElementById(player.id)!
|
|
|
|
const ballObj = content.objects.findIndex(
|
|
|
|
.getBoundingClientRect()
|
|
|
|
(o) => o.type == "ball",
|
|
|
|
const doesOverlap = !(
|
|
|
|
)
|
|
|
|
ballBounds.top > playerBounds.bottom ||
|
|
|
|
const playerCollidedIdx = getPlayerCollided(
|
|
|
|
ballBounds.right < playerBounds.left ||
|
|
|
|
refBounds,
|
|
|
|
ballBounds.bottom < playerBounds.top ||
|
|
|
|
content.players,
|
|
|
|
ballBounds.left > playerBounds.right
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if (doesOverlap) {
|
|
|
|
if (playerCollidedIdx != -1) {
|
|
|
|
ballAssigned = true
|
|
|
|
onBallDropOnPlayer(playerCollidedIdx)
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
objects: content.objects.toSpliced(ballObj, 1),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
courtObject = {
|
|
|
|
|
|
|
|
type: "ball",
|
|
|
|
|
|
|
|
rightRatio: x,
|
|
|
|
|
|
|
|
bottomRatio: y,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
throw new Error("unknown court object ", rackedObject.key)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
objects: [...content.objects, courtObject],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getPlayerCollided = (
|
|
|
|
|
|
|
|
bounds: DOMRect,
|
|
|
|
|
|
|
|
players: Player[],
|
|
|
|
|
|
|
|
): number | -1 => {
|
|
|
|
|
|
|
|
for (let i = 0; i < players.length; i++) {
|
|
|
|
|
|
|
|
const player = players[i]
|
|
|
|
|
|
|
|
const playerBounds = document
|
|
|
|
|
|
|
|
.getElementById(player.id)!
|
|
|
|
|
|
|
|
.getBoundingClientRect()
|
|
|
|
|
|
|
|
const doesOverlap = !(
|
|
|
|
|
|
|
|
bounds.top > playerBounds.bottom ||
|
|
|
|
|
|
|
|
bounds.right < playerBounds.left ||
|
|
|
|
|
|
|
|
bounds.bottom < playerBounds.top ||
|
|
|
|
|
|
|
|
bounds.left > playerBounds.right
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if (doesOverlap) {
|
|
|
|
|
|
|
|
return i
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onBallDropOnPlayer = (playerCollidedIdx: number) => {
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
|
|
|
|
const ballObj = content.objects.findIndex((o) => o.type == "ball")
|
|
|
|
|
|
|
|
let player = content.players.at(playerCollidedIdx) as Player
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
players: content.players.toSpliced(playerCollidedIdx, 1, {
|
|
|
|
|
|
|
|
...player,
|
|
|
|
|
|
|
|
hasBall: true,
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
objects: content.objects.toSpliced(ballObj, 1),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onBallDrop = (refBounds: DOMRect) => {
|
|
|
|
|
|
|
|
if (!isBoundsOnCourt(refBounds)) {
|
|
|
|
|
|
|
|
removeCourtBall()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const playerCollidedIdx = getPlayerCollided(refBounds, content.players)
|
|
|
|
|
|
|
|
if (playerCollidedIdx != -1) {
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
players: content.players.map((player) => ({
|
|
|
|
|
|
|
|
...player,
|
|
|
|
|
|
|
|
hasBall: false,
|
|
|
|
|
|
|
|
})),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return { ...player, hasBall: doesOverlap }
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
setShowBall(!ballAssigned)
|
|
|
|
onBallDropOnPlayer(playerCollidedIdx)
|
|
|
|
return { players: players }
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (content.objects.findIndex((o) => o.type == "ball") != -1) {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
|
|
|
|
const { x, y } = calculateRatio(refBounds, courtBounds)
|
|
|
|
|
|
|
|
let courtObject: CourtObject
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
courtObject = {
|
|
|
|
|
|
|
|
type: "ball",
|
|
|
|
|
|
|
|
rightRatio: x,
|
|
|
|
|
|
|
|
bottomRatio: y,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
players: content.players.map((player) => ({
|
|
|
|
|
|
|
|
...player,
|
|
|
|
|
|
|
|
hasBall: false,
|
|
|
|
|
|
|
|
})),
|
|
|
|
|
|
|
|
objects: [...content.objects, courtObject],
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const removePlayer = (player: Player) => {
|
|
|
|
|
|
|
|
setContent((content) => ({
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
players: toSplicedPlayers(content.players, player, false),
|
|
|
|
|
|
|
|
objects: [...content.objects],
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
let setter
|
|
|
|
|
|
|
|
switch (player.team) {
|
|
|
|
|
|
|
|
case Team.Opponents:
|
|
|
|
|
|
|
|
setter = setOpponents
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
case Team.Allies:
|
|
|
|
|
|
|
|
setter = setAllies
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (player.hasBall) {
|
|
|
|
|
|
|
|
setObjects([{ key: "ball" }])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
setter((players) => [
|
|
|
|
|
|
|
|
...players,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
team: player.team,
|
|
|
|
|
|
|
|
pos: player.role,
|
|
|
|
|
|
|
|
key: player.role,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const removeCourtBall = () => {
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
|
|
|
|
const ballObj = content.objects.findIndex((o) => o.type == "ball")
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
players: content.players.map((player) => ({
|
|
|
|
|
|
|
|
...player,
|
|
|
|
|
|
|
|
hasBall: false,
|
|
|
|
|
|
|
|
})),
|
|
|
|
|
|
|
|
objects: content.objects.toSpliced(ballObj, 1),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
setObjects([{ key: "ball" }])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div id="main-div">
|
|
|
|
<div id="main-div">
|
|
|
|
<div id="topbar-div">
|
|
|
|
<div id="topbar-div">
|
|
|
|
<div id="topbar-left">
|
|
|
|
<div id="topbar-left">
|
|
|
|
|
|
|
|
|
|
|
|
<SavingState state={saveState} />
|
|
|
|
<SavingState state={saveState} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="title-input-div">
|
|
|
|
<div id="title-input-div">
|
|
|
@ -220,7 +370,9 @@ function EditorView({
|
|
|
|
id="allies-rack"
|
|
|
|
id="allies-rack"
|
|
|
|
objects={allies}
|
|
|
|
objects={allies}
|
|
|
|
onChange={setAllies}
|
|
|
|
onChange={setAllies}
|
|
|
|
canDetach={canDetach}
|
|
|
|
canDetach={(div) =>
|
|
|
|
|
|
|
|
isBoundsOnCourt(div.getBoundingClientRect())
|
|
|
|
|
|
|
|
}
|
|
|
|
onElementDetached={onPieceDetach}
|
|
|
|
onElementDetached={onPieceDetach}
|
|
|
|
render={({ team, key }) => (
|
|
|
|
render={({ team, key }) => (
|
|
|
|
<PlayerPiece
|
|
|
|
<PlayerPiece
|
|
|
@ -232,18 +384,24 @@ function EditorView({
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
{showBall && (
|
|
|
|
<Rack
|
|
|
|
<BallPiece
|
|
|
|
id={"objects"}
|
|
|
|
onDrop={() => onBallDrop(ballPiece.current!)}
|
|
|
|
objects={objects}
|
|
|
|
pieceRef={ballPiece}
|
|
|
|
onChange={setObjects}
|
|
|
|
/>
|
|
|
|
canDetach={(div) =>
|
|
|
|
)}
|
|
|
|
isBoundsOnCourt(div.getBoundingClientRect())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onElementDetached={onObjectDetach}
|
|
|
|
|
|
|
|
render={renderCourtObject}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Rack
|
|
|
|
<Rack
|
|
|
|
id="opponent-rack"
|
|
|
|
id="opponent-rack"
|
|
|
|
objects={opponents}
|
|
|
|
objects={opponents}
|
|
|
|
onChange={setOpponents}
|
|
|
|
onChange={setOpponents}
|
|
|
|
canDetach={canDetach}
|
|
|
|
canDetach={(div) =>
|
|
|
|
|
|
|
|
isBoundsOnCourt(div.getBoundingClientRect())
|
|
|
|
|
|
|
|
}
|
|
|
|
onElementDetached={onPieceDetach}
|
|
|
|
onElementDetached={onPieceDetach}
|
|
|
|
render={({ team, key }) => (
|
|
|
|
render={({ team, key }) => (
|
|
|
|
<PlayerPiece
|
|
|
|
<PlayerPiece
|
|
|
@ -259,13 +417,22 @@ function EditorView({
|
|
|
|
<div id="court-div-bounds">
|
|
|
|
<div id="court-div-bounds">
|
|
|
|
<BasketCourt
|
|
|
|
<BasketCourt
|
|
|
|
players={content.players}
|
|
|
|
players={content.players}
|
|
|
|
onBallDrop={onBallDrop}
|
|
|
|
objects={content.objects}
|
|
|
|
|
|
|
|
onBallMoved={onBallDrop}
|
|
|
|
courtImage={
|
|
|
|
courtImage={
|
|
|
|
courtType == "PLAIN" ? plainCourt : halfCourt
|
|
|
|
courtType == "PLAIN" ? plainCourt : halfCourt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
courtRef={courtDivContentRef}
|
|
|
|
courtRef={courtDivContentRef}
|
|
|
|
onPlayerChange={(player) => {
|
|
|
|
onPlayerChange={(player) => {
|
|
|
|
|
|
|
|
const playerBounds = document
|
|
|
|
|
|
|
|
.getElementById(player.id)!
|
|
|
|
|
|
|
|
.getBoundingClientRect()
|
|
|
|
|
|
|
|
if (!isBoundsOnCourt(playerBounds)) {
|
|
|
|
|
|
|
|
removePlayer(player)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
setContent((content) => ({
|
|
|
|
setContent((content) => ({
|
|
|
|
|
|
|
|
...content,
|
|
|
|
players: toSplicedPlayers(
|
|
|
|
players: toSplicedPlayers(
|
|
|
|
content.players,
|
|
|
|
content.players,
|
|
|
|
player,
|
|
|
|
player,
|
|
|
@ -274,32 +441,10 @@ function EditorView({
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onPlayerRemove={(player) => {
|
|
|
|
onPlayerRemove={(player) => {
|
|
|
|
setContent((content) => ({
|
|
|
|
removePlayer(player)
|
|
|
|
players: toSplicedPlayers(
|
|
|
|
}}
|
|
|
|
content.players,
|
|
|
|
onBallRemove={() => {
|
|
|
|
player,
|
|
|
|
removeCourtBall()
|
|
|
|
false,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
let setter
|
|
|
|
|
|
|
|
switch (player.team) {
|
|
|
|
|
|
|
|
case Team.Opponents:
|
|
|
|
|
|
|
|
setter = setOpponents
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
case Team.Allies:
|
|
|
|
|
|
|
|
setter = setAllies
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (player.hasBall) {
|
|
|
|
|
|
|
|
setShowBall(true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
setter((players) => [
|
|
|
|
|
|
|
|
...players,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
team: player.team,
|
|
|
|
|
|
|
|
pos: player.role,
|
|
|
|
|
|
|
|
key: player.role,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -309,6 +454,20 @@ function EditorView({
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isBallOnCourt(content: TacticContent) {
|
|
|
|
|
|
|
|
if (content.players.findIndex((p) => p.hasBall) != -1) {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return content.objects.findIndex((o) => o.type == "ball") != -1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function renderCourtObject(courtObject: RackedCourtObject) {
|
|
|
|
|
|
|
|
if (courtObject.key == "ball") {
|
|
|
|
|
|
|
|
return <BallPiece />
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error("unknown racked court object ", courtObject.key)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getRackPlayers(team: Team, players: Player[]): RackedPlayer[] {
|
|
|
|
function getRackPlayers(team: Team, players: Player[]): RackedPlayer[] {
|
|
|
|
return ["1", "2", "3", "4", "5"]
|
|
|
|
return ["1", "2", "3", "4", "5"]
|
|
|
|
.filter(
|
|
|
|
.filter(
|
|
|
|