Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
112 lines (91 loc) · 3.75 KB
/
Copy pathscript.js
File metadata and controls
112 lines (91 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// -------- ELEMENTE AUS DEM HTML HOLEN --------
const runningCountDisplay = document.getElementById('runningCount');
const trueCountDisplay = document.getElementById('trueCount');
const cardsPlayedDisplay = document.getElementById('cardsPlayed');
const totalCardsDisplay = document.getElementById('totalCards');
const bettingAdviceDisplay = document.getElementById('bettingAdvice');
const resetButton = document.getElementById('resetButton');
const deckCountSelect = document.getElementById('deckCount');
const countingSystemSelect = document.getElementById('countingSystem');
const cardInputs = document.querySelectorAll('.card-input-grid .card');
// -------- ZÄHLSYSTEM-DEFINITIONEN --------
const COUNTING_SYSTEMS = {
hiLo: {
'2': 1, '3': 1, '4': 1, '5': 1, '6': 1,
'7': 0, '8': 0, '9': 0,
'10': -1, 'J': -1, 'Q': -1, 'K': -1, 'A': -1
},
wongHalves: {
'2': 0.5, '3': 1, '4': 1, '5': 1.5, '6': 1,
'7': 0.5, '8': 0, '9': -0.5,
'10': -1, 'J': -1, 'Q': -1, 'K': -1, 'A': -1
}
};
// -------- SPIELZUSTAND-VARIABLEN --------
let runningCount = 0;
let cardsPlayed = 0;
let totalCardsInShoe = 0;
// -------- FUNKTIONEN --------
// Startet/Resettet das Training
function resetGame() {
runningCount = 0;
cardsPlayed = 0;
totalCardsInShoe = parseInt(deckCountSelect.value) * 52;
updateDisplays();
}
// Wird aufgerufen, wenn eine Karte angeklickt wird
function handleCardClick(event) {
if (cardsPlayed >= totalCardsInShoe) return; // Stoppt, wenn Deck leer ist
cardsPlayed++;
const cardValue = event.currentTarget.dataset.value;
const system = countingSystemSelect.value;
const countValue = COUNTING_SYSTEMS[system][cardValue];
runningCount += countValue;
updateDisplays();
}
// Aktualisiert alle Anzeigen auf dem Bildschirm
function updateDisplays() {
// Counts berechnen
const decksRemaining = (totalCardsInShoe - cardsPlayed) / 52;
let trueCount = decksRemaining > 0 ? runningCount / decksRemaining : 0;
// Anzeigen aktualisieren
runningCountDisplay.textContent = runningCount.toLocaleString();
trueCountDisplay.textContent = trueCount.toFixed(2);
cardsPlayedDisplay.textContent = cardsPlayed;
totalCardsDisplay.textContent = totalCardsInShoe;
updateBettingAdvice(trueCount);
}
// Aktualisiert die Einsatz-Empfehlung basierend auf dem True Count
function updateBettingAdvice(trueCount) {
let message = '';
let adviceClass = '';
if (trueCount >= 4) {
message = "Starker Vorteil! Einsatz maximieren!";
adviceClass = 'bet-max';
} else if (trueCount >= 2) {
message = "Guter Vorteil! Einsatz deutlich erhöhen.";
adviceClass = 'bet-high';
} else if (trueCount >= 1) {
message = "Leichter Vorteil. Einsatz erhöhen.";
adviceClass = 'bet-increase';
} else if (trueCount >= -1) {
message = "Neutral. Minimaler Einsatz.";
adviceClass = 'bet-low';
} else {
message = "Nachteil. Absolut minimaler Einsatz.";
adviceClass = 'bet-neutral';
}
bettingAdviceDisplay.textContent = message;
// 'betting-advice' als Basisklasse beibehalten und die neue Farbklasse hinzufügen
bettingAdviceDisplay.className = `betting-advice ${adviceClass}`;
}
// -------- EVENT LISTENERS --------
// Event Listener für jede einzelne Eingabe-Karte
cardInputs.forEach(card => card.addEventListener('click', handleCardClick));
// Event Listener für den Reset-Button
resetButton.addEventListener('click', resetGame);
// Wenn Einstellungen geändert werden, Spiel zurücksetzen für korrekte Berechnung
deckCountSelect.addEventListener('change', resetGame);
countingSystemSelect.addEventListener('change', resetGame);
// Spiel beim ersten Laden der Seite initialisieren
resetGame();