Spaces:
Running
Running
Update backup2.index.html
Browse files- backup2.index.html +806 -79
backup2.index.html
CHANGED
|
@@ -3,15 +3,15 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Choose Your Own
|
| 7 |
<style>
|
| 8 |
body {
|
| 9 |
font-family: 'Courier New', monospace;
|
| 10 |
-
background-color: #222;
|
| 11 |
-
color: #eee;
|
| 12 |
margin: 0;
|
| 13 |
padding: 0;
|
| 14 |
-
overflow: hidden;
|
| 15 |
display: flex;
|
| 16 |
flex-direction: column;
|
| 17 |
height: 100vh;
|
|
@@ -19,126 +19,118 @@
|
|
| 19 |
|
| 20 |
#game-container {
|
| 21 |
display: flex;
|
| 22 |
-
flex-grow: 1;
|
| 23 |
-
overflow: hidden;
|
| 24 |
}
|
| 25 |
|
| 26 |
#scene-container {
|
| 27 |
-
flex-grow: 3;
|
| 28 |
-
position: relative;
|
| 29 |
border-right: 2px solid #555;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
#ui-container {
|
| 33 |
-
flex-grow: 2;
|
| 34 |
padding: 20px;
|
| 35 |
-
overflow-y: auto;
|
| 36 |
background-color: #333;
|
|
|
|
|
|
|
|
|
|
| 37 |
display: flex;
|
| 38 |
flex-direction: column;
|
| 39 |
}
|
| 40 |
|
|
|
|
|
|
|
| 41 |
#story-title {
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
#story-content {
|
| 49 |
margin-bottom: 20px;
|
| 50 |
line-height: 1.6;
|
|
|
|
| 51 |
}
|
| 52 |
-
|
| 53 |
-
#
|
| 54 |
-
margin-top: auto; /* Push choices towards the bottom */
|
| 55 |
-
padding-top: 15px;
|
| 56 |
-
border-top: 1px solid #555;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
#choices-container h3 {
|
| 60 |
-
margin-top: 0;
|
| 61 |
-
margin-bottom: 10px;
|
| 62 |
-
color: #aaa;
|
| 63 |
-
}
|
| 64 |
-
|
| 65 |
-
.choice-button {
|
| 66 |
-
display: block;
|
| 67 |
-
width: calc(100% - 20px); /* Adjust width */
|
| 68 |
-
padding: 10px;
|
| 69 |
-
margin-bottom: 10px;
|
| 70 |
-
background-color: #555;
|
| 71 |
-
color: #eee;
|
| 72 |
-
border: 1px solid #777;
|
| 73 |
-
border-radius: 5px;
|
| 74 |
-
cursor: pointer;
|
| 75 |
-
text-align: left;
|
| 76 |
-
font-family: 'Courier New', monospace;
|
| 77 |
-
font-size: 1em;
|
| 78 |
-
transition: background-color 0.2s;
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
.choice-button:hover {
|
| 82 |
-
background-color: #d4a017; /* Gold hover */
|
| 83 |
-
color: #222;
|
| 84 |
-
}
|
| 85 |
-
.choice-button:disabled {
|
| 86 |
-
background-color: #444;
|
| 87 |
-
color: #888;
|
| 88 |
-
cursor: not-allowed;
|
| 89 |
-
border-color: #666;
|
| 90 |
-
}
|
| 91 |
|
| 92 |
#stats-inventory-container {
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
}
|
| 98 |
#stats-display, #inventory-display {
|
| 99 |
margin-bottom: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
}
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
padding: 3px 8px;
|
| 105 |
-
border-radius: 15px;
|
| 106 |
-
margin-right: 8px;
|
| 107 |
-
margin-bottom: 5px; /* Wrap nicely */
|
| 108 |
-
border: 1px solid #666;
|
| 109 |
-
}
|
| 110 |
#inventory-display .item-quest { background-color: #666030; border-color: #999048;}
|
| 111 |
#inventory-display .item-weapon { background-color: #663030; border-color: #994848;}
|
| 112 |
#inventory-display .item-armor { background-color: #306630; border-color: #489948;}
|
| 113 |
#inventory-display .item-spell { background-color: #303066; border-color: #484899;}
|
|
|
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
|
|
|
|
|
|
| 118 |
</style>
|
| 119 |
</head>
|
| 120 |
<body>
|
| 121 |
-
|
| 122 |
<div id="game-container">
|
| 123 |
<div id="scene-container"></div>
|
| 124 |
-
|
| 125 |
<div id="ui-container">
|
| 126 |
<h2 id="story-title">Loading Adventure...</h2>
|
| 127 |
<div id="story-content">
|
| 128 |
<p>Please wait while the adventure loads.</p>
|
| 129 |
</div>
|
| 130 |
-
|
| 131 |
<div id="stats-inventory-container">
|
| 132 |
-
<div id="stats-display">
|
| 133 |
-
|
| 134 |
-
<div id="inventory-display">
|
| 135 |
-
</div>
|
| 136 |
</div>
|
| 137 |
-
|
| 138 |
<div id="choices-container">
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
</div>
|
| 142 |
</div>
|
| 143 |
</div>
|
| 144 |
</div>
|
|
@@ -152,7 +144,742 @@
|
|
| 152 |
}
|
| 153 |
</script>
|
| 154 |
|
| 155 |
-
<script type="module"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Choose Your Own Procedural Adventure</title>
|
| 7 |
<style>
|
| 8 |
body {
|
| 9 |
font-family: 'Courier New', monospace;
|
| 10 |
+
background-color: #222;
|
| 11 |
+
color: #eee;
|
| 12 |
margin: 0;
|
| 13 |
padding: 0;
|
| 14 |
+
overflow: hidden;
|
| 15 |
display: flex;
|
| 16 |
flex-direction: column;
|
| 17 |
height: 100vh;
|
|
|
|
| 19 |
|
| 20 |
#game-container {
|
| 21 |
display: flex;
|
| 22 |
+
flex-grow: 1;
|
| 23 |
+
overflow: hidden;
|
| 24 |
}
|
| 25 |
|
| 26 |
#scene-container {
|
| 27 |
+
flex-grow: 3;
|
| 28 |
+
position: relative;
|
| 29 |
border-right: 2px solid #555;
|
| 30 |
+
min-width: 200px;
|
| 31 |
+
background-color: #1a1a1a;
|
| 32 |
+
height: 100%;
|
| 33 |
+
box-sizing: border-box;
|
| 34 |
}
|
| 35 |
|
| 36 |
#ui-container {
|
| 37 |
+
flex-grow: 2;
|
| 38 |
padding: 20px;
|
| 39 |
+
overflow-y: auto;
|
| 40 |
background-color: #333;
|
| 41 |
+
min-width: 280px;
|
| 42 |
+
height: 100%;
|
| 43 |
+
box-sizing: border-box;
|
| 44 |
display: flex;
|
| 45 |
flex-direction: column;
|
| 46 |
}
|
| 47 |
|
| 48 |
+
#scene-container canvas { display: block; }
|
| 49 |
+
|
| 50 |
#story-title {
|
| 51 |
+
color: #ffcc66;
|
| 52 |
+
margin-top: 0;
|
| 53 |
+
margin-bottom: 15px;
|
| 54 |
+
border-bottom: 1px solid #555;
|
| 55 |
+
padding-bottom: 10px;
|
| 56 |
+
font-size: 1.4em;
|
| 57 |
}
|
| 58 |
|
| 59 |
#story-content {
|
| 60 |
margin-bottom: 20px;
|
| 61 |
line-height: 1.6;
|
| 62 |
+
flex-grow: 1;
|
| 63 |
}
|
| 64 |
+
#story-content p { margin-bottom: 1em; }
|
| 65 |
+
#story-content p:last-child { margin-bottom: 0; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
#stats-inventory-container {
|
| 68 |
+
margin-bottom: 20px;
|
| 69 |
+
padding-bottom: 15px;
|
| 70 |
+
border-bottom: 1px solid #555;
|
| 71 |
+
font-size: 0.9em;
|
| 72 |
}
|
| 73 |
#stats-display, #inventory-display {
|
| 74 |
margin-bottom: 10px;
|
| 75 |
+
line-height: 1.8;
|
| 76 |
+
}
|
| 77 |
+
#stats-display span, #inventory-display span {
|
| 78 |
+
display: inline-block;
|
| 79 |
+
background-color: #444;
|
| 80 |
+
padding: 3px 8px;
|
| 81 |
+
border-radius: 15px;
|
| 82 |
+
margin-right: 8px;
|
| 83 |
+
margin-bottom: 5px;
|
| 84 |
+
border: 1px solid #666;
|
| 85 |
+
white-space: nowrap;
|
| 86 |
}
|
| 87 |
+
#stats-display strong, #inventory-display strong { color: #aaa; margin-right: 5px; }
|
| 88 |
+
#inventory-display em { color: #888; font-style: normal; }
|
| 89 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
#inventory-display .item-quest { background-color: #666030; border-color: #999048;}
|
| 91 |
#inventory-display .item-weapon { background-color: #663030; border-color: #994848;}
|
| 92 |
#inventory-display .item-armor { background-color: #306630; border-color: #489948;}
|
| 93 |
#inventory-display .item-spell { background-color: #303066; border-color: #484899;}
|
| 94 |
+
#inventory-display .item-unknown { background-color: #555; border-color: #777;}
|
| 95 |
|
| 96 |
+
#choices-container {
|
| 97 |
+
margin-top: auto;
|
| 98 |
+
padding-top: 15px;
|
| 99 |
+
border-top: 1px solid #555;
|
| 100 |
+
}
|
| 101 |
+
#choices-container h3 { margin-top: 0; margin-bottom: 10px; color: #aaa; }
|
| 102 |
+
#choices { display: flex; flex-direction: column; gap: 10px; }
|
| 103 |
|
| 104 |
+
.choice-button {
|
| 105 |
+
display: block; width: 100%; padding: 10px 12px; margin-bottom: 0;
|
| 106 |
+
background-color: #555; color: #eee; border: 1px solid #777;
|
| 107 |
+
border-radius: 5px; cursor: pointer; text-align: left;
|
| 108 |
+
font-family: 'Courier New', monospace; font-size: 1em;
|
| 109 |
+
transition: background-color 0.2s, border-color 0.2s;
|
| 110 |
+
box-sizing: border-box;
|
| 111 |
+
}
|
| 112 |
+
.choice-button:hover:not(:disabled) { background-color: #d4a017; color: #222; border-color: #b8860b; }
|
| 113 |
+
.choice-button:disabled { background-color: #444; color: #888; cursor: not-allowed; border-color: #666; opacity: 0.7; }
|
| 114 |
|
| 115 |
+
.roll-success { color: #7f7; border-left: 3px solid #4a4; padding-left: 8px; margin-bottom: 1em; font-size: 0.9em; }
|
| 116 |
+
.roll-failure { color: #f77; border-left: 3px solid #a44; padding-left: 8px; margin-bottom: 1em; font-size: 0.9em; }
|
| 117 |
</style>
|
| 118 |
</head>
|
| 119 |
<body>
|
|
|
|
| 120 |
<div id="game-container">
|
| 121 |
<div id="scene-container"></div>
|
|
|
|
| 122 |
<div id="ui-container">
|
| 123 |
<h2 id="story-title">Loading Adventure...</h2>
|
| 124 |
<div id="story-content">
|
| 125 |
<p>Please wait while the adventure loads.</p>
|
| 126 |
</div>
|
|
|
|
| 127 |
<div id="stats-inventory-container">
|
| 128 |
+
<div id="stats-display"></div>
|
| 129 |
+
<div id="inventory-display"></div>
|
|
|
|
|
|
|
| 130 |
</div>
|
|
|
|
| 131 |
<div id="choices-container">
|
| 132 |
+
<h3>What will you do?</h3>
|
| 133 |
+
<div id="choices"></div>
|
|
|
|
| 134 |
</div>
|
| 135 |
</div>
|
| 136 |
</div>
|
|
|
|
| 144 |
}
|
| 145 |
</script>
|
| 146 |
|
| 147 |
+
<script type="module">
|
| 148 |
+
import * as THREE from 'three';
|
| 149 |
+
|
| 150 |
+
const sceneContainer = document.getElementById('scene-container');
|
| 151 |
+
const storyTitleElement = document.getElementById('story-title');
|
| 152 |
+
const storyContentElement = document.getElementById('story-content');
|
| 153 |
+
const choicesElement = document.getElementById('choices');
|
| 154 |
+
const statsElement = document.getElementById('stats-display');
|
| 155 |
+
const inventoryElement = document.getElementById('inventory-display');
|
| 156 |
+
|
| 157 |
+
let scene, camera, renderer;
|
| 158 |
+
let currentAssemblyGroup = null;
|
| 159 |
+
|
| 160 |
+
// Materials
|
| 161 |
+
const stoneMaterial = new THREE.MeshStandardMaterial({ color: 0x888888, roughness: 0.8, metalness: 0.1 });
|
| 162 |
+
const woodMaterial = new THREE.MeshStandardMaterial({ color: 0x8B4513, roughness: 0.7, metalness: 0 });
|
| 163 |
+
const darkWoodMaterial = new THREE.MeshStandardMaterial({ color: 0x5C3D20, roughness: 0.7, metalness: 0 });
|
| 164 |
+
const leafMaterial = new THREE.MeshStandardMaterial({ color: 0x2E8B57, roughness: 0.6, metalness: 0 });
|
| 165 |
+
const groundMaterial = new THREE.MeshStandardMaterial({ color: 0x556B2F, roughness: 0.9, metalness: 0 });
|
| 166 |
+
const metalMaterial = new THREE.MeshStandardMaterial({ color: 0xaaaaaa, metalness: 0.8, roughness: 0.3 });
|
| 167 |
+
const templeMaterial = new THREE.MeshStandardMaterial({ color: 0xA99B78, roughness: 0.7, metalness: 0.1 });
|
| 168 |
+
const errorMaterial = new THREE.MeshStandardMaterial({ color: 0xffa500, roughness: 0.5 });
|
| 169 |
+
const gameOverMaterial = new THREE.MeshStandardMaterial({ color: 0xff0000, roughness: 0.5 });
|
| 170 |
+
const dirtMaterial = new THREE.MeshStandardMaterial({ color: 0x8B5E3C, roughness: 0.9 });
|
| 171 |
+
const grassMaterial = new THREE.MeshStandardMaterial({ color: 0x3CB371, roughness: 0.8 });
|
| 172 |
+
const oceanMaterial = new THREE.MeshStandardMaterial({ color: 0x1E90FF, roughness: 0.5, metalness: 0.2 });
|
| 173 |
+
const sandMaterial = new THREE.MeshStandardMaterial({ color: 0xF4A460, roughness: 0.9 });
|
| 174 |
+
const wetStoneMaterial = new THREE.MeshStandardMaterial({ color: 0x2F4F4F, roughness: 0.7 });
|
| 175 |
+
const glowMaterial = new THREE.MeshStandardMaterial({ color: 0x00FFAA, emissive: 0x00FFAA, emissiveIntensity: 0.5 });
|
| 176 |
+
|
| 177 |
+
function initThreeJS() {
|
| 178 |
+
if (!sceneContainer) { console.error("Scene container not found!"); return; }
|
| 179 |
+
scene = new THREE.Scene();
|
| 180 |
+
scene.background = new THREE.Color(0x222222);
|
| 181 |
+
const width = sceneContainer.clientWidth;
|
| 182 |
+
const height = sceneContainer.clientHeight;
|
| 183 |
+
camera = new THREE.PerspectiveCamera(75, (width / height) || 1, 0.1, 1000);
|
| 184 |
+
camera.position.set(0, 2.5, 7);
|
| 185 |
+
camera.lookAt(0, 0.5, 0);
|
| 186 |
+
renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 187 |
+
renderer.setSize(width || 400, height || 300);
|
| 188 |
+
renderer.shadowMap.enabled = true;
|
| 189 |
+
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
| 190 |
+
sceneContainer.appendChild(renderer.domElement);
|
| 191 |
+
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
|
| 192 |
+
scene.add(ambientLight);
|
| 193 |
+
window.addEventListener('resize', onWindowResize, false);
|
| 194 |
+
setTimeout(onWindowResize, 100);
|
| 195 |
+
animate();
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
function onWindowResize() {
|
| 199 |
+
if (!renderer || !camera || !sceneContainer) return;
|
| 200 |
+
const width = sceneContainer.clientWidth;
|
| 201 |
+
const height = sceneContainer.clientHeight;
|
| 202 |
+
if (width > 0 && height > 0) {
|
| 203 |
+
camera.aspect = width / height;
|
| 204 |
+
camera.updateProjectionMatrix();
|
| 205 |
+
renderer.setSize(width, height);
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
function animate() {
|
| 210 |
+
requestAnimationFrame(animate);
|
| 211 |
+
const time = performance.now() * 0.001;
|
| 212 |
+
scene.traverse(obj => {
|
| 213 |
+
if (obj.userData.update) obj.userData.update(time);
|
| 214 |
+
});
|
| 215 |
+
if (renderer && scene && camera) {
|
| 216 |
+
renderer.render(scene, camera);
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
function createMesh(geometry, material, position = { x: 0, y: 0, z: 0 }, rotation = { x: 0, y: 0, z: 0 }, scale = { x: 1, y: 1, z: 1 }) {
|
| 221 |
+
const mesh = new THREE.Mesh(geometry, material);
|
| 222 |
+
mesh.position.set(position.x, position.y, position.z);
|
| 223 |
+
mesh.rotation.set(rotation.x, rotation.y, rotation.z);
|
| 224 |
+
mesh.scale.set(scale.x, scale.y, scale.z);
|
| 225 |
+
mesh.castShadow = true; mesh.receiveShadow = true;
|
| 226 |
+
return mesh;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
function createGroundPlane(material = groundMaterial, size = 20) {
|
| 230 |
+
const groundGeo = new THREE.PlaneGeometry(size, size);
|
| 231 |
+
const ground = new THREE.Mesh(groundGeo, material);
|
| 232 |
+
ground.rotation.x = -Math.PI / 2; ground.position.y = -0.05;
|
| 233 |
+
ground.receiveShadow = true; ground.castShadow = false;
|
| 234 |
+
return ground;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
// Procedural Generation Functions
|
| 238 |
+
function createDefaultAssembly() {
|
| 239 |
+
const group = new THREE.Group();
|
| 240 |
+
const sphereGeo = new THREE.SphereGeometry(0.5, 16, 16);
|
| 241 |
+
group.add(createMesh(sphereGeo, stoneMaterial, { x: 0, y: 0.5, z: 0 }));
|
| 242 |
+
group.add(createGroundPlane());
|
| 243 |
+
return group;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
function createCityGatesAssembly() {
|
| 247 |
+
const group = new THREE.Group();
|
| 248 |
+
const gh=4, gw=1.5, gd=0.8, ah=1, aw=3;
|
| 249 |
+
const tlGeo = new THREE.BoxGeometry(gw, gh, gd);
|
| 250 |
+
group.add(createMesh(tlGeo, stoneMaterial, { x:-(aw/2+gw/2), y:gh/2, z:0 }));
|
| 251 |
+
const trGeo = new THREE.BoxGeometry(gw, gh, gd);
|
| 252 |
+
group.add(createMesh(trGeo, stoneMaterial, { x:(aw/2+gw/2), y:gh/2, z:0 }));
|
| 253 |
+
const aGeo = new THREE.BoxGeometry(aw, ah, gd);
|
| 254 |
+
group.add(createMesh(aGeo, stoneMaterial, { x:0, y:gh-ah/2, z:0 }));
|
| 255 |
+
const cs=0.4;
|
| 256 |
+
const cg = new THREE.BoxGeometry(cs, cs, gd*1.1);
|
| 257 |
+
for(let i=-1; i<=1; i+=2){
|
| 258 |
+
group.add(createMesh(cg.clone(), stoneMaterial, { x:-(aw/2+gw/2)+i*cs*0.7, y:gh+cs/2, z:0 }));
|
| 259 |
+
group.add(createMesh(cg.clone(), stoneMaterial, { x:(aw/2+gw/2)+i*cs*0.7, y:gh+cs/2, z:0 }));
|
| 260 |
+
}
|
| 261 |
+
group.add(createMesh(cg.clone(), stoneMaterial, { x:0, y:gh+ah-cs/2, z:0 }));
|
| 262 |
+
group.add(createGroundPlane(stoneMaterial));
|
| 263 |
+
return group;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
function createWeaponsmithAssembly() {
|
| 267 |
+
const group = new THREE.Group();
|
| 268 |
+
const bw=3, bh=2.5, bd=3.5;
|
| 269 |
+
const bGeo = new THREE.BoxGeometry(bw, bh, bd);
|
| 270 |
+
group.add(createMesh(bGeo, darkWoodMaterial, { x:0, y:bh/2, z:0 }));
|
| 271 |
+
const ch=3.5;
|
| 272 |
+
const cGeo = new THREE.CylinderGeometry(0.3, 0.4, ch, 8);
|
| 273 |
+
group.add(createMesh(cGeo, stoneMaterial, { x:bw*0.3, y:ch/2, z:-bd*0.3 }));
|
| 274 |
+
group.add(createGroundPlane());
|
| 275 |
+
return group;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
function createTempleAssembly() {
|
| 279 |
+
const group = new THREE.Group();
|
| 280 |
+
const bs=5, bsh=0.5, ch=3, cr=0.25, rh=0.5;
|
| 281 |
+
const bGeo = new THREE.BoxGeometry(bs, bsh, bs);
|
| 282 |
+
group.add(createMesh(bGeo, templeMaterial, { x:0, y:bsh/2, z:0 }));
|
| 283 |
+
const cGeo = new THREE.CylinderGeometry(cr, cr, ch, 12);
|
| 284 |
+
const cPos = [{x:-bs/3, z:-bs/3}, {x:bs/3, z:-bs/3}, {x:-bs/3, z:bs/3}, {x:bs/3, z:bs/3}];
|
| 285 |
+
cPos.forEach(p=>group.add(createMesh(cGeo.clone(), templeMaterial, { x:p.x, y:bsh+ch/2, z:p.z })));
|
| 286 |
+
const rGeo = new THREE.BoxGeometry(bs*0.9, rh, bs*0.9);
|
| 287 |
+
group.add(createMesh(rGeo, templeMaterial, { x:0, y:bsh+ch+rh/2, z:0 }));
|
| 288 |
+
group.add(createGroundPlane());
|
| 289 |
+
return group;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
function createResistanceMeetingAssembly() {
|
| 293 |
+
const group = new THREE.Group();
|
| 294 |
+
const tw=2, th=0.8, td=1, tt=0.1;
|
| 295 |
+
const ttg = new THREE.BoxGeometry(tw, tt, td);
|
| 296 |
+
group.add(createMesh(ttg, woodMaterial, { x:0, y:th-tt/2, z:0 }));
|
| 297 |
+
const lh=th-tt, ls=0.1;
|
| 298 |
+
const lg=new THREE.BoxGeometry(ls, lh, ls);
|
| 299 |
+
const lofW=tw/2-ls*1.5;
|
| 300 |
+
const lofD=td/2-ls*1.5;
|
| 301 |
+
group.add(createMesh(lg, woodMaterial, { x:-lofW, y:lh/2, z:-lofD }));
|
| 302 |
+
group.add(createMesh(lg.clone(), woodMaterial, { x:lofW, y:lh/2, z:-lofD }));
|
| 303 |
+
group.add(createMesh(lg.clone(), woodMaterial, { x:-lofW, y:lh/2, z:lofD }));
|
| 304 |
+
group.add(createMesh(lg.clone(), woodMaterial, { x:lofW, y:lh/2, z:lofD }));
|
| 305 |
+
const ss=0.4;
|
| 306 |
+
const sg=new THREE.BoxGeometry(ss, ss*0.8, ss);
|
| 307 |
+
group.add(createMesh(sg, darkWoodMaterial, { x:-tw*0.6, y:ss*0.4, z:0 }));
|
| 308 |
+
group.add(createMesh(sg.clone(), darkWoodMaterial, { x:tw*0.6, y:ss*0.4, z:0 }));
|
| 309 |
+
group.add(createGroundPlane(stoneMaterial));
|
| 310 |
+
return group;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
function createForestAssembly(tc=10, a=10) {
|
| 314 |
+
const group = new THREE.Group();
|
| 315 |
+
const cT=(x,z)=>{
|
| 316 |
+
const tg=new THREE.Group();
|
| 317 |
+
const th=Math.random()*1.5+2;
|
| 318 |
+
const tr=Math.random()*0.1+0.1;
|
| 319 |
+
const tGeo = new THREE.CylinderGeometry(tr*0.7, tr, th, 8);
|
| 320 |
+
tg.add(createMesh(tGeo, woodMaterial, {x:0, y:th/2, z:0}));
|
| 321 |
+
const fr=th*0.4+0.2;
|
| 322 |
+
const fGeo=new THREE.SphereGeometry(fr, 8, 6);
|
| 323 |
+
tg.add(createMesh(fGeo, leafMaterial, {x:0, y:th*0.9, z:0}));
|
| 324 |
+
tg.position.set(x,0,z);
|
| 325 |
+
return tg;
|
| 326 |
+
};
|
| 327 |
+
for(let i=0; i<tc; i++){
|
| 328 |
+
const x=(Math.random()-0.5)*a;
|
| 329 |
+
const z=(Math.random()-0.5)*a;
|
| 330 |
+
if(Math.sqrt(x*x+z*z)>1.0) group.add(cT(x,z));
|
| 331 |
+
}
|
| 332 |
+
group.add(createGroundPlane(groundMaterial, a*1.1));
|
| 333 |
+
return group;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
function createRoadAmbushAssembly() {
|
| 337 |
+
const group = new THREE.Group();
|
| 338 |
+
const a=12;
|
| 339 |
+
const fg = createForestAssembly(8, a);
|
| 340 |
+
group.add(fg);
|
| 341 |
+
const rw=3, rl=a*1.2;
|
| 342 |
+
const rGeo=new THREE.PlaneGeometry(rw, rl);
|
| 343 |
+
const rMat=new THREE.MeshStandardMaterial({color:0x966F33, roughness:0.9});
|
| 344 |
+
const r=createMesh(rGeo, rMat, {x:0, y:0.01, z:0}, {x:-Math.PI/2});
|
| 345 |
+
r.receiveShadow=true;
|
| 346 |
+
group.add(r);
|
| 347 |
+
const rkGeo=new THREE.SphereGeometry(0.5, 5, 4);
|
| 348 |
+
const rkMat=new THREE.MeshStandardMaterial({color:0x666666, roughness:0.8});
|
| 349 |
+
group.add(createMesh(rkGeo, rkMat, {x:rw*0.7, y:0.25, z:1}, {y:Math.random()*Math.PI}));
|
| 350 |
+
group.add(createMesh(rkGeo.clone().scale(0.8,0.8,0.8), rkMat, {x:-rw*0.8, y:0.2, z:-2}, {y:Math.random()*Math.PI}));
|
| 351 |
+
return group;
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
function createForestEdgeAssembly() {
|
| 355 |
+
const group = new THREE.Group();
|
| 356 |
+
const a=15;
|
| 357 |
+
const fg = createForestAssembly(15, a);
|
| 358 |
+
const ttr=[];
|
| 359 |
+
fg.children.forEach(c => {
|
| 360 |
+
if(c.type === 'Group' && c.position.x > 0) ttr.push(c);
|
| 361 |
+
});
|
| 362 |
+
ttr.forEach(t => fg.remove(t));
|
| 363 |
+
group.add(fg);
|
| 364 |
+
return group;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
function createPrisonerCellAssembly() {
|
| 368 |
+
const group = new THREE.Group();
|
| 369 |
+
const cs=3, wh=2.5, wt=0.2, br=0.05, bsp=0.25;
|
| 370 |
+
const cfMat=stoneMaterial.clone();
|
| 371 |
+
cfMat.color.setHex(0x555555);
|
| 372 |
+
group.add(createGroundPlane(cfMat, cs));
|
| 373 |
+
const wbGeo=new THREE.BoxGeometry(cs, wh, wt);
|
| 374 |
+
group.add(createMesh(wbGeo, stoneMaterial, {x:0, y:wh/2, z:-cs/2}));
|
| 375 |
+
const wsGeo=new THREE.BoxGeometry(wt, wh, cs);
|
| 376 |
+
group.add(createMesh(wsGeo, stoneMaterial, {x:-cs/2, y:wh/2, z:0}));
|
| 377 |
+
group.add(createMesh(wsGeo.clone(), stoneMaterial, {x:cs/2, y:wh/2, z:0}));
|
| 378 |
+
const bGeo=new THREE.CylinderGeometry(br, br, wh, 8);
|
| 379 |
+
const nb=Math.floor(cs/bsp);
|
| 380 |
+
for(let i=0; i<nb; i++){
|
| 381 |
+
const xp=-cs/2+(i+0.5)*bsp;
|
| 382 |
+
group.add(createMesh(bGeo.clone(), metalMaterial, {x:xp, y:wh/2, z:cs/2}));
|
| 383 |
+
}
|
| 384 |
+
return group;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
function createGameOverAssembly() {
|
| 388 |
+
const group = new THREE.Group();
|
| 389 |
+
const boxGeo = new THREE.BoxGeometry(2, 2, 2);
|
| 390 |
+
group.add(createMesh(boxGeo, gameOverMaterial, { x: 0, y: 1, z: 0 }));
|
| 391 |
+
group.add(createGroundPlane(stoneMaterial.clone().set({color: 0x333333})));
|
| 392 |
+
return group;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
function createErrorAssembly() {
|
| 396 |
+
const group = new THREE.Group();
|
| 397 |
+
const coneGeo = new THREE.ConeGeometry(0.8, 1.5, 8);
|
| 398 |
+
group.add(createMesh(coneGeo, errorMaterial, { x: 0, y: 0.75, z: 0 }));
|
| 399 |
+
group.add(createGroundPlane());
|
| 400 |
+
return group;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
function createCrossroadsAssembly() {
|
| 404 |
+
const group = new THREE.Group();
|
| 405 |
+
group.add(createGroundPlane(dirtMaterial, 30));
|
| 406 |
+
const poleGeo = new THREE.CylinderGeometry(0.1, 0.1, 3, 8);
|
| 407 |
+
group.add(createMesh(poleGeo, woodMaterial, { y: 1.5 }));
|
| 408 |
+
const signGeo = new THREE.BoxGeometry(1.5, 0.3, 0.05);
|
| 409 |
+
group.add(createMesh(signGeo, woodMaterial, { y: 2.5, z: 0.2 }, { y: Math.PI / 4 }));
|
| 410 |
+
group.add(createMesh(signGeo, woodMaterial, { y: 2.5, z: -0.2 }, { y: -Math.PI / 4 }));
|
| 411 |
+
const grassGeo = new THREE.ConeGeometry(0.2, 0.5, 6);
|
| 412 |
+
for (let i = 0; i < 20; i++) {
|
| 413 |
+
const x = (Math.random() - 0.5) * 15;
|
| 414 |
+
const z = (Math.random() - 0.5) * 15;
|
| 415 |
+
if (Math.abs(x) > 2 || Math.abs(z) > 2) {
|
| 416 |
+
group.add(createMesh(grassGeo, grassMaterial, { x, y: 0.25, z }, { y: Math.random() * Math.PI }));
|
| 417 |
+
}
|
| 418 |
+
}
|
| 419 |
+
const rockGeo = new THREE.SphereGeometry(0.3, 6, 6);
|
| 420 |
+
for (let i = 0; i < 10; i++) {
|
| 421 |
+
group.add(createMesh(rockGeo, stoneMaterial, { x: (Math.random() - 0.5) * 10, y: 0.15, z: (Math.random() - 0.5) * 10 }, { y: Math.random() * Math.PI }));
|
| 422 |
+
}
|
| 423 |
+
return group;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
function createRollingHillsAssembly() {
|
| 427 |
+
const group = new THREE.Group();
|
| 428 |
+
const hillGeo = new THREE.PlaneGeometry(50, 50, 10, 10);
|
| 429 |
+
const hillMat = grassMaterial.clone();
|
| 430 |
+
const hill = new THREE.Mesh(hillGeo, hillMat);
|
| 431 |
+
hill.rotation.x = -Math.PI / 2;
|
| 432 |
+
hill.receiveShadow = true;
|
| 433 |
+
for (let i = 0; i < hillGeo.attributes.position.count; i++) {
|
| 434 |
+
const x = hillGeo.attributes.position.getX(i);
|
| 435 |
+
const z = hillGeo.attributes.position.getZ(i);
|
| 436 |
+
hillGeo.attributes.position.setY(i, Math.sin(x * 0.2 + z * 0.2) * 2);
|
| 437 |
+
}
|
| 438 |
+
hillGeo.computeVertexNormals();
|
| 439 |
+
group.add(hill);
|
| 440 |
+
const shepherdGeo = new THREE.CylinderGeometry(0.1, 0.1, 1, 8);
|
| 441 |
+
group.add(createMesh(shepherdGeo, darkWoodMaterial, { x: 10, y: 2, z: -15 }));
|
| 442 |
+
const grassGeo = new THREE.ConeGeometry(0.3, 0.7, 6);
|
| 443 |
+
for (let i = 0; i < 50; i++) {
|
| 444 |
+
group.add(createMesh(grassGeo, grassMaterial, { x: (Math.random() - 0.5) * 40, y: 0.35, z: (Math.random() - 0.5) * 40 }, { y: Math.random() * Math.PI }));
|
| 445 |
+
}
|
| 446 |
+
return group;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
function createCoastalCliffsAssembly() {
|
| 450 |
+
const group = new THREE.Group();
|
| 451 |
+
const cliffGeo = new THREE.BoxGeometry(10, 5, 10);
|
| 452 |
+
group.add(createMesh(cliffGeo, stoneMaterial, { y: 2.5 }));
|
| 453 |
+
const pathGeo = new THREE.PlaneGeometry(1, 10);
|
| 454 |
+
const path = createMesh(pathGeo, dirtMaterial, { x: -2, y: 2, z: 0 }, { x: -Math.PI / 2, z: -Math.PI / 4 });
|
| 455 |
+
group.add(path);
|
| 456 |
+
const oceanGeo = new THREE.PlaneGeometry(100, 100);
|
| 457 |
+
const ocean = createMesh(oceanGeo, oceanMaterial, { y: -2 }, { x: -Math.PI / 2 });
|
| 458 |
+
ocean.receiveShadow = false;
|
| 459 |
+
ocean.userData.update = (time) => {
|
| 460 |
+
ocean.position.y = -2 + Math.sin(time * 0.5) * 0.1;
|
| 461 |
+
};
|
| 462 |
+
group.add(ocean);
|
| 463 |
+
return group;
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
function createForestEntranceAssembly() {
|
| 467 |
+
const group = createForestAssembly(20, 12);
|
| 468 |
+
const rootGeo = new THREE.TorusGeometry(0.5, 0.1, 8, 16);
|
| 469 |
+
for (let i = 0; i < 10; i++) {
|
| 470 |
+
group.add(createMesh(rootGeo, woodMaterial, { x: (Math.random() - 0.5) * 8, y: 0.1, z: (Math.random() - 0.5) * 8 }, { x: Math.PI / 2 }));
|
| 471 |
+
}
|
| 472 |
+
return group;
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
function createOvergrownPathAssembly() {
|
| 476 |
+
const group = new THREE.Group();
|
| 477 |
+
group.add(createGroundPlane(dirtMaterial, 15));
|
| 478 |
+
const forest = createForestAssembly(15, 10);
|
| 479 |
+
group.add(forest);
|
| 480 |
+
const fungiGeo = new THREE.SphereGeometry(0.1, 8, 8);
|
| 481 |
+
for (let i = 0; i < 30; i++) {
|
| 482 |
+
group.add(createMesh(fungiGeo, glowMaterial, { x: (Math.random() - 0.5) * 8, y: 0.1, z: (Math.random() - 0.5) * 8 }));
|
| 483 |
+
}
|
| 484 |
+
const vineGeo = new THREE.CylinderGeometry(0.05, 0.05, 2, 8);
|
| 485 |
+
for (let i = 0; i < 10; i++) {
|
| 486 |
+
group.add(createMesh(vineGeo, leafMaterial, { x: (Math.random() - 0.5) * 6, y: 2, z: (Math.random() - 0.5) * 6 }, { z: Math.random() * Math.PI }));
|
| 487 |
+
}
|
| 488 |
+
return group;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
function createClearingStatueAssembly() {
|
| 492 |
+
const group = new THREE.Group();
|
| 493 |
+
group.add(createGroundPlane(grassMaterial, 10));
|
| 494 |
+
const statueGeo = new THREE.BoxGeometry(0.8, 2, 0.8);
|
| 495 |
+
group.add(createMesh(statueGeo, stoneMaterial, { y: 1 }));
|
| 496 |
+
const mossGeo = new THREE.SphereGeometry(0.2, 8, 8);
|
| 497 |
+
for (let i = 0; i < 10; i++) {
|
| 498 |
+
group.add(createMesh(mossGeo, grassMaterial, { x: (Math.random() - 0.5) * 0.8, y: 0.5 + Math.random(), z: (Math.random() - 0.5) * 0.8 }));
|
| 499 |
+
}
|
| 500 |
+
const leafGeo = new THREE.PlaneGeometry(0.1, 0.1);
|
| 501 |
+
for (let i = 0; i < 20; i++) {
|
| 502 |
+
group.add(createMesh(leafGeo, leafMaterial, { x: (Math.random() - 0.5) * 5, y: 0.05, z: (Math.random() - 0.5) * 5 }, { y: Math.random() * Math.PI }));
|
| 503 |
+
}
|
| 504 |
+
return group;
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
function createGoblinAmbushAssembly() {
|
| 508 |
+
const group = createOvergrownPathAssembly();
|
| 509 |
+
const bodyGeo = new THREE.CylinderGeometry(0.3, 0.3, 1, 8);
|
| 510 |
+
const headGeo = new THREE.SphereGeometry(0.2, 8, 8);
|
| 511 |
+
const goblinMat = new THREE.MeshStandardMaterial({ color: 0x556B2F });
|
| 512 |
+
for (let i = -1; i <= 1; i += 2) {
|
| 513 |
+
const goblin = new THREE.Group();
|
| 514 |
+
goblin.add(createMesh(bodyGeo, goblinMat, { y: 0.5 }));
|
| 515 |
+
goblin.add(createMesh(headGeo, goblinMat, { y: 1.2 }));
|
| 516 |
+
const spearGeo = new THREE.CylinderGeometry(0.05, 0.05, 2, 8);
|
| 517 |
+
goblin.add(createMesh(spearGeo, woodMaterial, { x: 0.3, y: 1, z: 0 }, { z: Math.PI / 4 }));
|
| 518 |
+
goblin.position.set(i * 2, 0, 2);
|
| 519 |
+
group.add(goblin);
|
| 520 |
+
}
|
| 521 |
+
return group;
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
function createHiddenCoveAssembly() {
|
| 525 |
+
const group = new THREE.Group();
|
| 526 |
+
group.add(createGroundPlane(sandMaterial, 15));
|
| 527 |
+
const caveGeo = new THREE.BoxGeometry(3, 2, 3);
|
| 528 |
+
group.add(createMesh(caveGeo, stoneMaterial, { z: -5, y: 1 }));
|
| 529 |
+
const rockGeo = new THREE.SphereGeometry(0.5, 6, 6);
|
| 530 |
+
for (let i = 0; i < 15; i++) {
|
| 531 |
+
group.add(createMesh(rockGeo, stoneMaterial, { x: (Math.random() - 0.5) * 10, y: 0.25, z: (Math.random() - 0.5) * 10 }));
|
| 532 |
+
}
|
| 533 |
+
const seaweedGeo = new THREE.ConeGeometry(0.2, 1, 6);
|
| 534 |
+
for (let i = 0; i < 10; i++) {
|
| 535 |
+
group.add(createMesh(seaweedGeo, leafMaterial, { x: (Math.random() - 0.5) * 8, y: 0.5, z: (Math.random() - 0.5) * 8 }));
|
| 536 |
+
}
|
| 537 |
+
return group;
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
function createDarkCaveAssembly() {
|
| 541 |
+
const group = new THREE.Group();
|
| 542 |
+
group.add(createGroundPlane(wetStoneMaterial, 10));
|
| 543 |
+
const wallGeo = new THREE.CylinderGeometry(3, 3, 5, 12, 1, true);
|
| 544 |
+
const wall = createMesh(wallGeo, stoneMaterial, { y: 2.5 }, { x: Math.PI / 2 });
|
| 545 |
+
wall.scale.set(1, 1, -1);
|
| 546 |
+
group.add(wall);
|
| 547 |
+
const dripGeo = new THREE.SphereGeometry(0.05, 8, 8);
|
| 548 |
+
for (let i = 0; i < 5; i++) {
|
| 549 |
+
const drip = createMesh(dripGeo, oceanMaterial, { x: (Math.random() - 0.5) * 2, y: 4, z: (Math.random() - 0.5) * 2 });
|
| 550 |
+
drip.userData.update = (time) => {
|
| 551 |
+
drip.position.y -= 0.1;
|
| 552 |
+
if (drip.position.y < 0) drip.position.y = 4;
|
| 553 |
+
};
|
| 554 |
+
group.add(drip);
|
| 555 |
+
}
|
| 556 |
+
return group;
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
// Game Data
|
| 560 |
+
const itemsData = {
|
| 561 |
+
"Flaming Sword":{type:"weapon", description:"A fiery blade"},
|
| 562 |
+
"Whispering Bow":{type:"weapon", description:"A silent bow"},
|
| 563 |
+
"Guardian Shield":{type:"armor", description:"A protective shield"},
|
| 564 |
+
"Healing Light Spell":{type:"spell", description:"Mends minor wounds"},
|
| 565 |
+
"Shield of Faith Spell":{type:"spell", description:"Temporary shield"},
|
| 566 |
+
"Binding Runes Scroll":{type:"spell", description:"Binds an enemy"},
|
| 567 |
+
"Secret Tunnel Map":{type:"quest", description:"Shows a hidden path"},
|
| 568 |
+
"Poison Daggers":{type:"weapon", description:"Daggers with poison"},
|
| 569 |
+
"Master Key":{type:"quest", description:"Unlocks many doors"},
|
| 570 |
+
"Crude Dagger":{type:"weapon", description:"A roughly made dagger."},
|
| 571 |
+
"Scout's Pouch":{type:"quest", description:"Contains odds and ends."}
|
| 572 |
+
};
|
| 573 |
|
| 574 |
+
const gameData = {
|
| 575 |
+
"1": { title: "The Crossroads", content: `<p>Dust swirls... Which path calls to you?</p>`, options: [ { text: "Enter the Shadowwood Forest (North)", next: 5 }, { text: "Head towards the Rolling Hills (East)", next: 2 }, { text: "Investigate the Coastal Cliffs (West)", next: 3 } ], illustration: "crossroads-signpost-sunny" },
|
| 576 |
+
"2": { title: "Rolling Hills", content: `<p>Verdant hills stretch before you... It feels peaceful...</p>`, options: [ { text: "Follow the narrow path", next: 4 }, { text: "Try to hail the distant shepherd (Charisma Check?)", next: 99 } ], illustration: "rolling-green-hills-shepherd-distance" },
|
| 577 |
+
"3": { title: "Coastal Cliffs Edge", content: `<p>You stand atop windswept cliffs... A precarious-looking path descends...</p>`, options: [ { text: "Attempt the precarious descent (Dexterity Check)", check: { stat: 'dexterity', dc: 12, onFailure: 31 }, next: 30 }, { text: "Scan the cliff face for easier routes (Wisdom Check)", check: { stat: 'wisdom', dc: 11, onFailure: 32 }, next: 33 } ], illustration: "windy-sea-cliffs-crashing-waves-path-down" },
|
| 578 |
+
"4": { title: "Hill Path Overlook", content: `<p>The path crests a hill... you see a small, overgrown shrine...</p>`, options: [ { text: "Investigate the overgrown shrine", next: 40 }, { text: "Continue towards the badlands", next: 41 } ], illustration: "hilltop-view-overgrown-shrine-wildflowers" },
|
| 579 |
+
"5": { title: "Shadowwood Entrance", content: `<p>Sunlight struggles to pierce the dense canopy... How do you proceed?</p>`, options: [ { text: "Follow the main, albeit overgrown, path", next: 6 }, { text: "Try to navigate through the lighter undergrowth", next: 7 }, { text: "Look for animal trails or signs of passage (Wisdom Check)", check: { stat: 'wisdom', dc: 10, onFailure: 6 }, next: 8 } ], illustration: "dark-forest-entrance-gnarled-roots-filtered-light" },
|
| 580 |
+
"6": { title: "Overgrown Forest Path", content: `<p>The path is barely visible... You hear a twig snap nearby!</p>`, options: [ { text: "Ready your weapon and investigate", next: 10 }, { text: "Attempt to hide quietly (Dexterity Check)", check: { stat: 'dexterity', dc: 11, onFailure: 10 }, next: 11 }, { text: "Call out cautiously", next: 10 } ], illustration: "overgrown-forest-path-glowing-fungi-vines" },
|
| 581 |
+
"7": { title: "Tangled Undergrowth", content: `<p>Pushing through ferns... You stumble upon a small clearing containing a moss-covered, weathered stone statue...</p>`, options: [ { text: "Examine the statue closely (Intelligence Check)", check: { stat: 'intelligence', dc: 13, onFailure: 71 }, next: 70 }, { text: "Ignore the statue and press on", next: 72 }, { text: "Leave a small offering (if possible)", next: 73 } ], illustration: "forest-clearing-mossy-statue-weathered-stone" },
|
| 582 |
+
"8": { title: "Hidden Game Trail", content: `<p>Your sharp eyes spot a faint trail... It leads towards a ravine spanned by a rickety rope bridge.</p><p>(+20 XP)</p>`, options: [ { text: "Risk crossing the rope bridge (Dexterity Check)", check: { stat: 'dexterity', dc: 10, onFailure: 81 }, next: 80 }, { text: "Search for another way across the ravine", next: 82 } ], illustration: "narrow-game-trail-forest-rope-bridge-ravine", reward: { xp: 20 } },
|
| 583 |
+
"10": { title: "Goblin Ambush!", content: `<p>Two scraggly goblins leap out, brandishing crude spears!</p>`, options: [ { text: "Fight the goblins!", next: 12 }, { text: "Attempt to dodge past them (Dexterity Check)", check: { stat: 'dexterity', dc: 13, onFailure: 10 }, next: 13 } ], illustration: "two-goblins-ambush-forest-path-spears" },
|
| 584 |
+
"11": { title: "Hidden Evasion", content: `<p>You melt into the shadows as the goblins blunder past.</p><p>(+30 XP)</p>`, options: [ { text: "Continue cautiously", next: 14 } ], illustration: "forest-shadows-hiding-goblins-walking-past", reward: { xp: 30 } },
|
| 585 |
+
"12": { title: "Ambush Victory!", content: `<p>You defeat the goblins! Found a Crude Dagger.</p><p>(+50 XP)</p>`, options: [ { text: "Press onward", next: 14 } ], illustration: "defeated-goblins-forest-path-loot", reward: { xp: 50, addItem: "Crude Dagger" } },
|
| 586 |
+
"13": { title: "Daring Escape", content: `<p>With surprising agility, you tumble past the goblins!</p><p>(+25 XP)</p>`, options: [ { text: "Keep running!", next: 14 } ], illustration: "blurred-motion-running-past-goblins-forest", reward: { xp: 25 } },
|
| 587 |
+
"14": { title: "Forest Stream Crossing", content: `<p>The path leads to a clear, shallow stream...</p>`, options: [ { text: "Wade across the stream", next: 16 }, { text: "Look for a drier crossing point (fallen log?)", next: 15 } ], illustration: "forest-stream-crossing-dappled-sunlight-stones" },
|
| 588 |
+
"15": { title: "Log Bridge", content: `<p>Further upstream, a large, mossy log spans the stream.</p>`, options: [ { text: "Cross carefully on the log (Dexterity Check)", check: { stat: 'dexterity', dc: 9, onFailure: 151 }, next: 16 }, { text: "Go back and wade instead", next: 14 } ], illustration: "mossy-log-bridge-over-forest-stream" },
|
| 589 |
+
"151": { title: "Splash!", content: `<p>You slip on the mossy log and tumble into the cold stream! You're soaked but unharmed.</p>`, options: [ { text: "Shake yourself off and continue", next: 16 } ], illustration: "character-splashing-into-stream-from-log" },
|
| 590 |
+
"16": { title: "Edge of the Woods", content: `<p>You emerge from the Shadowwood... Before you lie rocky foothills...</p>`, options: [ { text: "Begin the ascent into the foothills", next: 17 }, { text: "Scan the fortress from afar (Wisdom Check)", check: { stat: 'wisdom', dc: 14, onFailure: 17 }, next: 18 } ], illustration: "forest-edge-view-rocky-foothills-distant-mountain-fortress" },
|
| 591 |
+
"17": { title: "Rocky Foothills Path", content: `<p>The climb is arduous... The fortress looms larger now.</p>`, options: [ { text: "Continue the direct ascent", next: 19 }, { text: "Look for signs of a hidden trail (Wisdom Check)", check: { stat: 'wisdom', dc: 15, onFailure: 19 }, next: 20 } ], illustration: "climbing-rocky-foothills-path-fortress-closer" },
|
| 592 |
+
"18": { title: "Distant Observation", content: `<p>You notice what might be a less-guarded approach along the western ridge...</p><p>(+30 XP)</p>`, options: [ { text: "Take the main path into the foothills", next: 17 }, { text: "Attempt the western ridge approach", next: 21 } ], illustration: "zoomed-view-mountain-fortress-western-ridge", reward: { xp: 30 } },
|
| 593 |
+
"19": { title: "Blocked Pass", content: `<p>The main path is blocked by a recent rockslide!</p>`, options: [ { text: "Try to climb over (Strength Check)", check: { stat: 'strength', dc: 14, onFailure: 191 }, next: 190 }, { text: "Search for another way around", next: 192 } ], illustration: "rockslide-blocking-mountain-path-boulders" },
|
| 594 |
+
"20": { title: "Goat Trail", content: `<p>You discover a narrow trail barely wide enough for a mountain goat...</p><p>(+40 XP)</p>`, options: [ { text: "Follow the precarious goat trail", next: 22 } ], illustration: "narrow-goat-trail-mountainside-fortress-view", reward: { xp: 40 } },
|
| 595 |
+
"30": { title: "Hidden Cove", content: `<p>Your careful descent brings you to a secluded cove. A dark cave entrance is visible...</p><p>(+25 XP)</p>`, options: [ { text: "Explore the dark cave", next: 35 } ], illustration: "hidden-cove-beach-dark-cave-entrance", reward: { xp: 25 } },
|
| 596 |
+
"31": { title: "Tumbled Down", content: `<p>You lose your footing... landing hard on the sandy cove floor. You lose 5 HP. A dark cave entrance beckons.</p>`, options: [ { text: "Gingerly explore the dark cave", next: 35 } ], illustration: "character-fallen-at-bottom-of-cliff-path-cove", hpLoss: 5 },
|
| 597 |
+
"32": { title: "No Easier Path", content: `<p>You scan the cliffs intently but find no obviously easier routes.</p>`, options: [ { text: "Attempt the precarious descent (Dexterity Check)", check: { stat: 'dexterity', dc: 12, onFailure: 31 }, next: 30 } ], illustration: "scanning-sea-cliffs-no-other-paths-visible" },
|
| 598 |
+
"33": { title: "Smuggler's Steps?", content: `<p>Your keen eyes spot a series of barely visible handholds and steps carved into the rock...</p><p>(+15 XP)</p>`, options: [ { text: "Use the hidden steps (Easier Dex Check)", check: { stat: 'dexterity', dc: 8, onFailure: 31 }, next: 30 } ], illustration: "close-up-handholds-carved-in-cliff-face", reward: { xp: 15 } },
|
| 599 |
+
"35": { title: "Dark Cave", content: `<p>The cave smells of salt and decay. Water drips somewhere within.</p>`, options: [{ text: "Press deeper into the darkness", next: 99 } ], illustration: "dark-cave-entrance-dripping-water" },
|
| 600 |
+
"40": { title: "Overgrown Shrine", content: `<p>Wildflowers grow thick around a small stone shrine. It feels ancient and neglected.</p>`, options: [{ text: "Examine the carvings (Intelligence Check)", check:{stat:'intelligence', dc:11, onFailure: 401}, next: 400 } ], illustration: "overgrown-stone-shrine-wildflowers-close" },
|
| 601 |
+
"41": { title: "Rocky Badlands", content: `<p>The green hills give way to cracked earth and jagged rock formations under a harsh sun.</p>`, options: [{ text: "Scout ahead", next: 99 } ], illustration: "rocky-badlands-cracked-earth-harsh-sun" },
|
| 602 |
+
"190": { title: "Over the Rocks", content:"<p>With considerable effort, you manage to climb over the rockslide.</p><p>(+35 XP)</p>", options: [{text:"Continue up the path", next: 22}], illustration:"character-climbing-over-boulders", reward: {xp:35} },
|
| 603 |
+
"191": { title: "Climb Fails", content:"<p>The boulders are too unstable or sheer. You cannot climb them safely.</p>", options: [{text:"Search for another way around", next: 192}], illustration:"character-slipping-on-rockslide-boulders"},
|
| 604 |
+
"192": { title: "Detour Found", content:"<p>After some searching, you find a rough path leading around the rockslide, eventually rejoining the main trail.</p>", options: [{text:"Continue up the path", next: 22}], illustration:"rough-detour-path-around-rockslide"},
|
| 605 |
+
"21": { title: "Western Ridge", content:"<p>The ridge path is narrow and exposed, with strong winds threatening to push you off.</p>", options: [{text:"Proceed carefully (Dexterity Check)", check:{stat:'dexterity', dc: 14, onFailure: 211}, next: 22 } ], illustration:"narrow-windy-mountain-ridge-path" },
|
| 606 |
+
"22": { title: "Fortress Approach", content:"<p>You've navigated the treacherous paths and now stand near the outer walls of the dark fortress. Guards patrol the battlements.</p>", options: [{text:"Look for an unguarded entrance", next: 99}], illustration:"approaching-dark-fortress-walls-guards"},
|
| 607 |
+
"211": {title:"Lost Balance", content:"<p>A strong gust of wind catches you off guard, sending you tumbling down a steep slope! You lose 10 HP.</p>", options:[{text:"Climb back up and find another way", next: 17}], illustration:"character-falling-off-windy-ridge", hpLoss: 10},
|
| 608 |
+
"99": { title: "Game Over / To Be Continued...", content: "<p>Your adventure ends here (for now).</p>", options: [{ text: "Restart", next: 1 }], illustration: "game-over-generic", gameOver: true }
|
| 609 |
+
};
|
| 610 |
+
|
| 611 |
+
// Game State
|
| 612 |
+
let gameState = {
|
| 613 |
+
currentPageId: 1,
|
| 614 |
+
character: {
|
| 615 |
+
name: "Hero", race: "Human", alignment: "Neutral Good", class: "Adventurer",
|
| 616 |
+
level: 1, xp: 0, xpToNextLevel: 100,
|
| 617 |
+
stats: { strength: 8, intelligence: 10, wisdom: 10, dexterity: 10, constitution: 10, charisma: 8, hp: 12, maxHp: 12 },
|
| 618 |
+
inventory: []
|
| 619 |
+
}
|
| 620 |
+
};
|
| 621 |
+
|
| 622 |
+
// Game Logic Functions
|
| 623 |
+
function startGame() {
|
| 624 |
+
const defaultChar = { name: "Hero", race: "Human", alignment: "Neutral Good", class: "Adventurer", level: 1, xp: 0, xpToNextLevel: 100, stats: { strength: 8, intelligence: 10, wisdom: 10, dexterity: 10, constitution: 10, charisma: 8, hp: 12, maxHp: 12 }, inventory: [] };
|
| 625 |
+
gameState = { currentPageId: 1, character: { ...defaultChar } };
|
| 626 |
+
renderPage(gameState.currentPageId);
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
function handleChoiceClick(choiceData) {
|
| 630 |
+
const optionNextPageId = parseInt(choiceData.nextPage);
|
| 631 |
+
const itemToAdd = choiceData.addItem;
|
| 632 |
+
let nextPageId = optionNextPageId;
|
| 633 |
+
let rollResultMessage = "";
|
| 634 |
+
const check = choiceData.check;
|
| 635 |
+
|
| 636 |
+
if (isNaN(optionNextPageId) && !check) { console.error("Invalid choice data:", choiceData); return; }
|
| 637 |
+
|
| 638 |
+
if (check) {
|
| 639 |
+
const statValue = gameState.character.stats[check.stat] || 10;
|
| 640 |
+
const modifier = Math.floor((statValue - 10) / 2);
|
| 641 |
+
const roll = Math.floor(Math.random() * 20) + 1;
|
| 642 |
+
const totalResult = roll + modifier;
|
| 643 |
+
const dc = check.dc;
|
| 644 |
+
console.log(`Check: ${check.stat} (DC ${dc}) | Roll: ${roll} + Mod: ${modifier} = ${totalResult}`);
|
| 645 |
+
if (totalResult >= dc) {
|
| 646 |
+
nextPageId = optionNextPageId;
|
| 647 |
+
rollResultMessage = `<p class="roll-success"><em>Check Success! (${totalResult} vs DC ${dc})</em></p>`;
|
| 648 |
+
} else {
|
| 649 |
+
nextPageId = parseInt(check.onFailure);
|
| 650 |
+
rollResultMessage = `<p class="roll-failure"><em>Check Failed! (${totalResult} vs DC ${dc})</em></p>`;
|
| 651 |
+
if (isNaN(nextPageId)) { console.error("Invalid onFailure ID:", check.onFailure); nextPageId = 99; }
|
| 652 |
+
}
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
if (itemToAdd && !gameState.character.inventory.includes(itemToAdd)) {
|
| 656 |
+
gameState.character.inventory.push(itemToAdd);
|
| 657 |
+
console.log("Added item:", itemToAdd);
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
gameState.currentPageId = nextPageId;
|
| 661 |
+
const nextPageData = gameData[nextPageId];
|
| 662 |
+
|
| 663 |
+
if (nextPageData) {
|
| 664 |
+
if (nextPageData.hpLoss) {
|
| 665 |
+
gameState.character.stats.hp -= nextPageData.hpLoss;
|
| 666 |
+
console.log(`Lost ${nextPageData.hpLoss} HP.`);
|
| 667 |
+
if (gameState.character.stats.hp <= 0) { gameState.character.stats.hp = 0; console.log("Player died!"); nextPageId = 99; }
|
| 668 |
+
}
|
| 669 |
+
if (nextPageData.reward) {
|
| 670 |
+
if (nextPageData.reward.xp) { gameState.character.xp += nextPageData.reward.xp; console.log(`Gained ${nextPageData.reward.xp} XP! Total: ${gameState.character.xp}`); }
|
| 671 |
+
if (nextPageData.reward.statIncrease) {
|
| 672 |
+
const stat = nextPageData.reward.statIncrease.stat;
|
| 673 |
+
const amount = nextPageData.reward.statIncrease.amount;
|
| 674 |
+
if (gameState.character.stats.hasOwnProperty(stat)) {
|
| 675 |
+
gameState.character.stats[stat] += amount;
|
| 676 |
+
console.log(`Stat ${stat} increased by ${amount}.`);
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
if(nextPageData.reward.addItem && !gameState.character.inventory.includes(nextPageData.reward.addItem)){
|
| 680 |
+
gameState.character.inventory.push(nextPageData.reward.addItem);
|
| 681 |
+
console.log(`Found item: ${nextPageData.reward.addItem}`);
|
| 682 |
+
}
|
| 683 |
+
}
|
| 684 |
+
const conModifier = Math.floor((gameState.character.stats.constitution - 10) / 2);
|
| 685 |
+
gameState.character.stats.maxHp = 10 + (conModifier * gameState.character.level);
|
| 686 |
+
gameState.character.stats.hp = Math.min(gameState.character.stats.hp, gameState.character.stats.maxHp);
|
| 687 |
+
if (nextPageId === 99 && gameState.character.stats.hp <= 0) {
|
| 688 |
+
renderPageInternal(99, gameData[99], rollResultMessage);
|
| 689 |
+
return;
|
| 690 |
+
}
|
| 691 |
+
} else {
|
| 692 |
+
console.error(`Data for page ${nextPageId} not found!`);
|
| 693 |
+
renderPageInternal(99, gameData[99], "<p><em>Error: Next page data missing!</em></p>");
|
| 694 |
+
return;
|
| 695 |
+
}
|
| 696 |
+
renderPageInternal(nextPageId, gameData[nextPageId], rollResultMessage);
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
function renderPageInternal(pageId, pageData, message = "") {
|
| 700 |
+
if (!pageData) { console.error(`Render Error: No data for page ${pageId}`); return; }
|
| 701 |
+
storyTitleElement.textContent = pageData.title || "Untitled Page";
|
| 702 |
+
storyContentElement.innerHTML = message + (pageData.content || "<p>...</p>");
|
| 703 |
+
updateStatsDisplay();
|
| 704 |
+
updateInventoryDisplay();
|
| 705 |
+
choicesElement.innerHTML = '';
|
| 706 |
+
if (pageData.options && pageData.options.length > 0) {
|
| 707 |
+
pageData.options.forEach(option => {
|
| 708 |
+
const button = document.createElement('button');
|
| 709 |
+
button.classList.add('choice-button');
|
| 710 |
+
button.textContent = option.text;
|
| 711 |
+
let requirementMet = true;
|
| 712 |
+
if (option.requireItem && !gameState.character.inventory.includes(option.requireItem)) {
|
| 713 |
+
requirementMet = false;
|
| 714 |
+
button.title = `Requires: ${option.requireItem}`;
|
| 715 |
+
button.disabled = true;
|
| 716 |
+
}
|
| 717 |
+
if (requirementMet) {
|
| 718 |
+
const choiceData = { nextPage: option.next, addItem: option.addItem, check: option.check };
|
| 719 |
+
button.onclick = () => handleChoiceClick(choiceData);
|
| 720 |
+
} else {
|
| 721 |
+
button.classList.add('disabled');
|
| 722 |
+
}
|
| 723 |
+
choicesElement.appendChild(button);
|
| 724 |
+
});
|
| 725 |
+
} else {
|
| 726 |
+
const button = document.createElement('button');
|
| 727 |
+
button.classList.add('choice-button');
|
| 728 |
+
button.textContent = pageData.gameOver ? "Restart Adventure" : "The End";
|
| 729 |
+
button.onclick = () => handleChoiceClick({ nextPage: pageData.gameOver ? 1 : 99 });
|
| 730 |
+
choicesElement.appendChild(button);
|
| 731 |
+
if (!pageData.gameOver) choicesElement.insertAdjacentHTML('afterbegin', '<p><i>The path ends here.</i></p>');
|
| 732 |
+
}
|
| 733 |
+
updateScene(pageData.illustration || 'default');
|
| 734 |
+
}
|
| 735 |
+
|
| 736 |
+
function renderPage(pageId) { renderPageInternal(pageId, gameData[pageId]); }
|
| 737 |
+
|
| 738 |
+
function updateStatsDisplay() {
|
| 739 |
+
const char=gameState.character;
|
| 740 |
+
statsElement.innerHTML = `<strong>Stats:</strong> <span>Lvl: ${char.level}</span> <span>XP: ${char.xp}/${char.xpToNextLevel}</span> <span>HP: ${char.stats.hp}/${char.stats.maxHp}</span> <span>Str: ${char.stats.strength}</span> <span>Int: ${char.stats.intelligence}</span> <span>Wis: ${char.stats.wisdom}</span> <span>Dex: ${char.stats.dexterity}</span> <span>Con: ${char.stats.constitution}</span> <span>Cha: ${char.stats.charisma}</span>`;
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
function updateInventoryDisplay() {
|
| 744 |
+
let h='<strong>Inventory:</strong> ';
|
| 745 |
+
if(gameState.character.inventory.length === 0){
|
| 746 |
+
h+='<em>Empty</em>';
|
| 747 |
+
} else {
|
| 748 |
+
gameState.character.inventory.forEach(i=>{
|
| 749 |
+
const d=itemsData[i]||{type:'unknown',description:'???'};
|
| 750 |
+
const c=`item-${d.type||'unknown'}`;
|
| 751 |
+
h+=`<span class="${c}" title="${d.description}">${i}</span>`;
|
| 752 |
+
});
|
| 753 |
+
}
|
| 754 |
+
inventoryElement.innerHTML = h;
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
function updateScene(illustrationKey) {
|
| 758 |
+
if (currentAssemblyGroup) { scene.remove(currentAssemblyGroup); }
|
| 759 |
+
scene.fog = null;
|
| 760 |
+
scene.background = new THREE.Color(0x222222);
|
| 761 |
+
camera.position.set(0, 2.5, 7);
|
| 762 |
+
camera.lookAt(0, 0.5, 0);
|
| 763 |
+
|
| 764 |
+
let assemblyFunction;
|
| 765 |
+
switch (illustrationKey) {
|
| 766 |
+
case 'city-gates': assemblyFunction = createCityGatesAssembly; break;
|
| 767 |
+
case 'weaponsmith': assemblyFunction = createWeaponsmithAssembly; break;
|
| 768 |
+
case 'temple': assemblyFunction = createTempleAssembly; break;
|
| 769 |
+
case 'resistance-meeting': assemblyFunction = createResistanceMeetingAssembly; break;
|
| 770 |
+
case 'shadowwood-forest': assemblyFunction = createForestAssembly; break;
|
| 771 |
+
case 'road-ambush': assemblyFunction = createRoadAmbushAssembly; break;
|
| 772 |
+
case 'forest-edge': assemblyFunction = createForestEdgeAssembly; break;
|
| 773 |
+
case 'prisoner-cell': assemblyFunction = createPrisonerCellAssembly; break;
|
| 774 |
+
case 'game-over': case 'game-over-generic': assemblyFunction = createGameOverAssembly; break;
|
| 775 |
+
case 'error': assemblyFunction = createErrorAssembly; break;
|
| 776 |
+
case 'crossroads-signpost-sunny':
|
| 777 |
+
scene.fog = new THREE.Fog(0x87CEEB, 10, 30);
|
| 778 |
+
scene.background = new THREE.Color(0x87CEEB);
|
| 779 |
+
camera.position.set(0, 3, 10); camera.lookAt(0, 1, 0);
|
| 780 |
+
assemblyFunction = createCrossroadsAssembly; break;
|
| 781 |
+
case 'rolling-green-hills-shepherd-distance':
|
| 782 |
+
scene.fog = new THREE.Fog(0xA8E4A0, 15, 50);
|
| 783 |
+
camera.position.set(0, 5, 15); camera.lookAt(0, 2, -5);
|
| 784 |
+
assemblyFunction = createRollingHillsAssembly; break;
|
| 785 |
+
case 'windy-sea-cliffs-crashing-waves-path-down':
|
| 786 |
+
scene.fog = new THREE.Fog(0x6699CC, 10, 40);
|
| 787 |
+
scene.background = new THREE.Color(0x6699CC);
|
| 788 |
+
camera.position.set(5, 5, 10); camera.lookAt(-2, 0, -5);
|
| 789 |
+
assemblyFunction = createCoastalCliffsAssembly; break;
|
| 790 |
+
case 'dark-forest-entrance-gnarled-roots-filtered-light':
|
| 791 |
+
scene.fog = new THREE.Fog(0x2E2E2E, 5, 20);
|
| 792 |
+
camera.position.set(0, 2, 8); camera.lookAt(0, 1, 0);
|
| 793 |
+
assemblyFunction = createForestEntranceAssembly; break;
|
| 794 |
+
case 'overgrown-forest-path-glowing-fungi-vines':
|
| 795 |
+
scene.fog = new THREE.Fog(0x1A2F2A, 3, 15);
|
| 796 |
+
camera.position.set(0, 1.5, 6); camera.lookAt(0, 0.5, 0);
|
| 797 |
+
assemblyFunction = createOvergrownPathAssembly; break;
|
| 798 |
+
case 'forest-clearing-mossy-statue-weathered-stone':
|
| 799 |
+
scene.fog = new THREE.Fog(0x2E4F3A, 5, 25);
|
| 800 |
+
camera.position.set(0, 2, 5); camera.lookAt(0, 1, 0);
|
| 801 |
+
assemblyFunction = createClearingStatueAssembly; break;
|
| 802 |
+
case 'two-goblins-ambush-forest-path-spears':
|
| 803 |
+
scene.fog = new THREE.Fog(0x2E2E2E, 5, 20);
|
| 804 |
+
camera.position.set(0, 2, 7); camera.lookAt(0, 1, 0);
|
| 805 |
+
assemblyFunction = createGoblinAmbushAssembly; break;
|
| 806 |
+
case 'hidden-cove-beach-dark-cave-entrance':
|
| 807 |
+
scene.fog = new THREE.Fog(0x336699, 5, 30);
|
| 808 |
+
scene.background = new THREE.Color(0x336699);
|
| 809 |
+
camera.position.set(0, 2, 8); camera.lookAt(0, 1, -2);
|
| 810 |
+
assemblyFunction = createHiddenCoveAssembly; break;
|
| 811 |
+
case 'dark-cave-entrance-dripping-water':
|
| 812 |
+
scene.fog = new THREE.Fog(0x1A1A1A, 2, 10);
|
| 813 |
+
scene.background = new THREE.Color(0x1A1A1A);
|
| 814 |
+
camera.position.set(0, 1.5, 4); camera.lookAt(0, 1, 0);
|
| 815 |
+
assemblyFunction = createDarkCaveAssembly; break;
|
| 816 |
+
default:
|
| 817 |
+
console.warn(`Unknown illustration key: "${illustrationKey}". Using default.`);
|
| 818 |
+
assemblyFunction = createDefaultAssembly; break;
|
| 819 |
+
}
|
| 820 |
+
try {
|
| 821 |
+
currentAssemblyGroup = assemblyFunction();
|
| 822 |
+
scene.add(currentAssemblyGroup);
|
| 823 |
+
adjustLighting(illustrationKey);
|
| 824 |
+
} catch (error) {
|
| 825 |
+
console.error(`Error creating assembly for ${illustrationKey}:`, error);
|
| 826 |
+
currentAssemblyGroup = createErrorAssembly();
|
| 827 |
+
scene.add(currentAssemblyGroup);
|
| 828 |
+
}
|
| 829 |
+
}
|
| 830 |
+
|
| 831 |
+
function adjustLighting(illustrationKey) {
|
| 832 |
+
scene.children.forEach(child => {
|
| 833 |
+
if (child.isLight && child !== scene.children.find(c => c.isAmbientLight)) {
|
| 834 |
+
scene.remove(child);
|
| 835 |
+
}
|
| 836 |
+
});
|
| 837 |
+
const ambient = scene.children.find(c => c.isAmbientLight);
|
| 838 |
+
let directionalLight;
|
| 839 |
+
switch (illustrationKey) {
|
| 840 |
+
case 'crossroads-signpost-sunny':
|
| 841 |
+
ambient.intensity = 0.8;
|
| 842 |
+
directionalLight = new THREE.DirectionalLight(0xFFF8E1, 1.5);
|
| 843 |
+
directionalLight.position.set(10, 15, 10);
|
| 844 |
+
break;
|
| 845 |
+
case 'dark-forest-entrance-gnarled-roots-filtered-light':
|
| 846 |
+
case 'overgrown-forest-path-glowing-fungi-vines':
|
| 847 |
+
ambient.intensity = 0.3;
|
| 848 |
+
directionalLight = new THREE.DirectionalLight(0xA8E4A0, 0.6);
|
| 849 |
+
directionalLight.position.set(5, 10, 5);
|
| 850 |
+
break;
|
| 851 |
+
case 'dark-cave-entrance-dripping-water':
|
| 852 |
+
ambient.intensity = 0.1;
|
| 853 |
+
directionalLight = new THREE.DirectionalLight(0x666666, 0.2);
|
| 854 |
+
directionalLight.position.set(2, 5, 2);
|
| 855 |
+
break;
|
| 856 |
+
default:
|
| 857 |
+
ambient.intensity = 0.5;
|
| 858 |
+
directionalLight = new THREE.DirectionalLight(0xffffff, 1.2);
|
| 859 |
+
directionalLight.position.set(8, 15, 10);
|
| 860 |
+
}
|
| 861 |
+
directionalLight.castShadow = true;
|
| 862 |
+
directionalLight.shadow.mapSize.set(1024, 1024);
|
| 863 |
+
directionalLight.shadow.camera.near = 0.5;
|
| 864 |
+
directionalLight.shadow.camera.far = 50;
|
| 865 |
+
directionalLight.shadow.camera.left = -15;
|
| 866 |
+
directionalLight.shadow.camera.right = 15;
|
| 867 |
+
directionalLight.shadow.camera.top = 15;
|
| 868 |
+
directionalLight.shadow.camera.bottom = -15;
|
| 869 |
+
scene.add(directionalLight);
|
| 870 |
+
}
|
| 871 |
+
|
| 872 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 873 |
+
console.log("DOM Ready.");
|
| 874 |
+
try {
|
| 875 |
+
initThreeJS();
|
| 876 |
+
startGame();
|
| 877 |
+
} catch (error) {
|
| 878 |
+
console.error("Init failed:", error);
|
| 879 |
+
storyTitleElement.textContent = "Error";
|
| 880 |
+
storyContentElement.innerHTML = `<p>Init Error. Check console.</p><pre>${error}</pre>`;
|
| 881 |
+
}
|
| 882 |
+
});
|
| 883 |
+
</script>
|
| 884 |
</body>
|
| 885 |
</html>
|