Goblin Jeer Generator
The Goblin Jeer Generator is a browser-based interactive fantasy encounter that combines humorous writing with modular web development. Built with PHP, HTML, CSS, JavaScript, and JSON-driven content, the project simulates a short role-playing interaction in which goblins insult an adventurer based on their class, their familiarity with the city, and the locations they ask about.
Originally created as a playful PHP learning project, the application evolved into a small interactive system demonstrating modular architecture, data-driven dialogue, object-oriented character logic, and multi-stage interaction flow. Rather than functioning as a one-click joke generator, the project progresses through several encounter stages and separates data, logic, and presentation into reusable components.
Technologies Used
- PHP
- HTML5
- CSS3
- JavaScript
- JSON content structures
Gameplay Walkthrough
The application behaves like a small encounter system. The player enters a character name and class, receives class-based insults from goblins, answers whether they are new to the city, and can then ask about locations such as the tavern, temple, inn, courthouse, weapon shop, or magic shop.
Stage 1 — Character Setup
The opening screen establishes the fantasy-comic tone of the project while collecting the player’s character name and class. Presenting the interaction this way helps the app feel like a small browser-based RPG encounter rather than a generic web form.
Stage 2 — Class-Based Goblin Jeers
After the form is submitted, the system randomly selects goblins to respond with class-specific insults. This stage demonstrates how user input is translated into dynamic output through character-specific dialogue logic.
Stage 3 — City Familiarity Question
The next stage asks whether the player is new to the city. Goblins respond differently depending on the answer, which extends the project beyond a single-response script into a more structured interaction flow.
Stage 4 — Location-Based Jeers
In the final stage, players can ask about important city locations. Goblins then respond with location-specific insults, giving the system a stronger sense of place and making it feel more like a miniature encounter engine with world-aware dialogue.
Project Structure
The project uses a modular structure rather than placing all logic into a single file. Dialogue content, application logic, and presentation are separated into distinct components, making the system easier to understand and expand.
- Goblin.php — defines the Goblin class and encapsulates goblin behavior and dialogue methods.
- goblins.php — loads JSON dialogue data and instantiates goblin objects.
- stages.php — controls the multi-stage interaction flow.
- jeers.json — stores goblin dialogue data in a structured format.
- index.php — main entry point for the application.
- styles.css — presentation layer controlling layout and visual tone.
- images/ — goblin portrait assets used in the interface.
Key Design Concepts
- Data-driven dialogue stored in JSON
- Object-oriented character logic using a reusable Goblin class
- Multi-stage interaction flow using form state
- Randomized character selection for replayability
- Separation between data, logic, and presentation
Example: Goblin Class Logic
class Goblin {
private $name;
private $title;
private $classJeers = [];
private $cityResponses = [];
private $locationJeers = [];
private $image;
public function jeer($userClass, $characterName) {
$userClass = strtolower(trim($userClass));
if (array_key_exists($userClass, $this->classJeers)) {
return $characterName . ", " . $this->classJeers[$userClass];
} else {
return $characterName . ", never heard of that class! Ye sure yer not just a chicken in disguise?";
}
}
}
Encapsulating goblin behavior inside a class made the project easier to organize and opened the door to adding more goblins with distinct personalities, dialogue pools, and response types.
Design Reflection
This project started as a playful way to experiment with PHP, but as the number of goblins, dialogue types, and encounter stages increased, it required better organization and more deliberate structure. That pressure pushed the project toward modularity and made it much more useful as a learning exercise.
The result is a small but meaningful demonstration of data-driven design, object-oriented logic, structured interaction flow, and lightweight RPG-style browser interaction. It also reflects something I enjoy as both a developer and a writer: building systems that combine technical logic with character voice and playful presentation.
