|
|
@ -1,4 +1,11 @@
|
|
|
|
import {CSSProperties, Dispatch, SetStateAction, useCallback, useRef, useState,} from "react"
|
|
|
|
import {
|
|
|
|
|
|
|
|
CSSProperties,
|
|
|
|
|
|
|
|
Dispatch,
|
|
|
|
|
|
|
|
SetStateAction,
|
|
|
|
|
|
|
|
useCallback,
|
|
|
|
|
|
|
|
useRef,
|
|
|
|
|
|
|
|
useState,
|
|
|
|
|
|
|
|
} from "react"
|
|
|
|
import "../style/editor.css"
|
|
|
|
import "../style/editor.css"
|
|
|
|
import TitleInput from "../components/TitleInput"
|
|
|
|
import TitleInput from "../components/TitleInput"
|
|
|
|
import { BasketCourt } from "../components/editor/BasketCourt"
|
|
|
|
import { BasketCourt } from "../components/editor/BasketCourt"
|
|
|
@ -7,23 +14,23 @@ 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 { Player } from "../tactic/Player"
|
|
|
|
import {BallPiece, CourtBall} from "../components/editor/BallPiece";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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";
|
|
|
|
import {CourtObject} from "../tactic/CourtObjects";
|
|
|
|
import {Simulate} from "react-dom/test-utils";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ERROR_STYLE: CSSProperties = {
|
|
|
|
const ERROR_STYLE: CSSProperties = {
|
|
|
@ -57,12 +64,14 @@ interface RackedPlayer {
|
|
|
|
|
|
|
|
|
|
|
|
type RackedCourtObject = { key: "ball" }
|
|
|
|
type RackedCourtObject = { key: "ball" }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function Editor({
|
|
|
|
export default function Editor({
|
|
|
|
id,
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
name,
|
|
|
|
courtType,
|
|
|
|
courtType,
|
|
|
|
content,
|
|
|
|
content,
|
|
|
|
}: EditorProps) {
|
|
|
|
}: EditorProps) {
|
|
|
|
|
|
|
|
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
|
|
|
|
|
|
|
|
const storage_content = localStorage.getItem(GUEST_MODE_CONTENT_STORAGE_KEY)
|
|
|
|
const storage_content = localStorage.getItem(GUEST_MODE_CONTENT_STORAGE_KEY)
|
|
|
@ -101,17 +110,17 @@ export default function Editor({
|
|
|
|
(r) => r.ok,
|
|
|
|
(r) => r.ok,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
courtType={courtType}/>
|
|
|
|
courtType={courtType}
|
|
|
|
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function EditorView({
|
|
|
|
function EditorView({
|
|
|
|
tactic: {id, name, content: initialContent},
|
|
|
|
tactic: { id, name, content: initialContent },
|
|
|
|
onContentChange,
|
|
|
|
onContentChange,
|
|
|
|
onNameChange,
|
|
|
|
onNameChange,
|
|
|
|
courtType,
|
|
|
|
courtType,
|
|
|
|
}: EditorViewProps) {
|
|
|
|
}: EditorViewProps) {
|
|
|
|
|
|
|
|
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
const isInGuestMode = id == -1
|
|
|
|
|
|
|
|
|
|
|
|
const [titleStyle, setTitleStyle] = useState<CSSProperties>({})
|
|
|
|
const [titleStyle, setTitleStyle] = useState<CSSProperties>({})
|
|
|
@ -128,12 +137,14 @@ function EditorView({
|
|
|
|
getRackPlayers(Team.Opponents, content.players),
|
|
|
|
getRackPlayers(Team.Opponents, content.players),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const [objects, setObjects] = useState<RackedCourtObject[]>(isBallOnCourt(content) ? [] : [{key: "ball"}])
|
|
|
|
const [objects, setObjects] = useState<RackedCourtObject[]>(
|
|
|
|
|
|
|
|
isBallOnCourt(content) ? [] : [{ key: "ball" }],
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const courtDivContentRef = useRef<HTMLDivElement>(null)
|
|
|
|
const courtDivContentRef = useRef<HTMLDivElement>(null)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const canDetach = (bounds: DOMRect) => {
|
|
|
|
const isBoundsOnCourt = (bounds: DOMRect) => {
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
|
|
|
|
|
|
|
|
// check if refBounds overlaps courtBounds
|
|
|
|
// check if refBounds overlaps courtBounds
|
|
|
@ -145,8 +156,6 @@ function EditorView({
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onPieceDetach = (ref: HTMLDivElement, element: RackedPlayer) => {
|
|
|
|
const onPieceDetach = (ref: HTMLDivElement, element: RackedPlayer) => {
|
|
|
|
const refBounds = ref.getBoundingClientRect()
|
|
|
|
const refBounds = ref.getBoundingClientRect()
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
@ -171,33 +180,40 @@ function EditorView({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const onObjectDetach = (ref: HTMLDivElement, rackedObject: RackedCourtObject) => {
|
|
|
|
const onObjectDetach = (
|
|
|
|
|
|
|
|
ref: HTMLDivElement,
|
|
|
|
|
|
|
|
rackedObject: RackedCourtObject,
|
|
|
|
|
|
|
|
) => {
|
|
|
|
const refBounds = ref.getBoundingClientRect()
|
|
|
|
const refBounds = ref.getBoundingClientRect()
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
|
|
|
|
|
|
|
|
const {x, y} = calculateRatio(refBounds, courtBounds)
|
|
|
|
const { x, y } = calculateRatio(refBounds, courtBounds)
|
|
|
|
|
|
|
|
|
|
|
|
let courtObject: CourtObject
|
|
|
|
let courtObject: CourtObject
|
|
|
|
|
|
|
|
|
|
|
|
switch (rackedObject.key) {
|
|
|
|
switch (rackedObject.key) {
|
|
|
|
case "ball":
|
|
|
|
case "ball":
|
|
|
|
const ballObj = content.objects.findIndex(o => o.type == "ball")
|
|
|
|
const ballObj = content.objects.findIndex(
|
|
|
|
const playerCollidedIdx = getPlayerCollided(refBounds, content.players)
|
|
|
|
(o) => o.type == "ball",
|
|
|
|
if(playerCollidedIdx != -1) {
|
|
|
|
)
|
|
|
|
|
|
|
|
const playerCollidedIdx = getPlayerCollided(
|
|
|
|
|
|
|
|
refBounds,
|
|
|
|
|
|
|
|
content.players,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if (playerCollidedIdx != -1) {
|
|
|
|
onBallDropOnPlayer(playerCollidedIdx)
|
|
|
|
onBallDropOnPlayer(playerCollidedIdx)
|
|
|
|
setContent((content) => {
|
|
|
|
setContent((content) => {
|
|
|
|
return{
|
|
|
|
return {
|
|
|
|
...content,
|
|
|
|
...content,
|
|
|
|
objects : content.objects.toSpliced(ballObj, 1)
|
|
|
|
objects: content.objects.toSpliced(ballObj, 1),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
courtObject = {
|
|
|
|
courtObject = {
|
|
|
|
type: "ball",
|
|
|
|
type: "ball",
|
|
|
|
rightRatio: x,
|
|
|
|
rightRatio: x,
|
|
|
|
bottomRatio: y
|
|
|
|
bottomRatio: y,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break
|
|
|
|
break
|
|
|
@ -207,81 +223,100 @@ function EditorView({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
setContent((content) => {
|
|
|
|
return ({
|
|
|
|
return {
|
|
|
|
...content,
|
|
|
|
...content,
|
|
|
|
objects: [
|
|
|
|
objects: [...content.objects, courtObject],
|
|
|
|
...content.objects,
|
|
|
|
}
|
|
|
|
courtObject,
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getPlayerCollided = (bounds: DOMRect, players: Player[]): number | -1 => {
|
|
|
|
const getPlayerCollided = (
|
|
|
|
|
|
|
|
bounds: DOMRect,
|
|
|
|
|
|
|
|
players: Player[],
|
|
|
|
|
|
|
|
): number | -1 => {
|
|
|
|
for (let i = 0; i < players.length; i++) {
|
|
|
|
for (let i = 0; i < players.length; i++) {
|
|
|
|
const player = players[i]
|
|
|
|
const player = players[i]
|
|
|
|
const playerBounds = document.getElementById(player.id)!.getBoundingClientRect()
|
|
|
|
const playerBounds = document
|
|
|
|
|
|
|
|
.getElementById(player.id)!
|
|
|
|
|
|
|
|
.getBoundingClientRect()
|
|
|
|
const doesOverlap = !(
|
|
|
|
const doesOverlap = !(
|
|
|
|
bounds.top > playerBounds.bottom ||
|
|
|
|
bounds.top > playerBounds.bottom ||
|
|
|
|
bounds.right < playerBounds.left ||
|
|
|
|
bounds.right < playerBounds.left ||
|
|
|
|
bounds.bottom < playerBounds.top ||
|
|
|
|
bounds.bottom < playerBounds.top ||
|
|
|
|
bounds.left > playerBounds.right
|
|
|
|
bounds.left > playerBounds.right
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if(doesOverlap) {
|
|
|
|
if (doesOverlap) {
|
|
|
|
return i
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onBallDropOnPlayer = (playerCollidedIdx: number) => {
|
|
|
|
const onBallDropOnPlayer = (playerCollidedIdx : number) => {
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
setContent((content) => {
|
|
|
|
const ballObj = content.objects.findIndex(o => o.type == "ball")
|
|
|
|
const ballObj = content.objects.findIndex((o) => o.type == "ball")
|
|
|
|
let player = content.players.at(playerCollidedIdx) as Player
|
|
|
|
let player = content.players.at(playerCollidedIdx) as Player
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
...content,
|
|
|
|
...content,
|
|
|
|
players: content.players.toSpliced(playerCollidedIdx, 1, {...player, hasBall: true}),
|
|
|
|
players: content.players.toSpliced(playerCollidedIdx, 1, {
|
|
|
|
objects : content.objects.toSpliced(ballObj, 1)
|
|
|
|
...player,
|
|
|
|
|
|
|
|
hasBall: true,
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
objects: content.objects.toSpliced(ballObj, 1),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const onBallDrop = (refBounds: DOMRect) => {
|
|
|
|
const onBallDrop = (refBounds: DOMRect) => {
|
|
|
|
|
|
|
|
if (!isBoundsOnCourt(refBounds)) {
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
|
|
|
|
const ballObj = content.objects.findIndex(
|
|
|
|
|
|
|
|
(o) => o.type == "ball",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...content,
|
|
|
|
|
|
|
|
objects: content.objects.toSpliced(ballObj, 1),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
setObjects([{ key: "ball" }])
|
|
|
|
|
|
|
|
}
|
|
|
|
const playerCollidedIdx = getPlayerCollided(refBounds, content.players)
|
|
|
|
const playerCollidedIdx = getPlayerCollided(refBounds, content.players)
|
|
|
|
if(playerCollidedIdx != -1) {
|
|
|
|
if (playerCollidedIdx != -1) {
|
|
|
|
setContent((content) => {
|
|
|
|
setContent((content) => {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
...content,
|
|
|
|
...content,
|
|
|
|
players: content.players.map((player) => ({...player, hasBall: false})),
|
|
|
|
players: content.players.map((player) => ({
|
|
|
|
|
|
|
|
...player,
|
|
|
|
|
|
|
|
hasBall: false,
|
|
|
|
|
|
|
|
})),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
onBallDropOnPlayer(playerCollidedIdx)
|
|
|
|
onBallDropOnPlayer(playerCollidedIdx)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(content.objects.findIndex(o => o.type == "ball") != -1) {
|
|
|
|
if (content.objects.findIndex((o) => o.type == "ball") != -1) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
|
|
|
|
const {x, y} = calculateRatio(refBounds, courtBounds)
|
|
|
|
const { x, y } = calculateRatio(refBounds, courtBounds)
|
|
|
|
let courtObject: CourtObject
|
|
|
|
let courtObject: CourtObject
|
|
|
|
|
|
|
|
|
|
|
|
courtObject = {
|
|
|
|
courtObject = {
|
|
|
|
type: "ball",
|
|
|
|
type: "ball",
|
|
|
|
rightRatio: x,
|
|
|
|
rightRatio: x,
|
|
|
|
bottomRatio: y
|
|
|
|
bottomRatio: y,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setContent((content) => {
|
|
|
|
setContent((content) => {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
...content,
|
|
|
|
...content,
|
|
|
|
players: content.players.map((player) => ({...player, hasBall: false})),
|
|
|
|
players: content.players.map((player) => ({
|
|
|
|
objects: [
|
|
|
|
...player,
|
|
|
|
...content.objects,
|
|
|
|
hasBall: false,
|
|
|
|
courtObject,
|
|
|
|
})),
|
|
|
|
]
|
|
|
|
objects: [...content.objects, courtObject],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -313,7 +348,9 @@ function EditorView({
|
|
|
|
id="allies-rack"
|
|
|
|
id="allies-rack"
|
|
|
|
objects={allies}
|
|
|
|
objects={allies}
|
|
|
|
onChange={setAllies}
|
|
|
|
onChange={setAllies}
|
|
|
|
canDetach={div => canDetach(div.getBoundingClientRect())}
|
|
|
|
canDetach={(div) =>
|
|
|
|
|
|
|
|
isBoundsOnCourt(div.getBoundingClientRect())
|
|
|
|
|
|
|
|
}
|
|
|
|
onElementDetached={onPieceDetach}
|
|
|
|
onElementDetached={onPieceDetach}
|
|
|
|
render={({ team, key }) => (
|
|
|
|
render={({ team, key }) => (
|
|
|
|
<PlayerPiece
|
|
|
|
<PlayerPiece
|
|
|
@ -325,18 +362,24 @@ function EditorView({
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Rack id={"objects"}
|
|
|
|
<Rack
|
|
|
|
|
|
|
|
id={"objects"}
|
|
|
|
objects={objects}
|
|
|
|
objects={objects}
|
|
|
|
onChange={setObjects}
|
|
|
|
onChange={setObjects}
|
|
|
|
canDetach={div => canDetach(div.getBoundingClientRect())}
|
|
|
|
canDetach={(div) =>
|
|
|
|
|
|
|
|
isBoundsOnCourt(div.getBoundingClientRect())
|
|
|
|
|
|
|
|
}
|
|
|
|
onElementDetached={onObjectDetach}
|
|
|
|
onElementDetached={onObjectDetach}
|
|
|
|
render={renderCourtObject}/>
|
|
|
|
render={renderCourtObject}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Rack
|
|
|
|
<Rack
|
|
|
|
id="opponent-rack"
|
|
|
|
id="opponent-rack"
|
|
|
|
objects={opponents}
|
|
|
|
objects={opponents}
|
|
|
|
onChange={setOpponents}
|
|
|
|
onChange={setOpponents}
|
|
|
|
canDetach={div => canDetach(div.getBoundingClientRect())}
|
|
|
|
canDetach={(div) =>
|
|
|
|
|
|
|
|
isBoundsOnCourt(div.getBoundingClientRect())
|
|
|
|
|
|
|
|
}
|
|
|
|
onElementDetached={onPieceDetach}
|
|
|
|
onElementDetached={onPieceDetach}
|
|
|
|
render={({ team, key }) => (
|
|
|
|
render={({ team, key }) => (
|
|
|
|
<PlayerPiece
|
|
|
|
<PlayerPiece
|
|
|
@ -376,9 +419,7 @@ function EditorView({
|
|
|
|
player,
|
|
|
|
player,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
objects: [
|
|
|
|
objects: [...content.objects],
|
|
|
|
...content.objects,
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
let setter
|
|
|
|
let setter
|
|
|
|
switch (player.team) {
|
|
|
|
switch (player.team) {
|
|
|
@ -389,7 +430,7 @@ function EditorView({
|
|
|
|
setter = setAllies
|
|
|
|
setter = setAllies
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (player.hasBall) {
|
|
|
|
if (player.hasBall) {
|
|
|
|
setObjects([{key: "ball"}])
|
|
|
|
setObjects([{ key: "ball" }])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setter((players) => [
|
|
|
|
setter((players) => [
|
|
|
|
...players,
|
|
|
|
...players,
|
|
|
@ -402,13 +443,18 @@ function EditorView({
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onBallRemove={() => {
|
|
|
|
onBallRemove={() => {
|
|
|
|
setContent((content) => {
|
|
|
|
setContent((content) => {
|
|
|
|
const ballObj = content.objects.findIndex(o => o.type == "ball")
|
|
|
|
const ballObj = content.objects.findIndex(
|
|
|
|
|
|
|
|
(o) => o.type == "ball",
|
|
|
|
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
...content,
|
|
|
|
...content,
|
|
|
|
objects: content.objects.toSpliced(ballObj, 1)
|
|
|
|
objects: content.objects.toSpliced(
|
|
|
|
|
|
|
|
ballObj,
|
|
|
|
|
|
|
|
1,
|
|
|
|
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
setObjects([{key: "ball"}])
|
|
|
|
setObjects([{ key: "ball" }])
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -418,16 +464,16 @@ function EditorView({
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isBallOnCourt(content : TacticContent) {
|
|
|
|
function isBallOnCourt(content: TacticContent) {
|
|
|
|
if(content.players.findIndex(p => p.hasBall) != -1) {
|
|
|
|
if (content.players.findIndex((p) => p.hasBall) != -1) {
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return content.objects.findIndex(o => o.type == "ball") != -1
|
|
|
|
return content.objects.findIndex((o) => o.type == "ball") != -1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function renderCourtObject(courtObject: RackedCourtObject) {
|
|
|
|
function renderCourtObject(courtObject: RackedCourtObject) {
|
|
|
|
if (courtObject.key == "ball") {
|
|
|
|
if (courtObject.key == "ball") {
|
|
|
|
return <BallPiece/>
|
|
|
|
return <BallPiece />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new Error("unknown racked court object ", courtObject.key)
|
|
|
|
throw new Error("unknown racked court object ", courtObject.key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|