private void setHitpoints() { Console.Clear(); Console.WriteLine(); Console.WriteLine("== CUSTOM SETTINGS =="); Console.WriteLine("= Hitpoints"); Console.CursorTop += 2; setHitpointsEachPreview(Blue); setHitpointsEachPreview(Red); Console.CursorTop -= 2; Blue = setHitpointsEach(Blue); Red = setHitpointsEach(Red); }
private void StartProgram() { Swordsman BlueSwordsman = new Swordsman("Blue", 1000, 40, 60); Swordsman RedSwordsman = new Swordsman("Red", 1000, 30, 70); Console.Title = typeof(Program).Assembly.GetName().Name; Console.TreatControlCAsInput = false; Console.WriteLine(Console.Title); Console.WriteLine("Two swordsmens have different swords and will deal random damage within a specific boundary"); Console.WriteLine(); Console.WriteLine("The Default settings are:"); Console.WriteLine("Blue Sword deals 40-60 Damage per Hit"); Console.WriteLine("Red Sword deals 30-70 Damage per Hit"); Console.WriteLine("Both have 1000 hitpoints each"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Please choose:"); Console.WriteLine(); Console.WriteLine("1. Default Swordfight"); Console.WriteLine("2. Custom Swordfight"); if (Console.ReadLine() == "2") { //custom Console.Title += " (Custom Fight)"; new CustomSettings(BlueSwordsman, RedSwordsman); } else { //default Console.Title += " (Default Fight)"; //Don't change any values here } Fight(BlueSwordsman, RedSwordsman); }
private Swordsman setHitpointsEach(Swordsman swordsman) { string input; int n; Console.Write("{0} Hitpoints: ", swordsman.Name); SendKeys.SendWait(swordsman.Hitpoints.ToString()); input = Console.ReadLine(); if (Int32.TryParse(input, out n)) { swordsman.Hitpoints = Int32.Parse(input); } //update previous line in case the user entered somethign invalid which got replaced Console.CursorTop -= 1; Console.WriteLine("{0} Hitpoints: {1}{2}", swordsman.Name, swordsman.Hitpoints, new String(' ', Console.WindowWidth)); Console.CursorTop -= 1; return swordsman; }
private void setHitpointsEachPreview(Swordsman swordsman) { Console.WriteLine("{0} Hitpoints: {1}", swordsman.Name, swordsman.Hitpoints); }
private Swordsman setSwordDamageEach(Swordsman swordsman) { String input; int n; //red max Console.Write("{0} min Damage: ", swordsman.Name); SendKeys.SendWait(swordsman.SwordMin.ToString()); input = Console.ReadLine(); if (Int32.TryParse(input, out n)) { swordsman.SwordMin = Int32.Parse(input); } //update previous line in case the user entered somethign invalid which got replaced Console.CursorTop -= 1; Console.WriteLine("{0} min Damage: {1}{2}", swordsman.Name, swordsman.SwordMin, new String(' ', Console.WindowWidth)); Console.CursorTop -= 1; //red min Console.Write("{0} max Damage: ", swordsman.Name); SendKeys.SendWait(swordsman.SwordMax.ToString()); input = Console.ReadLine(); if (Int32.TryParse(input, out n)) { swordsman.SwordMax = Int32.Parse(input); } //update previous line in case the user entered somethign invalid which got replaced Console.CursorTop -= 1; Console.WriteLine("{0} max Damage: {1}{2}", swordsman.Name, swordsman.SwordMax, new String(' ', Console.WindowWidth)); Console.CursorTop -= 1; return swordsman; }
private void setSwordDamageEachPreview(Swordsman swordsman) { Console.WriteLine("{0} min Damage: {1}", swordsman.Name, swordsman.SwordMin); Console.WriteLine("{0} max Damage: {1}", swordsman.Name, swordsman.SwordMax); }
private void setSwordDamage() { Console.Clear(); Console.WriteLine(); Console.WriteLine("== CUSTOM SETTINGS =="); Console.WriteLine("= Sword"); Console.WriteLine(); Console.WriteLine(); Console.Clear(); //show information about hitpoints if (Blue.Hitpoints == Red.Hitpoints) Console.WriteLine("Both {0} and {1} have {2} Hitpoints", Blue.Name, Red.Name, Blue.Hitpoints); else { Console.WriteLine("{0} has {1} Hitpoints", Blue.Name, Blue.Hitpoints); Console.WriteLine("{0} has {1} Hitpoints", Red.Name, Red.Hitpoints); } Console.WriteLine(); //this previews the Data //Requires special attention when changing the spacing setSwordDamageEachPreview(Blue); Console.WriteLine(); setSwordDamageEachPreview(Red); Console.CursorTop -= 5; //this enables the use to enter the data Blue = setSwordDamageEach(Blue); Console.WriteLine(); Red = setSwordDamageEach(Red); }
public CustomSettings(Swordsman BlueSwordsman, Swordsman RedSwordsman) { Blue = BlueSwordsman; Red = RedSwordsman; ChangeSettings(); }
public void Fight(Swordsman BlueSwordsman, Swordsman RedSwordsman) { int rounds = 0; Console.Clear(); Console.WriteLine(Console.Title); //show Sword damage if (BlueSwordsman.SwordMin == RedSwordsman.SwordMin && BlueSwordsman.SwordMax == RedSwordsman.SwordMax) { //both have same stats if (BlueSwordsman.SwordMin == BlueSwordsman.SwordMax) Console.WriteLine("Both {0} and {1} deal {2} Damage per Hit", BlueSwordsman, RedSwordsman, BlueSwordsman.SwordMin); else Console.WriteLine("Both {0} and {1} deal {1}-{2} Damage per Hit", BlueSwordsman, RedSwordsman, BlueSwordsman.SwordMin, BlueSwordsman.SwordMax); } else { //both have diffrent stats if (BlueSwordsman.SwordMin == BlueSwordsman.SwordMax) Console.WriteLine("{0} deals {1} Damage per Hit", BlueSwordsman, BlueSwordsman.SwordMin); else Console.WriteLine("{0} deals {1}-{2} Damage per Hit", BlueSwordsman, BlueSwordsman.SwordMin, BlueSwordsman.SwordMax); if (RedSwordsman.SwordMin == RedSwordsman.SwordMax) Console.WriteLine("{0} deals {1} Damage per Hit", RedSwordsman, RedSwordsman.SwordMin); else Console.WriteLine("{0} deals {1}-{2} Damage per Hit", RedSwordsman, RedSwordsman.SwordMin, RedSwordsman.SwordMax); } //show hitpoints if (BlueSwordsman.Hitpoints == RedSwordsman.Hitpoints) Console.WriteLine("Both {0} and {1} have {2} Hitpoints", BlueSwordsman, RedSwordsman, BlueSwordsman.Hitpoints); else { Console.WriteLine("{0} has {1} Hitpoints", BlueSwordsman, BlueSwordsman.Hitpoints); Console.WriteLine("{0} has {1} Hitpoints", RedSwordsman, RedSwordsman.Hitpoints); } Console.WriteLine(); Console.WriteLine(); //TODO: More Detail Console.WriteLine("=== [ fighting ] ==="); Console.WriteLine(); Console.WriteLine(); //while both are alive while (BlueSwordsman.Hitpoints > 0 && RedSwordsman.Hitpoints > 0) { RedSwordsman.Hitpoints -= rnd.Next(RedSwordsman.SwordMin, RedSwordsman.SwordMax); BlueSwordsman.Hitpoints -= rnd.Next(RedSwordsman.SwordMin, RedSwordsman.SwordMax); rounds++; } if (BlueSwordsman.Hitpoints > 0) { //Blue won Console.WriteLine("{0} took {1} rounds to score victory against {2}! {0} still got {3} hitpoints left.", BlueSwordsman, rounds, RedSwordsman, BlueSwordsman.Hitpoints); } else if (RedSwordsman.Hitpoints > 0) { //Red won Console.WriteLine("{0} took {1} rounds to score victory against {2}! {0} still got {3} hitpoints left.", RedSwordsman, rounds, BlueSwordsman, RedSwordsman.Hitpoints); } else { //Both loose Console.WriteLine("{0} and {1} killed each other! Both are losers!", BlueSwordsman, RedSwordsman); } Console.WriteLine(); Console.WriteLine("{0} Hitpoints: {1}", BlueSwordsman, BlueSwordsman.Hitpoints); Console.WriteLine("{0} Hitpoints: {1}", RedSwordsman, RedSwordsman.Hitpoints); Console.WriteLine("Rounds taken: {0}", rounds); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Press Ctrl+C or Return to close the Window"); Console.ReadLine(); }