<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Adventures in Gielinor (Classic)</title>
<style id="styles">
body {
font-family: 'Courier New', Courier, monospace;
background-color: #2c2c2c; /* Dark grey background */
color: #cccccc; /* Light grey text */
display: flex;
flex-direction: column;
align-items: center;
margin: 0;
padding: 10px;
min-height: 100vh;
box-sizing: border-box;
}
h1 {
color: #e0c060; /* Gold color for title */
text-align: center;
border-bottom: 2px solid #e0c060;
padding-bottom: 5px;
margin-bottom: 15px;
width: 100%;
max-width: 800px;
}
#game-container {
background-color: #3a3a3a; /* Slightly lighter grey for content */
border: 2px solid #505050;
padding: 15px;
width: 100%;
max-width: 800px;
display: flex;
flex-wrap: wrap; /* Allow wrapping */
gap: 15px;
box-sizing: border-box;
}
#left-panel {
flex: 2; /* Takes more space */
min-width: 300px;
display: flex;
flex-direction: column;
gap: 15px;
}
#right-panel {
flex: 1; /* Takes less space */
min-width: 150px;
display: flex;
flex-direction: column;
gap: 15px;
}
#location-display {
background-color: #1e1e1e; /* Very dark grey for description */
border: 1px solid #606060;
padding: 10px;
min-height: 150px;
max-height: 300px; /* Limit height */
overflow-y: auto; /* Add scroll if needed */
box-sizing: border-box;
white-space: pre-wrap; /* Preserve formatting */
}
#location-display h2 {
color: #e0c060;
margin-top: 0;
text-align: center;
}
#location-display a {
color: #70a0ff; /* Blue for links */
text-decoration: none;
cursor: pointer;
font-weight: bold;
display: inline-block; /* Better spacing */
margin: 5px 0;
}
#location-display a:hover {
color: #ffffff; /* White on hover */
text-decoration: underline;
}
#location-display .item-name {
color: #ffcc66; /* Yellowish for items */
}
#location-display .npc-name {
color: #99ccff; /* Lighter blue for NPCs */
}
#action-log {
background-color: #1e1e1e;
border: 1px solid #606060;
padding: 10px;
height: 200px; /* Fixed height */
overflow-y: scroll; /* Always show scroll */
box-sizing: border-box;
font-size: 0.9em;
}
#action-log p {
margin: 0 0 5px 0;
}
#action-log p:last-child {
margin-bottom: 0;
}
#inventory-box, #status-box {
background-color: #1e1e1e;
border: 1px solid #606060;
padding: 10px;
min-height: 100px; /* Minimum height */
}
#inventory-box h3, #status-box h3 {
color: #e0c060;
margin-top: 0;
text-align: center;
border-bottom: 1px dashed #e0c060;
padding-bottom: 5px;
}
#inventory-list li, #status-list li {
margin-bottom: 5px;
}
/* Simple responsive adjustment */
@media (max-width: 600px) {
#game-container {
flex-direction: column;
}
#left-panel, #right-panel {
width: 100%;
flex: none; /* Reset flex grow */
}
}
</style>
</head>
<body>
<h1>Adventures in Gielinor (Classic)</h1>
<div id="game-container">
<div id="left-panel">
<div id="location-display">
<!-- Location description and links will be loaded here by JavaScript -->
</div>
<div id="action-log">
<h3>— Log —</h3>
<p>Welcome, adventurer!</p>
</div>
</div>
<div id="right-panel">
<div id="status-box">
<h3>— Status —</h3>
<ul id="status-list">
<li>Hitpoints: 10/10</li>
<li>Combat Level: 3</li>
</ul>
</div>
<div id="inventory-box">
<h3>— Inventory —</h3>
<ul id="inventory-list">
<li>Empty</li>
</ul>
</div>
</div>
</div>
<script id="scripts">
// --- Game Data ---
const locations = {
'lumbridge-start': {
name: "Lumbridge Lumbridge",
description: "You are standing in the familiar grassy fields south of Lumbridge.\nThere's a path leading north towards the castle and a small cottage to the east.\nTo the west, you see some cows grazing.",
exits: {
'north': 'lumbridge-castle-gate',
'east': 'lumbridge-cottage',
'west': 'lumbridge-field-west'
},
interactables: {
'cow': { type: 'npc', name: 'Grazing Cow', description: "A typical cow. It looks peaceful.", canAttack: true, attackResult: "You attack the cow. It moos loudly but seems unharmed. Maybe you need a weapon?", loot: ['cowhide'] },
'tree': { type: 'resource', name: 'Tree', description: "A sturdy oak tree. Perhaps you could chop it?", canChop: true, requires: 'bronze axe', drop: 'logs', dropMessage: "You chop the tree and get some logs."}
},
items: ['bronze axe'] // Items initially present
},
'lumbridge-castle-gate': {
name: "Lumbridge Castle Gate",
description: "You stand before the imposing gates of Lumbridge Castle. The main entrance is north.\nYou can return south to the fields.",
exits: {
'south': 'lumbridge-start',
'north': 'lumbridge-castle-hall'
},
interactables: {
'gate': { type: 'feature', name: 'Castle Gate', description: "A large wooden gate. It seems sturdy."}
}
},
'lumbridge-castle-hall': {
name: "Lumbridge Castle Hall",
description: "You are inside the main hall of Lumbridge Castle. It's quite grand. There's an exit south.",
exits: {
'south': 'lumbridge-castle-gate'
},
interactables: {
'duke': { type: 'npc', name: 'Duke Horacio', description: "The Duke sits on his throne, looking rather bored.", canTalk: true, dialogue: ["Welcome, adventurer! Fancy seeing you here.", "Mind the goblins, they've been troublesome lately."] }
}
},
'lumbridge-cottage': {
name: "Small Cottage",
description: "You are beside a small, quaint cottage. The door is slightly ajar. The Lumbridge fields are to the west.",
exits: {
'west': 'lumbridge-start'
},
interactables: {
'cottage-door': { type: 'feature', name: 'Cottage Door', description: "A simple wooden door.", canOpen: true, opensTo: 'lumbridge-cottage-inside'},
'farmer': { type: 'npc', name: 'Farmer Giles', description: "A farmer wearing overalls. He seems worried.", canTalk: true, dialogue: ["Oh dear, oh dear! My chickens have wandered off again!", "Have you seen any chickens nearby? I'd reward you if you could find them."], quest: 'find-chickens', questCompleteMessage: "Thank you for finding my chickens! Here's a small reward.", reward: 'chicken' }
}
},
'lumbridge-cottage-inside': {
name: "Inside the Cottage",
description: "The inside is simple and tidy. There's a table and some basic furniture. The door leads outside west.",
exits: {
'west': 'lumbridge-cottage'
},
interactables: {
'chicken': { type: 'npc', name: 'Wandering Chicken', description: "A small, clucking chicken.", canTalk: false, canAttack: true, attackResult: "You scare the chicken, and it runs back towards Farmer Giles.", foundBy: 'find-chickens'},
'table': { type: 'feature', name: 'Table', description: "A plain wooden table."}
}
},
'lumbridge-field-west': {
name: "Western Lumbridge Field",
description: "You are in a field west of Lumbridge. More cows graze here. A large oak tree stands nearby. You can go east back towards the main fields.",
exits: {
'east': 'lumbridge-start'
},
interactables: {
'cow': { type: 'npc', name: 'Grazing Cow', description: "Another cow. Looks just like the others.", canAttack: true, attackResult: "You attack the cow. It bleats and runs away towards the east!", loot: ['cowhide'] },
'oak-tree': { type: 'resource', name: 'Oak Tree', description: "A large oak tree. Seems suitable for woodcutting.", canChop: true, requires: 'bronze axe', drop: 'logs', dropMessage: "You swing your axe... CLUNK! You managed to chop some logs." },
'chicken': { type: 'npc', name: 'Lost Chicken', description: "A chicken pecks at the ground nervously. Maybe Farmer Giles is looking for this?", canTalk: false, foundBy: 'find-chickens', returnTo: 'farmer'}
}
}
};
// --- Game State ---
let currentLocation = 'lumbridge-start';
let inventory = [];
let gameFlags = {
hasTalkedToFarmer: false,
foundChickens: 0,
quest_find_chickens_active: false,
quest_find_chickens_completed: false
};
// --- DOM Elements ---
const locationDisplay = document.getElementById('location-display');
const inventoryList = document.getElementById('inventory-list');
const actionLog = document.getElementById('action-log');
const statusList = document.getElementById('status-list');
// --- Helper Functions ---
function logMessage(message) {
const p = document.createElement('p');
p.textContent = message;
actionLog.appendChild(p);
// Auto-scroll to bottom
actionLog.scrollTop = actionLog.scrollHeight;
}
function updateInventoryDisplay() {
inventoryList.innerHTML = ''; // Clear existing list
if (inventory.length === 0) {
const li = document.createElement('li');
li.textContent = 'Empty';
inventoryList.appendChild(li);
} else {
inventory.forEach(item => {
const li = document.createElement('li');
li.textContent = capitalize(item);
inventoryList.appendChild(li);
});
}
}
function capitalize(str) {
if (!str) return '';
return str.charAt(0).toUpperCase() + str.slice(1);
}
function updateStatusDisplay() {
// Simple status for now
statusList.innerHTML = '<h3>— Status —</h3><li>Hitpoints: 10/10</li><li>Combat Level: 3</li>';
}
function canDoAction(action, itemNeeded) {
if (!itemNeeded) return true;
return inventory.includes(itemNeeded);
}
// --- Core Game Logic ---
function renderLocation() {
const locData = locations[currentLocation];
if (!locData) {
locationDisplay.innerHTML = '<h2>Error</h2><p>Location not found!</p>';
return;
}
let displayHtml = `<h2>${locData.name}</h2>`;
displayHtml += locData.description + '\n\n';
// Add Exits
displayHtml += "Exits: ";
let firstExit = true;
for (const direction in locData.exits) {
if (!firstExit) displayHtml += " | ";
displayHtml += `<a onclick="moveTo('${locData.exits[direction]}')">${capitalize(direction)}</a>`;
firstExit = false;
}
displayHtml += '\n\n';
// Add Items in Location
if (locData.items && locData.items.length > 0) {
displayHtml += "You see here: ";
locData.items.forEach((item, index) => {
if (index > 0) displayHtml += ", ";
displayHtml += `<a class="item-name" onclick="takeItem('${item}')">${capitalize(item)}</a>`;
});
displayHtml += '\n';
}
// Add Interactables (NPCs, Resources, Features)
if (locData.interactables) {
displayHtml += "Also here: ";
let firstInteractable = true;
for (const key in locData.interactables) {
const interactable = locData.interactables[key];
if (!firstInteractable) displayHtml += ", ";
let className = '';
if (interactable.type === 'npc') className = 'npc-name';
if (interactable.type === 'resource') className = 'item-name'; // Style resources like items
displayHtml += `<a class="${className}" onclick="interactWith('${key}')">${interactable.name}</a>`;
firstInteractable = false;
}
displayHtml += '\n';
}
locationDisplay.textContent = displayHtml; // Use textContent first to avoid issues with nested links initially
// Now, manually wrap the links in spans or divs if needed, or ensure the JS handles clicks correctly.
// Simpler approach: Re-parse to ensure onclick works if needed, or just rely on the onclick attribute.
// The current setup with onclick attributes on <a> tags should work directly.
}
function moveTo(locationId) {
// Check if the location exists
if (locations[locationId]) {
currentLocation = locationId;
renderLocation();
logMessage(`You move ${getDirectionName(locationId)}.`); // Needs refinement to know direction
} else {
logMessage(`You can't go that way.`);
}
}
// Helper to find direction name (basic implementation)
function getDirectionName(targetLocationId) {
const locData = locations[currentLocation];
for(const dir in locData.exits) {
if (locData.exits[dir] === targetLocationId) {
return capitalize(dir);
}
}
return "towards";
}
function takeItem(itemId) {
const locData = locations[currentLocation];
if (locData.items && locData.items.includes(itemId)) {
// Remove item from location
locData.items = locData.items.filter(item => item !== itemId);
// Add item to inventory
inventory.push(itemId);
updateInventoryDisplay();
logMessage(`You pick up the ${itemId}.`);
renderLocation(); // Re-render to remove item from view
} else {
logMessage(`There is no ${itemId} here to take.`);
}
}
function interactWith(interactableKey) {
const locData = locations[currentLocation];
const interactable = locData.interactables[interactableKey];
if (!interactable) {
logMessage("You can't interact with that.");
return;
}
// Handle NPCs
if (interactable.type === 'npc') {
if (interactable.canTalk) {
let dialogueToShow = interactable.dialogue[0]; // Default dialogue
// Quest logic integration
if(interactable.quest === 'find-chickens') {
if (!gameFlags.quest_find_chickens_completed) {
gameFlags.quest_find_chickens_active = true;
logMessage(`${interactable.name}: ${interactable.dialogue[0]}`);
interactable.dialogue.shift(); // Remove first line
interactable.dialogue.push("Have you seen any chickens nearby? I'd reward you if you could find them."); // Add quest goal
gameFlags.hasTalkedToFarmer = true;
} else {
logMessage(`${interactable.name}: ${interactable.dialogue[0]}`); // Already completed dialogue
}
} else {
logMessage(`${interactable.name}: ${dialogueToShow}`);
}
} else if (interactable.canAttack) {
// Basic combat / interaction
if (interactable.attackResult) {
logMessage(interactable.attackResult);
if (interactable.loot && interactable.loot.length > 0) {
if (canDoAction('take', null)) { // Check if player can pick up
interactable.loot.forEach(lootItem => {
if (!locData.items) locData.items = [];
locData.items.push(lootItem);
logMessage(`The ${interactable.name} dropped a ${lootItem}.`);
});
renderLocation(); // Re-render to show dropped items
} else {
logMessage(`You can't carry anymore!`); // Assuming full inventory check later
}
}
// Handle specific returnTo logic (like chickens)
if (interactable.returnTo && gameFlags.quest_find_chickens_active && !gameFlags.quest_find_chickens_completed) {
const npc = locData.interactables[interactable.returnTo];
if (npc && npc.quest === 'find-chickens') {
gameFlags.foundChickens++;
logMessage(`The ${interactable.name} seems to be heading back to ${npc.name}.`);
// Remove the chicken visually for now
delete locData.interactables[interactableKey];
// Check if quest is complete
if (gameFlags.foundChickens >= 1) { // Need to find 1 chicken
logMessage(`You helped Farmer Giles find his chicken!`);
logMessage(`${npc.name}: ${npc.questCompleteMessage} Here you go.`);
inventory.push(npc.reward);
updateInventoryDisplay();
gameFlags.quest_find_chickens_completed = true;
gameFlags.quest_find_chickens_active = false;
npc.dialogue = ["Thanks again for finding my chicken!"]; // Update dialogue
}
}
}
}
} else {
logMessage(`You can't interact with the ${interactable.name} right now.`);
}
}
// Handle Resources
else if (interactable.type === 'resource') {
if (interactable.canChop) {
if (interactable.requires && !canDoAction('chop', interactable.requires)) {
logMessage(`You need a ${interactable.requires} to chop this.`);
} else {
logMessage(interactable.dropMessage || `You interact with the ${interactable.name}.`);
if (interactable.drop) {
if (canDoAction('take', null)) {
inventory.push(interactable.drop);
updateInventoryDisplay();
// Optionally, remove the interactable or change its state
// For simplicity, let's just log the action. A stump could replace the tree.
logMessage(`You now have ${inventory.filter(i => i === 'logs').length} logs.`);
} else {
logMessage("Your inventory is full!");
}
}
}
} else {
logMessage(`You can't ${interactable.action || 'interact'} with the ${interactable.name}.`);
}
}
// Handle Features
else if (interactable.type === 'feature') {
if (interactable.canOpen && interactable.opensTo) {
const nextLocId = interactable.opensTo;
if (locations[nextLocId]) {
// Directly change location for doors/entrances
currentLocation = nextLocId;
renderLocation();
logMessage(`You open the ${interactable.name} and proceed.`);
} else {
logMessage(`The ${interactable.name} doesn't seem to lead anywhere.`);
}
} else {
logMessage(`You examine the ${interactable.name}. ${interactable.description}`);
}
}
}
// --- Initialization ---
window.onload = () => {
updateInventoryDisplay();
updateStatusDisplay();
renderLocation();
};
</script>
</body>
</html>
How to Use:
- Save: Save the entire code block above as an HTML file (e.g.,
rs_classic_adventure.html).
- Open: Open the saved file in your web browser (Chrome, Firefox, Edge, etc.).
Features and Inspirations:
- Classic UI: Mimics the two-panel layout (main view + inventory/log) seen in RuneScape Classic.
- Simple Graphics: Uses basic HTML elements and CSS for a retro, text-heavy feel. No actual images are embedded, keeping it a single, clean HTML file.
- Exploration: Navigate between locations using clickable "Exits".
- Interaction: Click on items to
take them, NPCs to talk or attack, and features like trees or doors to interact.
- Inventory System: Items you pick up appear in the inventory list.
- Basic Quest: A simple "find the chickens" quest involving Farmer Giles.
- Action Log: Records your actions and messages from the game.
- Basic Status: Shows placeholder HP and Combat Level.
- Resource Gathering: Attempting to chop a tree requires a "bronze axe" (which is available to pick up near the start).
Limitations:
- No Combat: Combat is purely descriptive. There's no HP reduction, stats, or turn-based fighting.
- Very Limited Scope: Only a few locations around Lumbridge are included.
- No Graphics: Relies entirely on text descriptions and CSS styling.
- No Saving: The game state resets every time you refresh the page.
- Simple Logic: Questing and interactions are very basic.
This file provides a functional, albeit simple, point-and-click adventure experience within the constraints of a single HTML document, capturing some of the early feel of RuneScape Classic.