-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
664 lines (601 loc) · 23.3 KB
/
index.html
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
<!DOCTYPE html>
<html>
<head>
<style>
html {
margin: 0px;
box-shadow: inset 0 0 100px rgba(0,0,0,0.9);
background: radial-gradient(circle at 50% 0%,#e1e1e1 10%,#555);
height: 100%;
width: 100%;
overflow-x: hidden;
}
body {
margin: 20px;
height: 100%;
width: 100%;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
overflow-x: hidden;
}
.container {
display: flex;
gap: 20px;
max-width: 1200px;
margin: 0 auto;
height: 140vh;
}
.fate-panel, .journal-panel {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.fate-panel {
flex: 1;
}
.journal-panel {
flex: 2;
}
.dice-container {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.die {
width: 60px;
height: 60px;
background: #f8f8f8;
border: 2px solid #ddd;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
font-weight: bold;
}
button {
background: #4a4a4a;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin-bottom: 10px;
width: 100%;
}
button:hover {
background: #666;
}
.result {
margin-top: 10px;
padding: 10px;
background: #f8f8f8;
border-radius: 5px;
}
#journal {
width: 97%;
height: calc(80% - 60px);
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
resize: none;
font-family: inherit;
line-height: 1.6;
}
.section {
margin-bottom: 30px;
padding-bottom: 20px;
border-bottom: 1px solid #eee;
}
h2 {
margin-top: 0;
color: #333;
}
.card-display {
min-height: 40px;
padding: 10px;
background: #f8f8f8;
border-radius: 5px;
margin-top: 10px;
}
.save-section {
margin-top: 10px;
display: flex;
gap: 10px;
}
.save-button {
flex: 1;
background: #4CAF50;
}
.auto-save-indicator {
padding: 5px;
color: #666;
font-size: 0.8em;
text-align: right;
}
.card-history {
margin-top: 10px;
max-height: 150px;
overflow-y: auto;
background: #f8f8f8;
border-radius: 5px;
padding: 10px;
}
.card-history-item {
padding: 5px;
border-bottom: 1px solid #eee;
font-size: 0.9em;
display: flex;
justify-content: space-between;
}
.card-history-item:last-child {
border-bottom: none;
}
.history-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 5px;
}
.clear-history {
font-size: 0.8em;
padding: 3px 8px;
background: #ff4444;
}
.red-card {
color: #ff0000;
}
.instructions-panel {
background: #fffdf7;
border-radius: 10px;
padding: 15px;
margin-bottom: 20px;
border: 1px solid #e0dcd0;
}
.dice-pool-info {
font-size: 0.9em;
color: #666;
margin-top: 5px;
padding: 5px;
background: #f8f8f8;
border-radius: 3px;
}
.stability-critical {
color: #ff4444;
font-weight: bold;
}
.stability-warning {
color: #ff8c00;
}
.stability-safe {
color: #4CAF50;
}
.collapse-message {
color: #ff4444;
font-weight: bold;
font-size: 1.2em;
text-align: center;
padding: 20px;
background: #fff8f8;
border-radius: 5px;
margin-top: 10px;
border: 2px solid #ff4444;
}
.narrative-message {
font-style: italic;
padding: 15px;
border-radius: 5px;
margin-top: 10px;
text-align: center;
}
.safe-message {
background: #f0f8f0;
color: #2e7d32;
}
.warning-message {
background: #fff3e0;
color: #ef6c00;
}
.salvation-controls {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.salvation-value {
display: flex;
align-items: center;
gap: 10px;
}
.salvation-value button {
width: 30px;
padding: 5px;
margin: 0;
}
.salvation-value span {
font-size: 1.2em;
font-weight: bold;
min-width: 30px;
text-align: center;
}
.salvation-checkbox {
display: flex;
align-items: center;
gap: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="fate-panel">
<h2>Fate</h2>
<div class="section">
<h3>Roll 2d6</h3>
<div class="dice-container">
<div class="die" id="die1">-</div>
<div class="die" id="die2">-</div>
</div>
<button onclick="rollDice()">Roll Dice</button>
<div class="result" id="diceResult">Total: -</div>
</div>
<div class="section">
<h3>Draw Card</h3>
<button onclick="drawCard()">Draw Card</button>
<div class="card-display" id="cardResult">No card drawn</div>
<div class="deck-info">
<span id="remainingCards"></span>
<button onclick="reshuffleDeck()" id="reshuffleButton" style="display: none;">Reshuffle Deck</button>
</div>
<div class="history-header">
<h4>Card History</h4>
<button class="clear-history" onclick="clearHistory()">Clear</button>
</div>
<div class="card-history" id="cardHistory"></div>
</div>
<div class="section">
<h3>Tower Pull</h3>
<button onclick="towerPull()" id="pullButton">Pull Block</button>
<div class="result" id="towerResult" class="narrative-message">The tower stands steady, waiting for the first pull...</div>
<div class="dice-pool-info" id="dicePoolInfo"></div>
</div>
<div class="section">
<h3>Salvation (Ace of Hearts)</h3>
<p>This counter represents your tokens.</p>
<div class="salvation-controls">
<div class="salvation-value">
<button onclick="adjustSalvation(-1)">-</button>
<span id="salvationValue">10</span>
<button onclick="adjustSalvation(1)">+</button>
</div>
<div class="salvation-checkbox">
<input type="checkbox" id="countUp">
<label for="countUp">Count up?</label>
</div>
</div>
<div class="dice-container">
<div class="die" id="salvationDie">-</div>
</div>
<button onclick="rollSalvationDie()">Roll Die</button>
<div class="result" id="salvationResult">Ready to roll...</div>
</div>
<p><small><i>Games, then, are a unique social technology. They are a method for inscribing forms of agency into artifactual vessels: for recording them, preserving them, and passing them around. And we possess a special ability; we can submerge ourselves in alternate agencies designed by another. In other words, we can use games to communicate forms of agency.</i><br> C Thi Nguyen <i>Games: Agency as Art</i> 2020: 1.</small></p>
</div>
<div class="journal-panel">
<div class="instructions-panel">
<h2>Wretched & Alone Game Pad</h2>
<h3>by Shawn Graham</h3>
<div id="instructions">
This site is meant to help you play solo journaling RPGs made using the <a href="https://sealedlibrary.itch.io/wretched-alone-srd">'Wretched & Alone'</a> system by Chris Bissette.
<select id="gameSelector" onchange="openGameWindow()">
<option value="">Select a game...</option>
<option value="https://shawngraham.github.io/solo-rpg/Whoever%20Finds%20This%20Paper%20v1.0%20S%20Graham.pdf">Whoever Finds This Paper v1 by S Graham</option>
<option value="https://shawngraham.github.io/solo-rpg/The%20Cave%20v1.0%20Shawn%20Graham.pdf">The Cave v1 by S Graham</option>
<option value="https://shawngraham.github.io/solo-rpg/In%20The%20Forest%20Dark%20v1.0%20Shawn%20Graham.pdf">In The Forest Dark v1 by S Graham</option>
<option value="https://shawngraham.github.io/solo-rpg/Degrees%20of%20Difficulty%20v1.0%20by%20Shawn%20Graham.pdf">Degrees of Difficulty by S Graham</option>
</select>
</div>
</div>
<h2>Journal</h2>
<div class="auto-save-indicator" id="saveIndicator"></div>
<textarea id="journal" placeholder="Record your adventure here..." oninput="autoSave()"></textarea>
<div class="save-section">
<button class="save-button" onclick="downloadJournal()">Save to File</button>
<button class="save-button" onclick="loadFile()">Load File</button>
</div>
<input type="file" id="fileInput" style="display: none;" onchange="handleFileLoad(event)">
</div>
</div>
<script>
function openGameWindow() {
const selector = document.getElementById('gameSelector');
const selectedValue = selector.value;
if (selectedValue) {
window.open(selectedValue, '_blank');
selector.selectedIndex = 0; // Reset the selection
}
}
// Dice Rolling
function rollDice() {
const die1 = Math.floor(Math.random() * 6) + 1;
const die2 = Math.floor(Math.random() * 6) + 1;
document.getElementById('die1').textContent = die1;
document.getElementById('die2').textContent = die2;
document.getElementById('diceResult').textContent = `Total: ${die1 + die2}`;
}
// Card Drawing with History
let deck = [];
let cardHistory = [];
const maxHistoryLength = 50;
function initializeDeck() {
const suits = ['♠', '♣', '♥', '♦'];
const values = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'];
deck = [];
for (let suit of suits) {
for (let value of values) {
deck.push(`${value}${suit}`);
}
}
updateDeckInfo();
}
function drawCard() {
if (deck.length === 0) {
document.getElementById('reshuffleButton').style.display = 'block';
document.getElementById('cardResult').textContent = 'Deck is empty! Please reshuffle.';
return;
}
const randomIndex = Math.floor(Math.random() * deck.length);
const card = deck.splice(randomIndex, 1)[0];
const timestamp = new Date().toLocaleTimeString();
// Add to history
cardHistory.unshift({
card: card,
timestamp: timestamp,
remainingCards: deck.length
});
// Limit history length
if (cardHistory.length > maxHistoryLength) {
cardHistory.pop();
}
// Update display
document.getElementById('cardResult').textContent = card;
updateDeckInfo();
updateHistoryDisplay();
// Save history to localStorage
localStorage.setItem('cardHistory', JSON.stringify(cardHistory));
}
function reshuffleDeck() {
initializeDeck();
document.getElementById('reshuffleButton').style.display = 'none';
document.getElementById('cardResult').textContent = 'Deck reshuffled';
updateHistoryDisplay();
}
function updateDeckInfo() {
document.getElementById('remainingCards').textContent =
`Remaining cards: ${deck.length}/52`;
}
function updateHistoryDisplay() {
const historyDiv = document.getElementById('cardHistory');
historyDiv.innerHTML = '';
cardHistory.forEach(entry => {
const historyItem = document.createElement('div');
historyItem.className = 'card-history-item';
// Check if card is red (hearts or diamonds)
const isRed = entry.card.includes('♥') || entry.card.includes('♦');
const cardSpan = document.createElement('span');
cardSpan.textContent = entry.card;
if (isRed) cardSpan.className = 'red-card';
const timeSpan = document.createElement('span');
timeSpan.textContent = entry.timestamp;
historyItem.appendChild(cardSpan);
historyItem.appendChild(timeSpan);
historyDiv.appendChild(historyItem);
});
}
function clearHistory() {
cardHistory = [];
updateHistoryDisplay();
localStorage.setItem('cardHistory', JSON.stringify(cardHistory));
}
// Jenga Simulation
const safeMessages = [
"The tower wobbles, but is ok",
"The tower shifts slightly as you pull out the block",
"The tower leans somewhat, but remains stable",
"A gentle sway, but the tower holds firm",
"The blocks settle into their new position",
"The tower adjusts to the change with minimal movement",
"A successful pull, the tower barely notices",
"Nothing much happens - for now",
"Phew, all is ok",
"It wobbles a bit, but settles",
"Easy peasy",
"Nicely done. The tower is structurally sound, still"
];
const dangerMessages = [
"The tower is leaning quite dangerously",
"The tower sways as you touch it",
"The tower is in imminent danger of collapse",
"The structure groans under its own weight",
"The blocks shift precariously",
"Each movement threatens to bring it all down",
"The tower teeters on the edge of disaster",
"Your hands shake as you pull the block free",
"Your hand slipped, knocking some blocks askew. Careful!",
"Things are starting to get dangerous",
"Gently... gently dammit!",
"The blocks are barely carrying the weight",
"Watch out, things are getting dicey",
"Pull... careful, careful! The tower shifts as you pull",
"Hold your breath, anything could bring it down it seems"
];
function getRandomMessage(array) {
return array[Math.floor(Math.random() * array.length)];
}
let dicePool = 100;
function rollDicePool() {
let ones = 0;
for (let i = 0; i < dicePool; i++) {
if (Math.floor(Math.random() * 6) + 1 === 1) {
ones++;
}
}
return ones;
}
function getStabilityClass(remainingDice) {
if (remainingDice <= 20) return 'stability-critical';
if (remainingDice <= 50) return 'stability-warning';
return 'stability-safe';
}
function towerPull() {
if (dicePool <= 0) {
showGameEnd();
return;
}
const removedDice = rollDicePool();
dicePool -= removedDice;
if (dicePool <= 0) {
showGameEnd();
return;
}
const messageElement = document.getElementById('towerResult');
if (dicePool > 50) {
messageElement.className = 'narrative-message safe-message';
messageElement.textContent = getRandomMessage(safeMessages);
} else {
messageElement.className = 'narrative-message warning-message';
messageElement.textContent = getRandomMessage(dangerMessages);
}
const stabilityClass = getStabilityClass(dicePool);
document.getElementById('dicePoolInfo').innerHTML =
`<span class="${stabilityClass}">Stability Level: ${dicePool > 50 ? 'Stable' : 'Unstable'}</span>`;
localStorage.setItem('towerState', JSON.stringify({
dicePool: dicePool,
messageState: messageElement.textContent
}));
}
function showGameEnd() {
document.getElementById('towerResult').innerHTML =
'<div class="collapse-message">The tower groans one final time before cascading down in a thunderous crash! Game Over.</div>';
document.getElementById('dicePoolInfo').innerHTML = '';
document.getElementById('pullButton').disabled = true;
const resetButton = document.createElement('button');
resetButton.onclick = resetTower;
resetButton.textContent = 'Build New Tower';
resetButton.style.marginTop = '20px';
document.getElementById('towerResult').appendChild(resetButton);
}
function resetTower() {
dicePool = 100;
document.getElementById('towerResult').className = 'narrative-message safe-message';
document.getElementById('towerResult').textContent = 'A fresh tower stands before you, solid and stable.';
document.getElementById('dicePoolInfo').innerHTML =
`<span class="stability-safe">Stability Level: Stable</span>`;
document.getElementById('pullButton').disabled = false;
localStorage.setItem('towerState', JSON.stringify({
dicePool: dicePool,
messageState: 'A fresh tower stands before you, solid and stable.'
}));
}
// Journal Auto-save
let saveTimeout;
function autoSave() {
clearTimeout(saveTimeout);
document.getElementById('saveIndicator').textContent = 'Saving...';
saveTimeout = setTimeout(() => {
const text = document.getElementById('journal').value;
localStorage.setItem('journalContent', text);
const now = new Date().toLocaleTimeString();
document.getElementById('saveIndicator').textContent = `Last auto-saved at ${now}`;
}, 1000);
}
// Function to download journal as a file
function downloadJournal() {
const text = document.getElementById('journal').value;
const blob = new Blob([text], { type: 'text/plain' });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
a.href = url;
a.download = `rpg-journal-${timestamp}.txt`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}
// Function to trigger file input
function loadFile() {
document.getElementById('fileInput').click();
}
// Function to handle file loading
function handleFileLoad(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('journal').value = e.target.result;
autoSave(); // Save the loaded content to localStorage
};
reader.readAsText(file);
}
}
let salvationValue = 10;
function adjustSalvation(amount) {
salvationValue += amount;
document.getElementById('salvationValue').textContent = salvationValue;
localStorage.setItem('salvationValue', salvationValue);
}
function rollSalvationDie() {
const dieResult = Math.floor(Math.random() * 6) + 1;
document.getElementById('salvationDie').textContent = dieResult;
const countUp = document.getElementById('countUp').checked;
const resultElement = document.getElementById('salvationResult');
if (dieResult === 6) {
if (countUp) {
adjustSalvation(1);
resultElement.textContent = 'Rolled a 6! Chances of salvation increase';
} else {
adjustSalvation(-1);
resultElement.textContent = 'Rolled a 6! Chances of salvation increase';
}
} else {
resultElement.textContent = `Rolled a ${dieResult}. Your chances remain...unchanged.`;
}
}
// Window load handler to restore state
window.onload = function() {
const savedTowerState = localStorage.getItem('towerState');
if (savedTowerState) {
const state = JSON.parse(savedTowerState);
dicePool = state.dicePool;
if (dicePool <= 20) {
showGameEnd();
} else {
const messageElement = document.getElementById('towerResult');
messageElement.textContent = state.messageState || 'The tower stands steady...';
messageElement.className = `narrative-message ${dicePool > 50 ? 'safe-message' : 'warning-message'}`;
const stabilityClass = getStabilityClass(dicePool);
document.getElementById('dicePoolInfo').innerHTML =
`<span class="${stabilityClass}">Stability Level: ${dicePool > 50 ? 'Stable' : 'Unstable'}</span>`;
}
} else {
resetTower();
}
initializeDeck();
const savedJournal = localStorage.getItem('journalContent');
if (savedJournal) {
document.getElementById('journal').value = savedJournal;
}
const savedCardHistory = localStorage.getItem('cardHistory');
if (savedCardHistory) {
cardHistory = JSON.parse(savedCardHistory);
updateHistoryDisplay();
}
const savedSalvationValue = localStorage.getItem('salvationValue');
if (savedSalvationValue !== null) {
salvationValue = parseInt(savedSalvationValue);
document.getElementById('salvationValue').textContent = salvationValue;
}
};
</script>
</body>
</html>