-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2475 from vivekvardhan2810/Pokergame
Poker Game Extension
- Loading branch information
Showing
5 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Simple Poker Game</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<div class="game-container"> | ||
<div class="player"> | ||
<h2>Player 1</h2> | ||
<div class="hand" id="player1-hand"></div> | ||
</div> | ||
<div class="player"> | ||
<h2>Player 2</h2> | ||
<div class="hand" id="player2-hand"></div> | ||
</div> | ||
<div class="community"> | ||
<h2>Community Cards</h2> | ||
<div class="hand" id="community-cards"></div> | ||
</div> | ||
<button id="deal-button">Deal</button> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Simple Poker Game", | ||
"version": "1.0", | ||
"description": "A simple poker game extension that combines strategy, skill, and luck.", | ||
"action": { | ||
"default_popup": "index.html", | ||
"default_icon": { | ||
"16": "icon.png", | ||
"48": "icon.png", | ||
"128": "icon.png" | ||
} | ||
}, | ||
"permissions": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
document.getElementById('deal-button').addEventListener('click', dealCards); | ||
|
||
function createDeck() { | ||
const suits = ['♠', '♥', '♦', '♣']; | ||
const ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']; | ||
let deck = []; | ||
for (let suit of suits) { | ||
for (let rank of ranks) { | ||
deck.push(rank + suit); | ||
} | ||
} | ||
return deck; | ||
} | ||
|
||
function shuffleDeck(deck) { | ||
for (let i = deck.length - 1; i > 0; i--) { | ||
const j = Math.floor(Math.random() * (i + 1)); | ||
[deck[i], deck[j]] = [deck[j], deck[i]]; | ||
} | ||
return deck; | ||
} | ||
|
||
function dealCards() { | ||
const deck = shuffleDeck(createDeck()); | ||
const player1Hand = deck.slice(0, 2); | ||
const player2Hand = deck.slice(2, 4); | ||
const communityCards = deck.slice(4, 9); | ||
|
||
renderCards('player1-hand', player1Hand); | ||
renderCards('player2-hand', player2Hand); | ||
|
||
document.getElementById('community-cards').innerHTML = ''; | ||
setTimeout(() => renderCards('community-cards', communityCards.slice(0, 3)), 1000); | ||
setTimeout(() => renderCards('community-cards', communityCards.slice(0, 4)), 2000); | ||
setTimeout(() => renderCards('community-cards', communityCards.slice(0, 5)), 3000); | ||
} | ||
|
||
function renderCards(elementId, cards) { | ||
const handElement = document.getElementById(elementId); | ||
handElement.innerHTML = ''; | ||
for (let card of cards) { | ||
const cardElement = document.createElement('div'); | ||
cardElement.className = 'card'; | ||
cardElement.innerText = card; | ||
handElement.appendChild(cardElement); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
background-color: #2d2d2d; | ||
color: #ffffff; | ||
margin: 0; | ||
} | ||
|
||
.game-container { | ||
text-align: center; | ||
} | ||
|
||
.player, .community { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.hand { | ||
display: flex; | ||
justify-content: center; | ||
margin-top: 10px; | ||
} | ||
|
||
.card { | ||
width: 60px; | ||
height: 90px; | ||
background-color: #ffffff; | ||
color: #000000; | ||
border: 1px solid #000000; | ||
border-radius: 5px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
margin: 0 5px; | ||
font-size: 20px; | ||
} |