balthizar01 / highsail-text-rpg Goto Github PK
View Code? Open in Web Editor NEWA side project for the HighSail Studios team that are in intro programming courses. This project is to help learn and understand core programming concepts.
A side project for the HighSail Studios team that are in intro programming courses. This project is to help learn and understand core programming concepts.
The "Load Game" option on the menu should list the characters that are located in the "characters.json" file. The code should read the file, use JSON.NET by Newtonsoft (add the dependency) to reserialize the JSON, and then list each JSON object (character) to the player with a number attached. The number is for the player to choose which character to load.
Updates should include:
We need someone to start working on a combat system. The implementation should be fairly simple. The class will pretty much just be interacting with the Player and whatever Enemy object is passed into it. Here is a sample implementation I've made, feel free to edit or create something new:
public class CombatSystem
{
private Player player;
private Enemy enemy;
public CombatSystem(Player player, Enemy enemy)
{
this.player = player;
this.enemy = enemy;
}
public void StartCombat()
{
Console.WriteLine("Combat has started!");
// Main combat loop
while (player.IsAlive && enemy.IsAlive)
{
// Player's turn
Console.WriteLine("\nPlayer's turn:");
if (PlayerTurn())
{
Console.WriteLine("Player successfully fled the battle!");
return; // Exit combat if player flees
}
if (!enemy.IsAlive) break; // Check if enemy was defeated
// Enemy's turn
Console.WriteLine("\nEnemy's turn:");
EnemyTurn();
if (!player.IsAlive) break; // Check if player was defeated
}
// Determine outcome
if (!player.IsAlive)
{
Console.WriteLine("Player has been defeated.");
}
else if (!enemy.IsAlive)
{
Console.WriteLine("Enemy has been defeated.");
}
}
private bool PlayerTurn()
{
// For simplicity, only two actions: attack and flee.
Console.WriteLine("Choose an action:\n1. Attack\n2. Flee");
string choice = Console.ReadLine();
if (choice == "1")
{
player.Attack(enemy);
return false; // Did not flee
}
else if (choice == "2")
{
if (player.TryFlee())
{
return true; // Successfully fled
}
else
{
Console.WriteLine("Failed to flee!");
return false; // Failed to flee
}
}
return false;
}
private void EnemyTurn()
{
enemy.Attack(player);
}
}
Calling it would look like this:
Player player = new Player { Name = "Hero", Health = 100, AttackPower = 15, FleeChance = 0.3 };
Enemy enemy = new Enemy { Name = "Goblin", Health = 50, AttackPower = 10 };
CombatSystem combat = new CombatSystem(player, enemy);
combat.StartCombat();
The Player and Enemy objects are just example objects, but the CombatSystem object is accurate.
The character creator should provide the player with options to fill out some of the character information such as:
The new character should be saved into a file called "characters.json" into a folder called "textRPG". The folder should be located in C:\Users<currentuser>\Documents\
Run logic checks to see if the file or folder exists first. If not, they should be created and THEN save the character.
Just like the Enemy database, we need an NPC database as well. These are NPCs that you'd find in town, merchants along the roads, or any other entity that generally is not considered naturally hostile.
{
"NPC_ID": 1,
"name": "Arthur Pendragon",
"spawnTown": "Camelot",
"spawnChance": 100,
"lootTable": [
{"item": "Gold Coin", "dropChance": 50},
{"item": "Rusty Sword", "dropChance": 5}
]
}
This one might be a bit more complex or might not be, all depends on how we implement this. However, the repository for dialogue will be in a single JSON file with the following structure:
{
"NPC_ID": 1,
"Dialogues": [
{
"ID": "smith_greeting",
"Text": "Welcome to my smithy, adventurer!",
"Responses": [
{
"Text": "Show me your wares.",
"NextDialogueID": "smith_shop"
},
{
"Text": "Heard any rumors?",
"NextDialogueID": "smith_rumors"
},
{
"Text": "Goodbye.",
"NextDialogueID": null
}
]
},
{
"ID": "smith_shop",
"Text": "Here's what I've got for sale.",
"Responses": []
},
{
"ID": "smith_rumors",
"Text": "They say the old well is haunted...",
"Responses": [
{
"Text": "Tell me more.",
"NextDialogueID": "smith_well_story"
},
{
"Text": "I should go.",
"NextDialogueID": null
}
]
}
]
}
With this structure and how the NPC model/database is structured, it should be easy to create and use a DialogueManager and map the NPC_ID from the NPC Database to the NPC_ID in the Dialogue Database.
This example shows the usage of the NPC_ID to map out their dialogue options, as well as fields to use for easy navigation into the next line of the dialogue tree. It also gives responses that are available for the player to choose from.
Should contain the options to do the following:
We can have a single JSON file that contains all the enemies in the game as JSON objects that can be called whenever needed. Sample JSON would look like this:
{
"enemyID": 1,
"name": "Goblin",
"spawnArea": "Forest",
"spawnChance": 25,
"lootTable": [
{"item": "Gold Coin", "dropChance": 50},
{"item": "Rusty Sword", "dropChance": 5}
]
}
With this we'd be able to have the player encounter enemies on a % chance based on the area they're in and what the spawn chance of the enemy is.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.