fix collision problem where more than 1 player can have the ball
continuous-integration/drone/push Build is passing Details

pull/40/head
Vivien DUFOUR 1 year ago
parent 7177c07ca0
commit b653ff4ea2

@ -44,8 +44,8 @@ on the court.
.player-selection-tab {
display: flex;
position: absolute;
margin-bottom: 10%;
position: relative;
margin-bottom: -20%;
justify-content: center;
visibility: hidden;
@ -56,6 +56,8 @@ on the court.
.player-selection-tab-remove {
pointer-events: all;
height: 25%;
width: 25%;
justify-content: center;
}
.player-selection-tab-remove * {

@ -159,10 +159,13 @@ function EditorView({
const onBallDrop = (ref : HTMLDivElement) => {
const ballBounds = ref.getBoundingClientRect()
let showBall = true
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 ||
@ -171,13 +174,11 @@ function EditorView({
ballBounds.left > playerBounds.right
)
if(doesOverlap) {
showBall = false
ballAssigned = true
}
return {...player, hasBall: doesOverlap}
})
setShowBall(showBall)
setShowBall(!ballAssigned)
return {players: players}
})
}
@ -259,6 +260,9 @@ function EditorView({
case Team.Allies:
setter = setAllies
}
if(player.hasBall) {
setShowBall(true)
}
setter((players) => [
...players,
{

Loading…
Cancel
Save