WEBLEB
Accueil
Éditeur
Chat
Défi
Connexion
Pro
Français
English
Français
Español
monopole
51
2
Jeux
TacoGamer
Suivre
0
Remixer
Ouvrir dans l'éditeur
Plein écran
Discuter
Publiez votre code
0
HTML
Copy
HTML5 Monopoly Prototype
Monopoly Bank
Roll Dice
Dice: -
Player 1 Turn
Free Parking
Go To Jail
Just Visiting
GO
🔴
Kentucky
Chance
Indiana
Illinois
B&O Rail
Atlantic
Ventnor
Water Wks
Marvin
New York
Tennessee
Community
St. James
Pennsylvania Rail
Virginia
States
Electric Co
St. Charles
Pacific
North Car.
Community
Pennsylvania
Short Line
Chance
Park Place
Luxury Tax
Boardwalk
Conn.
Vermont
Chance
Oriental
Reading Rail
Income Tax
Baltic
Community
Mediterranean
MONOPOLY
CSS
Copy
body { background-color: #2c3e50; font-family: Arial, sans-serif; display: flex; justify-content: center; padding: 20px; } .game-container { display: flex; gap: 30px; } .controls { background: white; padding: 20px; border-radius: 8px; height: fit-content; width: 200px; text-align: center; } /* 11x11 Grid system for the board */ .monopoly-board { display: grid; grid-template-columns: 120px repeat(9, 70px) 120px; grid-template-rows: 120px repeat(9, 70px) 120px; grid-gap: 2px; background: #000; width: 874px; height: 874px; background-color: #caf0f8; } .space { background: #f4f1de; display: flex; flex-direction: column; align-items: center; justify-content: space-between; font-size: 10px; font-weight: bold; text-align: center; padding: 5px; box-sizing: border-box; position: relative; } /* Explicitly Placing Corners */ #space-20 { grid-column: 1; grid-row: 1; } #space-30 { grid-column: 11; grid-row: 1; } #space-10 { grid-column: 1; grid-row: 11; } #space-0 { grid-column: 11; grid-row: 11; } /* Explicitly Placing Rows and Columns */ #space-21 { grid-column: 2; grid-row: 1; } #space-22 { grid-column: 3; grid-row: 1; } #space-23 { grid-column: 4; grid-row: 1; } #space-24 { grid-column: 5; grid-row: 1; } #space-25 { grid-column: 6; grid-row: 1; } #space-26 { grid-column: 7; grid-row: 1; } #space-27 { grid-column: 8; grid-row: 1; } #space-28 { grid-column: 9; grid-row: 1; } #space-29 { grid-column: 10; grid-row: 1; } #space-19 { grid-column: 1; grid-row: 2; } #space-18 { grid-column: 1; grid-row: 3; } #space-17 { grid-column: 1; grid-row: 4; } #space-16 { grid-column: 1; grid-row: 5; } #space-15 { grid-column: 1; grid-row: 6; } #space-14 { grid-column: 1; grid-row: 7; } #space-13 { grid-column: 1; grid-row: 8; } #space-12 { grid-column: 1; grid-row: 9; } #space-11 { grid-column: 1; grid-row: 10; } #space-31 { grid-column: 11; grid-row: 2; } #space-32 { grid-column: 11; grid-row: 3; } #space-33 { grid-column: 11; grid-row: 4; } #space-34 { grid-column: 11; grid-row: 5; } #space-35 { grid-column: 11; grid-row: 6; } #space-36 { grid-column: 11; grid-row: 7; } #space-37 { grid-column: 11; grid-row: 8; } #space-38 { grid-column: 11; grid-row: 9; } #space-39 { grid-column: 11; grid-row: 10; } #space-9 { grid-column: 2; grid-row: 11; } #space-8 { grid-column: 3; grid-row: 11; } #space-7 { grid-column: 4; grid-row: 11; } #space-6 { grid-column: 5; grid-row: 11; } #space-5 { grid-column: 6; grid-row: 11; } #space-4 { grid-column: 7; grid-row: 11; } #space-3 { grid-column: 8; grid-row: 11; } #space-2 { grid-column: 9; grid-row: 11; } #space-1 { grid-column: 10; grid-row: 11; } /* Center Display Zone */ .board-center { grid-column: 2 / 11; grid-row: 2 / 11; background: #f4f1de; display: flex; justify-content: center; align-items: center; } .board-center h1 { font-size: 60px; color: #e63946; transform: rotate(-45deg); letter-spacing: 5px; } /* Color Property Bars */ .bar { width: 100%; height: 15px; border-bottom: 2px solid black; } .red { background: red; } .yellow { background: yellow; } .orange { background: orange; } .magenta { background: magenta; } .green { background: green; } .blue { background: blue; } .lightblue { background: lightblue; } .brown { background: #8b5a2b; } #player-token { font-size: 20px; position: absolute; bottom: 5px; z-index: 10; }
JS
Copy
let playerPosition = 0; // Starts at GO (0) const spacesInfo = { 0: "GO", 1: "Mediterranean Avenue", 2: "Community Chest", 3: "Baltic Avenue", 4: "Income Tax", 5: "Reading Railroad", 6: "Oriental Avenue", 7: "Chance", 8: "Vermont Avenue", 9: "Connecticut Avenue", 10: "Just Visiting", 11: "St. Charles Place", 12: "Electric Company", 13: "States Avenue", 14: "Virginia Avenue", 15: "Pennsylvania Railroad", 16: "St. James Place", 17: "Community Chest", 18: "Tennessee Avenue", 19: "New York Avenue", 20: "Free Parking", 21: "Kentucky Avenue", 22: "Chance", 23: "Indiana Avenue", 24: "Illinois Avenue", 25: "B. & O. Railroad", 26: "Atlantic Avenue", 27: "Ventnor Avenue", 28: "Water Works", 29: "Marvin Gardens", 30: "Go To Jail", 31: "Pacific Avenue", 32: "North Carolina Avenue", 33: "Community Chest", 34: "Pennsylvania Avenue", 35: "Short Line Railroad", 36: "Chance", 37: "Park Place", 38: "Luxury Tax", 39: "Boardwalk" }; document.getElementById('roll-btn').addEventListener('click', () => { // Generate standard 2x Dice Roll const die1 = Math.floor(Math.random() * 6) + 1; const die2 = Math.floor(Math.random() * 6) + 1; const totalRoll = die1 + die2; document.getElementById('dice-result').innerText = `Dice: ${die1} + ${die2} (= ${totalRoll})`; // Calculate updated board index position playerPosition = (playerPosition + totalRoll) % 40; // Reposition Token Node inside the DOM const token = document.getElementById('player-token'); const targetSpace = document.getElementById(`space-${playerPosition}`); targetSpace.appendChild(token); // Update Status Screen Text document.getElementById('status-panel').innerText = `Landed on: ${spacesInfo[playerPosition]}`; });
Comments
2
Log in to join the discussion
…