radicais commited on
Commit
f641f6b
·
verified ·
1 Parent(s): b660d0e

ME AJUDAR AGORA SOBRE OS Atletas, QUANDO EU JOGAR UM Atletas NA QUADRA ELE SAIR DO BANCO, E QUANDO EU JOGAR O Atletas DO BANCO NA POSICAO DO Atletas QUE ESTA NA QUADRA LEVAR ESSE Atletas DA QUADRA PRO BANCO E DO BANCO PRA QUADRA - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +17 -2
index.html CHANGED
@@ -962,14 +962,24 @@
962
  return;
963
  }
964
 
965
- // Remove player from previous position
 
 
 
966
  removePlayerFromCourt(player);
 
 
 
 
 
 
967
 
968
- // Add to new position
969
  gameState.courtPositions[`team${team}`][zoneNum] = player;
970
 
971
  // Update UI
972
  renderCourt();
 
973
 
974
  // Save history
975
  saveHistory();
@@ -1167,6 +1177,11 @@
1167
  }
1168
  }
1169
  }
 
 
 
 
 
1170
 
1171
  function renderCourt() {
1172
  // Clear all player circles from zones
 
962
  return;
963
  }
964
 
965
+ // Check if there's a player in the target zone
966
+ const existingPlayer = gameState.courtPositions[`team${team}`][zoneNum];
967
+
968
+ // Remove player from previous position (court or bench)
969
  removePlayerFromCourt(player);
970
+ removePlayerFromBench(player);
971
+
972
+ // If there was a player in the zone, move them to bench
973
+ if (existingPlayer) {
974
+ gameState.bench[`team${team}`].push(existingPlayer);
975
+ }
976
 
977
+ // Add dragging player to court position
978
  gameState.courtPositions[`team${team}`][zoneNum] = player;
979
 
980
  // Update UI
981
  renderCourt();
982
+ renderBench();
983
 
984
  // Save history
985
  saveHistory();
 
1177
  }
1178
  }
1179
  }
1180
+
1181
+ function removePlayerFromBench(player) {
1182
+ const benchTeam = player.team === '1' ? 'team1' : 'team2';
1183
+ gameState.bench[benchTeam] = gameState.bench[benchTeam].filter(p => p.id !== player.id);
1184
+ }
1185
 
1186
  function renderCourt() {
1187
  // Clear all player circles from zones