Skip to content

Instantly share code, notes, and snippets.

@sandrockcstm
Created July 10, 2017 07:41
Show Gist options
  • Save sandrockcstm/a846087c6fadcfb1f83c0e92cf7ce3d6 to your computer and use it in GitHub Desktop.
Save sandrockcstm/a846087c6fadcfb1f83c0e92cf7ce3d6 to your computer and use it in GitHub Desktop.
Console RPG created by sandrockcstm - https://repl.it/JMY2/134
using System;
using System.Collections;
namespace Bestiary
{
class Slime
{
public string Name { get; set; } = "Slime";
public int Hp { get; set; } = 10;
public int Atk { get; set; } = 1;
}
class Revenant
{
public string Name { get; set; } = "Revenant";
public int Hp { get; set; } = 15;
public int Atk { get; set; } = 5;
}
}
using System;
using System.Collections;
using Bestiary;
using PlayerStats;
//Battle system is contained in this namespace.
namespace BattleSpace
{
class Combat()
{
//public int[] playerStats= new int[] { 25, 10};
//public int[] monsterStats= new int[] { 10, 10};
public string playerName;
public int playerHp;
public int playerAtk;
public string monsterName;
public int monsterHp;
public int monsterAtk;
public bool runCombat(string playerName) //Begins combat.
{
/*public string playerName;
public int playerHp;
public into playerAtk;*/
Player p = new Player();
this.playerName = playerName;
playerHp = p.PlayerHp;
playerAtk = p.PlayerAtk;
Revenant r = new Revenant();
monsterName = r.Name;
monsterHp = r.Hp;
monsterAtk = r.Atk;
Console.WriteLine("You encountered a " + monsterName + " !");
while(playerHp > 0 && monsterHp > 0)
{
Console.WriteLine(monsterName + " has " + monsterHp + " HP");
Console.WriteLine(playerName + " has " + playerHp + " HP");
Console.WriteLine("What will you do?");
string c = Console.ReadLine();
switch(c)
{
case "Attack":
monsterHp -= playerAtk;
Console.WriteLine(playerName + " deals " + playerAtk + " damage!");
break;
case "Run":
playerHp -= monsterAtk;
Console.WriteLine(monsterName + " does " + monsterAtk + " damage! There's no escape!");
break;
default:
Console.WriteLine("Not a valid entry");
break;
}
}
if (playerHp > 0)
{
return true;
}
else if (playerHp <= 0)
{
return false;
}
else
{
throw new System.Exception("Value of playerStats is not valid");
}
}
}
}
using System;
using System.Collections;
using Startup;
using BattleSpace;
using PlayerStats;
using StorySpace;
static class Program
{
static void Main(string[] args)
{
//StartupClass s = new StartupClass();
Player p = new Player();
Console.WriteLine("What is your name?");
p.PlayerName = Console.ReadLine(); //Sets the player character's name
Story s = new Story();
s.Act1(p.PlayerName);
Combat c = new Combat(); //Begins combat
if(c.runCombat(p.PlayerName) == true)
{
//If player survives, he wins
Console.WriteLine(p.PlayerName + " was victorious!");
}
else
{
//If player dies, game over
Console.WriteLine("Game Over!");
}
}
}
using System;
using System.Collections;
namespace PlayerStats
{
class Player
{
public string PlayerName { get; set; } = "Default";
public int PlayerHp { get; set; } = 25;
public int PlayerAtk { get; set; } = 10;
}
}
using System;
using System.Collections;
namespace Startup
{
class StartupClass
{
public string playerName;
public string PlayerNameGet()
{
Console.WriteLine("Welcome to Console RPG! What is your name?");
string playerName = Console.ReadLine();
return playerName;
}
}
}
using System;
using System.Collections;
using BattleSpace;
using Bestiary;
using PlayerStats;
namespace StorySpace
{
class Story
{
private string playerName;
public void NextLine(string text)
{
Console.Write(text);
Console.ReadLine();
}
public void Act1(string playerName)
{
this.playerName = playerName;
NextLine("You awake in a dark corridor... how did you get here?");
NextLine("It smells like darkness in here. Nothing but mold and mildew and... is that rotten flesh you smell?");
NextLine("You try not to think about it.");
Console.WriteLine("You should try to find your way out of here. Who knows if anyone will ever find you, or why you were brought here in the first place. You can CALL for help, SEARCH the area for supplies, EXPLORE the room, or WAIT.");
string c = ToUpper(Console.ReadLine());
switch(c)
{
case "CALL":
Console.WriteLine("You let out a boisterous call, which echoes through the room. You wait a minute or two but hear no response.");
break;
case "SEARCH":
Console.WriteLine("You move around on your hands and knees, looking for something to help you. You find a TORCH. If you can figure out how to light it, you might be able to see a way out.")
case "EXPLORE":
Console.WriteLine("You search along the walls of the room for something, anything, to aid you. You find the DOOR, but it will neither budge nor open. You search around on the floor and find some FLINT. If you can find a TORCH, you may be able to see more detail in the room and find a way out.")
}
//Console.WriteLine("You awake in a dark corridor... how did you get here?");
//Console.ReadLine();
//Console.WriteLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment