//Creates a new character and gives them the default weapon (Six-Shooter) public Player NewCharacter() { string temp, temp2, temp3, temp4, temp5; Weapons.WeaponsOwned.Clear(); foreach (Weapons w in Weapons.WeaponCheck) { if (w.ownedByPlayer == true) { Weapons.WeaponsOwned.Add(w); } } sC.TB("\t Enter Your Character's Name"); p.name = sC.RL(""); temp = sC.WRL("Press R to roll for Strength"); if (temp == "r") { Console.Clear(); Console.WriteLine("Rolling..."); Console.WriteLine($"Strength: {p.Str = StatRoll(0)}"); } temp2 = sC.WRL("Press R to roll for Dexterity"); if (temp2 == "r") { Console.Clear(); Console.WriteLine("Rolling..."); Console.WriteLine($"Dexterity: {p.Dex = StatRoll(0)}"); } temp3 = sC.WRL("Press R to roll for Intelligence"); if (temp3 == "r") { Console.Clear(); Console.WriteLine("Rolling..."); Console.WriteLine($"Intelligence: {p.Int = StatRoll(0)}"); } temp4 = sC.WRL("Press R to roll for Constitution"); if (temp4 == "r") { Console.Clear(); Console.WriteLine("Rolling..."); Console.WriteLine($"Constitution: {p.Con = StatRoll(0)}"); } temp5 = sC.WRL("Press R to roll for Perception"); if (temp5 == "r") { Console.Clear(); Console.WriteLine("Rolling..."); Console.WriteLine($"Perception: {p.Per = StatRoll(0)}"); p.Gold = 80; return(p); } else { Console.WriteLine("invalid command"); return(null); } }
static void Main(string[] args) { int Location = 0; bool close = false; bool loadNew = true; ShortCuts sC = new ShortCuts(); Helpers h = new Helpers(); Locations l = new Locations(); Weapons w = new Weapons(); //Loads the weapons from the .csv file. w.ArsenalInstantiation(); //Checks to see if there is a previous save file, if there isn't it creates a blank one. try { w.PreviousSaveCheck(); } catch { StreamWriter sW = new StreamWriter("PlayerInv.csv"); sW.Close(); } //Loads the previous inventory(if it exists) w.InventoryInstantiation(); sC.TB("Sunset Showdown"); Console.WriteLine("Press Enter to begin..."); sC.RL(""); while (loadNew) { Console.WriteLine("Would You Like to [L]oad a Save or Start a [N]ew Adventure?"); char LN = sC.RK(' '); if (LN == 'n') { p = h.NewCharacter(); Location = 0; loadNew = false; } else if (LN == 'l') { try { p.LoadSave(); Location = p.Location; loadNew = false; } catch { Console.WriteLine("Invalid data! please create a new character."); } } else { Console.WriteLine("Invalid Command."); } } while (!close)//The real main game loop. { //The player is able to move around and access other locations while //they are alive. while (!p.isDead) { if (Location == 0) { l.TownEntrance(); Location = 1; } if (Location == 1) { l.TownSquare(); char temp = sC.RK(' '); if (temp == 'l') { Console.Clear(); p.Location = Location = 2; } else if (temp == 'r') { Console.Clear(); p.Location = Location = 3; } else if (temp == 'f') { Console.Clear(); p.Location = Location = 4; } else { p.Location = 1; } } if (Location == 2) { l.Saloon(); p.Location = Location = 1; } if (Location == 3) { l.Shop(); p.Location = Location = 1; } if (Location == 4) { l.Hideout(); p.Location = Location = 1; } //This may seem redundant since this is in a while(!p.isDead) loop, but otherwise this will run anyways //since it is between where the player can die and where where it actually checks to see if they're dead. if (!p.isDead) { Console.WriteLine("Type [C] to check your stats, or [V] to view your last save"); char tempchar = sC.RK(' '); Console.Clear(); if (tempchar == 'v') { bool savestate = true; Console.WriteLine($"Current Stats:"); p.CheckStats(); Console.WriteLine("\nPrevious Save:"); try { p.CheckSave(); } catch { Console.WriteLine("No Existing Previous Save."); } Console.WriteLine("\nPress [L] to load your pervious save, or [S] to overwrite it.\n\nPress [E] to Exit\n"); while (savestate) { tempchar = sC.RK(' '); if (tempchar == 's') { p.SaveStats(); savestate = false; } else if (tempchar == 'l') { try { p.LoadSave(); Location = p.Location; loadNew = false; } catch { Console.WriteLine("Save data is invalid or corrupt. Please make a new save file."); } } else if (tempchar == 'e') { Console.Clear(); savestate = false; } else { Console.WriteLine("Invalid command"); } } } else if (tempchar == 'c') { p.CheckStats(); } else if (tempchar == 'q') { close = true; } else { Console.WriteLine("Invalid Command"); } } } //If the player were to die, they would be forced to either load their previous save or quit. while (p.isDead) { Console.WriteLine(""); char tempchar = sC.RK(' '); if (tempchar == 'l') { bool savestate = true; Console.WriteLine($"Current Stats: [DEAD]"); p.CheckStats(); Console.WriteLine("\nPrevious Save:"); try { p.CheckSave(); } catch { Console.WriteLine("No Existing Previous Save."); } Console.WriteLine("\nPress [L] to Load your pervious save.\n\nPress [Q] to Quit\n"); while (savestate) { tempchar = sC.RK(' '); if (tempchar == 'l') { try { p.LoadSave(); Location = p.Location; p.isDead = false; loadNew = false; break; } catch { Console.WriteLine("Save data is Non-existant or invalid."); } } else if (tempchar == 'e') { Console.Clear(); savestate = false; break; } else { Console.WriteLine("Invalid command"); } } } } } }
//This is where the actual *Game* takes place, after killing each set of bandits, the player is given gold //equal to their combined bounties. public void Hideout() { Program.p.HP = Program.p.Con * 4; int phase = 0; int eIDint = 0; int rep = 1; int wepInt = 0; bool inCombat = false; bool playerDeath = false; bool playerRetreat = false; foreach (Weapons wep in Weapons.WeaponsOwned) { wep.cRam = rep; rep++; } if (!playerDeath && !playerRetreat) { if (phase == 0) { sC.TB("You walk up to the hideout, three gang members are lingering outside and notice you. "); sC.RK(' '); Console.Clear(); eIDint = 0; //ph0 = Phase 0, spawns 3 of the weakest for the player to fight. var ph0 = new List <Enemies> { new Thug(1), new Thug(2), new Thug(3) }; inCombat = true; while (inCombat) { Console.WriteLine(""); Console.Write("Name: "); foreach (Enemies e in ph0) { Console.Write($"\t[{e.EID}] {e.Name}"); } Console.Write("\nHealth: "); foreach (Enemies e in ph0) { if (e.EHP > 0) { Console.Write($"{e.EHP}\t\t"); } else { Console.Write("Dead\t\t"); } } Console.WriteLine(); Console.WriteLine($"Choose an enemy to attack\nCurrent Health: {Program.p.HP}"); sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref eIDint); foreach (Enemies e in ph0) { if (eIDint == e.EID) { Console.WriteLine($"Choose a weapons to use"); foreach (Weapons wep in Weapons.WeaponsOwned) { Console.Write($"[{wep.cRam}] {wep.name}\t"); } Console.WriteLine(""); foreach (Weapons wep in Weapons.WeaponsOwned) { Console.Write($"Damage: {wep.truDamage = wep.bDamage + (Program.p.Dex * wep.DexMod) + (Program.p.Str * wep.StrMod)}\t\t"); } sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref wepInt); foreach (Weapons wep in Weapons.WeaponsOwned) { if (wepInt == wep.cRam) { e.EHP -= wep.truDamage; } } } } Console.WriteLine(); int deadT = 0; foreach (Enemies eCheck in ph0) { if (eCheck.EHP <= 0) { eCheck.IsAlive = false; } if (eCheck.IsAlive) { int tInt = h.R2H(0) + 7; if (tInt >= Program.p.Per + Program.p.Dex) { Console.WriteLine($"{eCheck.DPT} Damage Taken from thug [{eCheck.EID}]"); Program.p.HP -= eCheck.DPT; } else { Console.WriteLine($"Thug [{eCheck.EID}] missed!"); } } else { Console.WriteLine($"Thug [{eCheck.EID}] is dead."); deadT++; } if (deadT >= 3) { sC.TB($"You collected {eCheck.Bounty * 3} Gold from their bounties"); Program.p.Gold += eCheck.Bounty * 3; inCombat = false; phase = 1; } } if (Program.p.HP <= 0) { playerDeath = true; inCombat = false; } } } } if (!playerDeath && !playerRetreat) { //The player is given the opportunity to retreat here, if they //press R they get sent back to town and their health gets reset to full. sC.TB("As you push in through the entrance, you run into a captain and his guards investigating the commotion.\nPress [R] to retreat or [Enter] continue"); char tempchar = sC.RK(' '); if (tempchar == 'r') { phase = 3; Program.p.Location = 1; playerRetreat = true; inCombat = false; } if (phase == 1) { //Phase 1 spawns another set of enemies, this time with a captain among them. var ph1 = new List <Enemies> { new Thug(1), new Thug(2), new Captain(3) }; Console.Clear(); eIDint = 0; inCombat = true; while (inCombat) { if (Program.p.HP <= 0) { playerDeath = true; inCombat = false; } Console.WriteLine(""); Console.Write("Name: "); foreach (Enemies e in ph1) { Console.Write($"\t[{e.EID}] {e.Name}"); } Console.Write("\nHealth: "); foreach (Enemies e in ph1) { if (e.EHP > 0) { Console.Write($"{e.EHP}\t\t"); } else { Console.Write("Dead\t\t"); } } Console.WriteLine("\n\n"); Console.WriteLine($"Choose an enemy to attack\nCurrent Health: {Program.p.HP}"); sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref eIDint); foreach (Enemies e in ph1) { if (eIDint == e.EID) { Console.WriteLine($"Choose a weapons to use"); foreach (Weapons wep in Weapons.WeaponsOwned) { Console.Write($"[{wep.cRam}] {wep.name}\t"); } Console.WriteLine(""); foreach (Weapons wep in Weapons.WeaponsOwned) { Console.Write($"{wep.truDamage = wep.bDamage + (Program.p.Dex * wep.DexMod) + (Program.p.Str * wep.StrMod)}\t\t"); } sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref wepInt); foreach (Weapons wep in Weapons.WeaponsOwned) { if (wepInt == wep.cRam) { e.EHP -= wep.truDamage; } } } } Console.WriteLine(); int deadT = 0; foreach (Enemies eCheck in ph1) { if (eCheck.EHP <= 0) { eCheck.IsAlive = false; } if (eCheck.IsAlive) { int tInt = h.R2H(0) + 7; if (tInt >= Program.p.Per + Program.p.Dex) { Console.WriteLine($"{eCheck.DPT} Damage Taken from {eCheck.Name} [{eCheck.EID}]"); Program.p.HP -= eCheck.DPT; } else { Console.WriteLine($"{eCheck.Name} [{eCheck.EID}] missed!"); } } else { Console.WriteLine($"{eCheck.Name} [{eCheck.EID}] is dead."); deadT++; } if (deadT >= 3) { int tInt = 0; foreach (Enemies eDeath in ph1) { tInt += eDeath.Bounty; } sC.TB($"You collected {tInt} Gold from their bounties"); Program.p.Gold += tInt; inCombat = false; phase = 2; } } } } } if (!playerDeath && !playerRetreat) { sC.TB("As you move up the stairs, a honcho and his goons ambush you.\nPress [R] to retreat or [Enter] continue"); char tempchar = sC.RK(' '); if (tempchar == 'r') { phase = 3; Program.p.Location = 1; playerRetreat = true; inCombat = false; } if (phase == 2) { var ph2 = new List <Enemies> { new Thug(1), new Honcho(2), new Thug(3) }; Console.Clear(); eIDint = 0; inCombat = true; while (inCombat) { Console.WriteLine(""); Console.Write("Name: "); foreach (Enemies e in ph2) { Console.Write($"\t[{e.EID}] {e.Name}"); } Console.Write("\nHealth: "); foreach (Enemies e in ph2) { if (e.EHP > 0) { Console.Write($"{e.EHP}\t\t"); } else { Console.Write("Dead\t\t"); } } Console.WriteLine(); Console.WriteLine($"Choose an enemy to attack\nCurrent Health: {Program.p.HP}"); sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref eIDint); foreach (Enemies e in ph2) { if (eIDint == e.EID) { Console.WriteLine($"Choose a weapons to use"); foreach (Weapons wep in Weapons.WeaponsOwned) { Console.Write($"[{wep.cRam}] {wep.name}\t"); } Console.WriteLine(""); foreach (Weapons wep in Weapons.WeaponsOwned) { Console.Write($"{wep.truDamage = wep.bDamage + (Program.p.Dex * wep.DexMod) + (Program.p.Str * wep.StrMod)}\t\t"); } sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref wepInt); foreach (Weapons wep in Weapons.WeaponsOwned) { if (wepInt == wep.cRam) { e.EHP -= wep.truDamage; } } } } Console.WriteLine(); int deadT = 0; foreach (Enemies eCheck in ph2) { if (eCheck.EHP <= 0) { eCheck.IsAlive = false; } if (eCheck.IsAlive) { int tInt = h.R2H(0) + 7; if (tInt >= Program.p.Per + Program.p.Dex) { Console.WriteLine($"{eCheck.DPT} Damage Taken from {eCheck.Name} [{eCheck.EID}]"); Program.p.HP -= eCheck.DPT; } else { Console.WriteLine($"{eCheck.Name} [{eCheck.EID}] missed!"); } } else { Console.WriteLine($"{eCheck.Name} [{eCheck.EID}] is dead."); deadT++; } if (deadT >= 3) { int tInt = 0; foreach (Enemies eDeath in ph2) { tInt += eDeath.Bounty; } sC.TB($"You collected {tInt} Gold from their bounties"); Program.p.Gold += tInt; inCombat = false; } } if (Program.p.HP <= 0) { playerDeath = true; inCombat = false; } } } } if (phase == 3) { } //if the player were to die, then they would be sent here. if (playerDeath) { sC.TB("You have died. \n[L]oad a previous save or [Q]uit;"); Program.p.isDead = true; } else if (!playerDeath && !playerRetreat) { sC.RL("Although you cleared out the bandits' hideout this time, \nyou know more will take their place soon."); Console.WriteLine("Press Any Key to Continue..."); sC.RK(' '); } }