Dallas mavericks simulation
user_0856540
plain_text
2 years ago
2.0 kB
9
Indexable
// Mock data for players and games
const players = [
{ id: 1, name: "Luka Dončić", position: "Point Guard", pointsPerGame: 28.5 },
{ id: 2, name: "Kristaps Porziņģis", position: "Power Forward", pointsPerGame: 20.2 },
// Add more player data here
];
const games = [
{ opponent: "Los Angeles Lakers", date: "2024-03-16", venue: "Staples Center", result: "W" },
{ opponent: "Golden State Warriors", date: "2024-03-18", venue: "Chase Center", result: "L" },
// Add more game data here
];
// Function to display player statistics
function displayPlayerStats(playerId) {
const player = players.find(p => p.id === playerId);
if (player) {
console.log(`Player Name: ${player.name}`);
console.log(`Position: ${player.position}`);
console.log(`Points Per Game: ${player.pointsPerGame}`);
} else {
console.log("Player not found.");
}
}
// Function to display game schedule
function displayGameSchedule() {
console.log("Upcoming Games:");
games.forEach(game => {
console.log(`${game.date} - ${game.opponent} (${game.venue})`);
});
}
// Function to simulate live updates during a game
function simulateLiveUpdates() {
const liveUpdateInterval = setInterval(() => {
const randomGameIndex = Math.floor(Math.random() * games.length);
const randomGame = games[randomGameIndex];
const randomScore = Math.floor(Math.random() * 120); // Simulating score
console.log(`Live Update: ${randomGame.opponent} - Mavericks ${randomScore}`);
}, 5000); // Update every 5 seconds
// Stop live updates after 1 minute (for demonstration)
setTimeout(() => {
clearInterval(liveUpdateInterval);
console.log("Live updates stopped.");
}, 60000); // Stop after 1 minute
}
// Example usage
displayPlayerStats(1); // Display stats for Luka Dončić
displayGameSchedule(); // Display upcoming games
simulateLiveUpdates(); // Simulate live updates during a gameEditor is loading...