testsAndMisc/python_pkg/poker_modifier_app/script.js

176 lines
6.0 KiB
JavaScript
Raw Normal View History

2025-07-19 19:31:18 +02:00
class PokerModifierApp {
constructor() {
this.modifiers = [
{
name: "High Stakes",
description: "All bets are doubled this round!"
},
{
name: "Wild Card",
description: "The next card revealed can be used as any card!"
},
{
name: "Bluff Master",
description: "Players can see one opponent's card before betting."
},
{
name: "All-In Fever",
description: "If someone goes all-in, everyone must match or fold."
},
{
name: "Lucky Sevens",
description: "Any hand with a 7 beats a pair!"
},
{
name: "Reverse Psychology",
description: "Lowest hand wins this round!"
},
{
name: "Split Pot",
description: "The pot is split between the top 2 hands."
},
{
name: "Texas Twister",
description: "Each player gets an extra hole card this round."
},
{
name: "Blind Luck",
description: "All players must play blind (no looking at cards) until the river."
},
{
name: "Community Boost",
description: "An extra community card is revealed (6 total)."
},
{
name: "Minimum Madness",
description: "Minimum bet is tripled this round."
},
{
name: "Suit Supremacy",
description: "All cards of the chosen suit (random) are worth +1 rank."
},
{
name: "Quick Draw",
description: "Betting time is cut in half - make decisions fast!"
},
{
name: "Royal Treatment",
description: "Face cards (J, Q, K) are worth double."
},
{
name: "Chip Challenge",
description: "Winner gets extra chips from the house!"
}
];
2025-07-19 19:31:18 +02:00
this.roundsPlayed = 0;
this.modifiersApplied = 0;
2025-07-19 19:31:18 +02:00
this.initializeElements();
this.attachEventListeners();
this.updateChanceDisplay();
}
2025-07-19 19:31:18 +02:00
initializeElements() {
this.startButton = document.getElementById('startRoundBtn');
this.resultDisplay = document.getElementById('resultDisplay');
this.modifierChanceSlider = document.getElementById('modifierChance');
this.chanceValueDisplay = document.getElementById('chanceValue');
this.roundsCountDisplay = document.getElementById('roundsCount');
this.modifiersCountDisplay = document.getElementById('modifiersCount');
}
2025-07-19 19:31:18 +02:00
attachEventListeners() {
this.startButton.addEventListener('click', () => this.startRound());
this.modifierChanceSlider.addEventListener('input', () => this.updateChanceDisplay());
}
2025-07-19 19:31:18 +02:00
updateChanceDisplay() {
const chance = this.modifierChanceSlider.value;
this.chanceValueDisplay.textContent = `${chance}%`;
}
2025-07-19 19:31:18 +02:00
startRound() {
// Add button animation
this.startButton.style.transform = 'scale(0.95)';
setTimeout(() => {
this.startButton.style.transform = '';
}, 150);
2025-07-19 19:31:18 +02:00
// Update round counter
this.roundsPlayed++;
this.roundsCountDisplay.textContent = this.roundsPlayed;
2025-07-19 19:31:18 +02:00
// Get current probability
const modifierChance = parseInt(this.modifierChanceSlider.value);
2025-07-19 19:31:18 +02:00
// Determine if a modifier should be applied
const randomValue = Math.random() * 100;
const shouldApplyModifier = randomValue < modifierChance;
2025-07-19 19:31:18 +02:00
if (shouldApplyModifier) {
this.applyRandomModifier();
} else {
this.showNoModifier();
}
2025-07-19 19:31:18 +02:00
// Add some visual feedback with animation
this.resultDisplay.style.opacity = '0';
this.resultDisplay.style.transform = 'scale(0.8)';
2025-07-19 19:31:18 +02:00
setTimeout(() => {
this.resultDisplay.style.opacity = '1';
this.resultDisplay.style.transform = 'scale(1)';
}, 200);
}
2025-07-19 19:31:18 +02:00
applyRandomModifier() {
// Update modifier counter
this.modifiersApplied++;
this.modifiersCountDisplay.textContent = this.modifiersApplied;
2025-07-19 19:31:18 +02:00
// Select random modifier
const randomIndex = Math.floor(Math.random() * this.modifiers.length);
const selectedModifier = this.modifiers[randomIndex];
2025-07-19 19:31:18 +02:00
// Update display
this.resultDisplay.className = 'result-display has-modifier';
this.resultDisplay.innerHTML = `
<div class="modifier-title">🎲 ${selectedModifier.name}</div>
<div class="modifier-description">${selectedModifier.description}</div>
`;
}
2025-07-19 19:31:18 +02:00
showNoModifier() {
this.resultDisplay.className = 'result-display no-modifier';
this.resultDisplay.innerHTML = `
<div class="no-modifier-text">No modifier this round</div>
<div style="font-size: 0.9rem; color: #999; margin-top: 0.5rem;">Play normally</div>
`;
}
2025-07-19 19:31:18 +02:00
// Method to add new modifiers (for future expansion)
addModifier(name, description) {
this.modifiers.push({ name, description });
}
2025-07-19 19:31:18 +02:00
// Method to get statistics
getStats() {
return {
roundsPlayed: this.roundsPlayed,
modifiersApplied: this.modifiersApplied,
modifierRate: this.roundsPlayed > 0 ? (this.modifiersApplied / this.roundsPlayed * 100).toFixed(1) : 0
};
}
}
// Initialize the app when the page loads
document.addEventListener('DOMContentLoaded', () => {
window.pokerApp = new PokerModifierApp();
2025-07-19 19:31:18 +02:00
// Add some console info for developers
console.log('🃏 Texas Hold\'em Modifier App loaded!');
console.log('Access the app instance via window.pokerApp');
console.log('Available methods: getStats(), addModifier(name, description)');
});