Created
May 8, 2025 17:10
-
-
Save pca2/aaac968887a7212760c708ccf572a33d to your computer and use it in GitHub Desktop.
Dominion Tracker
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Dominion Counter</title> | |
<style> | |
body { | |
font-family: 'Courier New', monospace; | |
background-color: #1f1f2e; | |
color: #d6d6e5; | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
justify-content: center; | |
min-height: 100vh; | |
margin: 0; | |
padding: 20px; | |
} | |
h1 { | |
font-size: 42px; | |
margin-bottom: 40px; | |
font-weight: normal; | |
} | |
.counter-section { | |
margin-bottom: 30px; | |
text-align: center; | |
width: 100%; | |
max-width: 300px; | |
} | |
.counter-title { | |
font-size: 28px; | |
margin-bottom: 15px; | |
} | |
.counter-controls { | |
display: flex; | |
justify-content: space-between; | |
} | |
.counter-btn { | |
background-color: #515166; | |
border: none; | |
color: white; | |
width: 80px; | |
height: 80px; | |
font-size: 32px; | |
cursor: pointer; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
.counter-btn:hover { | |
background-color: #626277; | |
} | |
.counter-value { | |
width: 80px; | |
height: 80px; | |
font-size: 32px; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Dominion</h1> | |
<div class="counter-section"> | |
<div class="counter-title">Actions</div> | |
<div class="counter-controls"> | |
<button class="counter-btn" onclick="decrement('actions')">-</button> | |
<div id="actions" class="counter-value">0</div> | |
<button class="counter-btn" onclick="increment('actions')">+</button> | |
</div> | |
</div> | |
<div class="counter-section"> | |
<div class="counter-title">Buys</div> | |
<div class="counter-controls"> | |
<button class="counter-btn" onclick="decrement('buys')">-</button> | |
<div id="buys" class="counter-value">0</div> | |
<button class="counter-btn" onclick="increment('buys')">+</button> | |
</div> | |
</div> | |
<div class="counter-section"> | |
<div class="counter-title">Coin</div> | |
<div class="counter-controls"> | |
<button class="counter-btn" onclick="decrement('coin')">-</button> | |
<div id="coin" class="counter-value">0</div> | |
<button class="counter-btn" onclick="increment('coin')">+</button> | |
</div> | |
</div> | |
<div class="counter-section"> | |
<div class="counter-title">Victory</div> | |
<div class="counter-controls"> | |
<button class="counter-btn" onclick="decrement('victory')">-</button> | |
<div id="victory" class="counter-value">0</div> | |
<button class="counter-btn" onclick="increment('victory')">+</button> | |
</div> | |
</div> | |
<script> | |
// Initialize counters from localStorage or default to 0 | |
const counters = loadCounters(); | |
// Load initial values to display | |
updateDisplay(); | |
// Function to load counters from localStorage | |
function loadCounters() { | |
const savedCounters = localStorage.getItem('dominionCounters'); | |
if (savedCounters) { | |
return JSON.parse(savedCounters); | |
} else { | |
// Default values if nothing is saved | |
return { | |
actions: 0, | |
buys: 0, | |
coin: 0, | |
victory: 0 | |
}; | |
} | |
} | |
// Function to save counters to localStorage | |
function saveCounters() { | |
localStorage.setItem('dominionCounters', JSON.stringify(counters)); | |
} | |
// Function to update all counter displays | |
function updateDisplay() { | |
document.getElementById('actions').textContent = counters.actions; | |
document.getElementById('buys').textContent = counters.buys; | |
document.getElementById('coin').textContent = counters.coin; | |
document.getElementById('victory').textContent = counters.victory; | |
} | |
// Function to increment a counter | |
function increment(type) { | |
counters[type]++; | |
document.getElementById(type).textContent = counters[type]; | |
saveCounters(); | |
} | |
// Function to decrement a counter | |
function decrement(type) { | |
if (counters[type] > 0) { | |
counters[type]--; | |
document.getElementById(type).textContent = counters[type]; | |
saveCounters(); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment