(null)
const x = player.rightRatio
const y = player.bottomRatio
@@ -68,6 +71,7 @@ export default function CourtPlayer({
}}>
{hasBall && (
+<<<<<<< HEAD
@@ -80,6 +84,12 @@ export default function CourtPlayer({
+=======
+ onBallDrop(ball)}
+ pieceRef={ball}
+ />
+>>>>>>> 7fa76bf (push for trying to resolve problem)
)}
>>>>>> 7fa76bf (push for trying to resolve problem):front/tactic/Ball.ts
}
diff --git a/front/tactic/Tactic.ts b/front/tactic/Tactic.ts
index 8e06331..1de59af 100644
--- a/front/tactic/Tactic.ts
+++ b/front/tactic/Tactic.ts
@@ -1,5 +1,9 @@
import { Player } from "./Player"
+<<<<<<< HEAD
import { CourtObject } from "./CourtObjects"
+=======
+import {Ball} from "./Ball";
+>>>>>>> 7fa76bf (push for trying to resolve problem)
export interface Tactic {
id: number
@@ -9,5 +13,9 @@ export interface Tactic {
export interface TacticContent {
players: Player[]
+<<<<<<< HEAD
objects: CourtObject[]
+=======
+ ball : Ball
+>>>>>>> 7fa76bf (push for trying to resolve problem)
}
diff --git a/front/views/Editor.tsx b/front/views/Editor.tsx
index 2ee86a8..f7a1865 100644
--- a/front/views/Editor.tsx
+++ b/front/views/Editor.tsx
@@ -14,7 +14,9 @@ import plainCourt from "../assets/court/full_court.svg"
import halfCourt from "../assets/court/half_court.svg"
-import { BallPiece } from "../components/editor/BallPiece"
+import {BallPiece, CourtBall} from "../components/editor/BallPiece";
+
+
import { Rack } from "../components/Rack"
import { PlayerPiece } from "../components/editor/PlayerPiece"
@@ -29,7 +31,6 @@ import SavingState, {
SaveState,
SaveStates,
} from "../components/editor/SavingState"
-import * as Console from "console";
import {CourtObject} from "../tactic/CourtObjects";
@@ -122,6 +123,7 @@ function EditorView({
onNameChange,
courtType,
}: EditorViewProps) {
+
const isInGuestMode = id == -1
const [titleStyle, setTitleStyle] = useState({})
@@ -146,6 +148,11 @@ function EditorView({
const isBoundsOnCourt = (bounds: DOMRect) => {
+ const rackBallRef = useRef(null)
+ const [rackBall, setRackBall] = useState(true)
+ const courtDivContentRef = useRef(null)
+
+ const canDetach = (bounds: DOMRect) => {
const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
// check if refBounds overlaps courtBounds
@@ -177,12 +184,12 @@ function EditorView({
hasBall: false,
},
],
+ ball: content.ball
}
})
}
const onObjectDetach = (
- ref: HTMLDivElement,
rackedObject: RackedCourtObject,
) => {
const refBounds = ref.getBoundingClientRect()
@@ -228,6 +235,44 @@ function EditorView({
...content,
objects: [...content.objects, courtObject],
}
+
+ const onBallDetach = (pos: DOMRect) => {
+ const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
+
+ const {x, y} = calculateRatio(pos, courtBounds)
+
+ setContent((content) => {
+ return {
+ players: content.players,
+ ball: {
+ rightRatio: x,
+ bottomRatio: y
+ }
+ }
+ })
+ }
+
+ const onBallDrop = (ballBounds: DOMRect) => {
+ let ballAssigned = false
+
+ setContent(content => {
+ const players = content.players.map(player => {
+ if (ballAssigned) {
+ return {...player, hasBall: false}
+ }
+ const playerBounds = document.getElementById(player.id)!.getBoundingClientRect()
+ const doesOverlap = !(
+ ballBounds.top > playerBounds.bottom ||
+ ballBounds.right < playerBounds.left ||
+ ballBounds.bottom < playerBounds.top ||
+ ballBounds.left > playerBounds.right
+ )
+ if (doesOverlap) {
+ ballAssigned = true
+ }
+ return {...player, hasBall: doesOverlap}
+ })
+ return {players: players, ball: content.ball}
})
}
@@ -362,7 +407,7 @@ function EditorView({
-
+
{