Spaces:
Sleeping
Sleeping
gale state update
Browse files- static/game/gameState.js +11 -5
- static/maker/index.html +39 -1
static/game/gameState.js
CHANGED
@@ -16,12 +16,18 @@
|
|
16 |
"North Hallway"
|
17 |
];
|
18 |
|
19 |
-
this.hideTargets = [
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
this.searchTargets = ["dresser", "
|
22 |
-
|
23 |
-
this.items = ["lock pick", "flashlight", "knife", "remote"];
|
24 |
-
|
|
|
25 |
|
26 |
// Track current game state
|
27 |
this.currentRoom = this.rooms[0];
|
|
|
16 |
"North Hallway"
|
17 |
];
|
18 |
|
19 |
+
this.hideTargets = [
|
20 |
+
{"room": "My Bedroom", "hiding_place": "bed"},
|
21 |
+
{"room": "North Hallway", "hiding_place": "coat closet"},
|
22 |
+
{"room": "Dining Room", "hiding_place": "table"},
|
23 |
+
{"room": "Guest Bedroom", "hiding_place": "bed"}
|
24 |
+
]
|
25 |
|
26 |
+
this.searchTargets = ["dresser", "desk", "bookcase", "cabinet", "dead body", "fridge", "stove", "coffee table"];
|
27 |
+
|
28 |
+
this.items = ["lock pick", "book note", "flashlight", "knife", "oil", "remote"];
|
29 |
+
|
30 |
+
this.useTargets = ["bedroom door", "bookcase", "storage door", "dead body","coffee table","TV"];
|
31 |
|
32 |
// Track current game state
|
33 |
this.currentRoom = this.rooms[0];
|
static/maker/index.html
CHANGED
@@ -57,6 +57,7 @@
|
|
57 |
|
|
58 |
<button onclick="saveMap()">Save Map</button>
|
59 |
<button onclick="loadMap()">Load Map</button>
|
|
|
60 |
|
|
61 |
<input type="number" id="gridCols" value="40" min="1" style="width: 60px"> ×
|
62 |
<input type="number" id="gridRows" value="20" min="1" style="width: 60px">
|
@@ -69,7 +70,7 @@
|
|
69 |
<!-- Move the JSON text areas here so they appear after the editor and canvas -->
|
70 |
<div style="margin-top: 20px; width: 100%; max-width: 1200px; text-align: center;">
|
71 |
<textarea id="roomsJson" readonly style="width: 90%; height: 100px; margin: 10px; padding: 10px;" placeholder="Rooms will appear here in JSON format"></textarea>
|
72 |
-
<textarea id="gameJson"
|
73 |
</div>
|
74 |
|
75 |
<script>
|
@@ -481,6 +482,43 @@
|
|
481 |
updateGameJson(); // Update game JSON after loading
|
482 |
}
|
483 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
function removeSelectedRoom() {
|
485 |
const roomName = document.getElementById('roomSelect').value;
|
486 |
if (!roomName) return;
|
|
|
57 |
|
|
58 |
<button onclick="saveMap()">Save Map</button>
|
59 |
<button onclick="loadMap()">Load Map</button>
|
60 |
+
<button onclick="loadFromJson()">Load from JSON</button>
|
61 |
|
|
62 |
<input type="number" id="gridCols" value="40" min="1" style="width: 60px"> ×
|
63 |
<input type="number" id="gridRows" value="20" min="1" style="width: 60px">
|
|
|
70 |
<!-- Move the JSON text areas here so they appear after the editor and canvas -->
|
71 |
<div style="margin-top: 20px; width: 100%; max-width: 1200px; text-align: center;">
|
72 |
<textarea id="roomsJson" readonly style="width: 90%; height: 100px; margin: 10px; padding: 10px;" placeholder="Rooms will appear here in JSON format"></textarea>
|
73 |
+
<textarea id="gameJson" style="width: 90%; height: 200px; margin: 10px; padding: 10px;" placeholder="Complete game definition will appear here in JSON format"></textarea>
|
74 |
</div>
|
75 |
|
76 |
<script>
|
|
|
482 |
updateGameJson(); // Update game JSON after loading
|
483 |
}
|
484 |
|
485 |
+
function loadFromJson() {
|
486 |
+
const gameJson = document.getElementById('gameJson').value;
|
487 |
+
if (!gameJson) {
|
488 |
+
alert('Please paste a valid game JSON in the textarea below');
|
489 |
+
return;
|
490 |
+
}
|
491 |
+
|
492 |
+
try {
|
493 |
+
const data = JSON.parse(gameJson);
|
494 |
+
|
495 |
+
// Validate required fields
|
496 |
+
if (!data.grid || !Array.isArray(data.grid)) {
|
497 |
+
throw new Error('Invalid grid data');
|
498 |
+
}
|
499 |
+
|
500 |
+
// Update grid dimensions and input fields
|
501 |
+
GRID_COLS = data.gridCols || data.grid[0].length;
|
502 |
+
GRID_ROWS = data.gridRows || data.grid.length;
|
503 |
+
document.getElementById('gridCols').value = GRID_COLS;
|
504 |
+
document.getElementById('gridRows').value = GRID_ROWS;
|
505 |
+
|
506 |
+
// Resize canvas and initialize grid
|
507 |
+
resizeCanvas(GRID_COLS * CELL_SIZE, GRID_ROWS * CELL_SIZE);
|
508 |
+
initGrid();
|
509 |
+
|
510 |
+
// Load saved data
|
511 |
+
grid = data.grid;
|
512 |
+
rooms = new Map(data.rooms || []);
|
513 |
+
characterPos = data.characterPos;
|
514 |
+
|
515 |
+
updateRoomDropdown();
|
516 |
+
updateGameJson();
|
517 |
+
} catch (error) {
|
518 |
+
alert('Error loading JSON: ' + error.message);
|
519 |
+
}
|
520 |
+
}
|
521 |
+
|
522 |
function removeSelectedRoom() {
|
523 |
const roomName = document.getElementById('roomSelect').value;
|
524 |
if (!roomName) return;
|