Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- public class Character
- {
- static Random random = new Random(Environment.TickCount); // Static -- each instance of Character class uses this same variable.
- static int attackRoll;
- // Member variables. Each instance of the Character class gets a copy of all.
- public string Name;
- public int Strength, Dexterity, Intelligence, Health, MaxHitPoints, HitPoints, WeaponSkill, Armor, Gold;
- public float Speed, SwingDamageType, ThrustDamageType;
- public bool Alive;
- public Character(string name, int strength, int dexterity, int intelligence, int health, int maxHitPoints, int hitPoints, int weaponSkill,
- int armor, int gold, float speed, float swingDamageType, float thrustDamageType, bool alive) // Constructor.
- {
- // Begin initializing member variables:
- Name = name;
- Strength = strength;
- Dexterity = dexterity;
- Intelligence = intelligence;
- MaxHitPoints = maxHitPoints;
- HitPoints = hitPoints;
- Speed = speed;
- WeaponSkill = weaponSkill;
- Armor = armor;
- Gold = gold;
- Speed = speed;
- SwingDamageType = swingDamageType;
- ThrustDamageType = thrustDamageType;
- Alive = alive;
- } // End constructor.
- public void Combat(Character target) //Combat function.
- {
- Console.WriteLine("\nDo you wish to (A)ttack, (D)efend, Attack to (H)it Location, or chose a (T)actical Option?\n");
- string combatChoice = Console.ReadLine();
- switch (combatChoice.ToUpper())
- {
- case "A":
- Console.WriteLine("\nDo you wish to (S)wing or (T)hrust?\n");
- string swingOrThrust = Console.ReadLine();
- switch (swingOrThrust.ToUpper())
- {
- case "S":
- Swing(target);
- break;
- case "T":
- Thrust(target);
- break;
- default:
- break; // Break from swingOrThrust block.
- } // End swingOrThrust block.
- break; // Break from case "A" and combatChoice block.
- default:
- Console.WriteLine("\nNot a valid option!\n Press any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- break; // Break from combatChoice block.
- } //End combatChoice swtich block.
- } // End Combat function.
- public void Swing(Character target)
- {
- attackRoll = random.Next(3, 18);
- Console.WriteLine("\nDebug: Roll = {0}.\n", attackRoll);
- if (attackRoll <= WeaponSkill)
- {
- Console.WriteLine("\n{0}'s attack was successfull!\n", Name);
- SwingDamageRoll(target);
- Console.WriteLine("\nDebug: {0} has {1} HP!\n", target.Name, target.HitPoints);
- Console.WriteLine("\nPress any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- }
- else
- {
- Console.WriteLine("\nThe attack misses!\n");
- Console.WriteLine("\nPress any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- }
- } // End Swing function.
- public void Thrust(Character target)
- {
- attackRoll = random.Next(3, 18);
- Console.WriteLine("\nDebug: Roll = {0}.\n", attackRoll);
- if (attackRoll <= WeaponSkill)
- {
- Console.WriteLine("\n{0}'s attack was successfull!\n", Name);
- ThrustDamageRoll(target);
- Console.WriteLine("\nDebug: {0} has {1} HP!\n", target.Name, target.HitPoints);
- Console.WriteLine("\nPress any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- }
- else
- {
- Console.WriteLine("\nThe attack misses!\n");
- Console.WriteLine("\nPress any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- }
- } // End Thrust function.
- public void SwingDamageRoll(Character target)
- {
- int damageRoll, basicDamage, injury;
- if (Strength <= 2)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 5), 0);
- }
- else if (Strength == 3)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 4), 0);
- }
- else if (Strength == 4)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 4), 0);
- }
- else if (Strength == 5)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 3), 0);
- }
- else if (Strength == 6)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 3), 0);
- }
- else if (Strength == 7)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 2), 0);
- }
- else if (Strength == 8)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 2), 0);
- }
- else if (Strength == 9)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 1), 0);
- }
- else if (Strength == 10)
- {
- damageRoll = random.Next(1, 6);
- }
- else if (Strength == 11)
- {
- damageRoll = (random.Next(1, 6)) + 1;
- }
- else if (Strength == 12)
- {
- damageRoll = (random.Next(1, 6)) + 2;
- }
- else if (Strength == 13)
- {
- damageRoll = (random.Next(2, 12)) - 1;
- }
- else if (Strength == 14)
- {
- damageRoll = random.Next(2, 12);
- }
- else if (Strength >= 15)
- {
- damageRoll = (random.Next(2, 12)) + 1;
- }
- else
- {
- damageRoll = 0;
- }
- basicDamage = Math.Max((damageRoll - target.Armor), 0);
- injury = (int)(basicDamage * SwingDamageType);
- target.HitPoints -= injury;
- Console.WriteLine("\nRolling for damage... {0} rolled {1} and did {2} damage.\n", Name, damageRoll, injury);
- AliveOrDead(target);
- } // End Swing Damage Roll function.
- public void ThrustDamageRoll(Character target)
- {
- int damageRoll, basicDamage, injury;
- if (Strength <= 2)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 6), 0);
- }
- else if (Strength == 3)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 5), 0);
- }
- else if (Strength == 4)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 5), 0);
- }
- else if (Strength == 5)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 4), 0);
- }
- else if (Strength == 6)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 4), 0);
- }
- else if (Strength == 7)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 3), 0);
- }
- else if (Strength == 8)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 3), 0);
- }
- else if (Strength == 9)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 2), 0);
- }
- else if (Strength == 10)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 2), 0);
- }
- else if (Strength == 11)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 1), 0);
- }
- else if (Strength == 12)
- {
- damageRoll = Math.Max((random.Next(1, 6) - 1), 0);
- }
- else if (Strength == 13)
- {
- damageRoll = random.Next(1, 6);
- }
- else if (Strength == 14)
- {
- damageRoll = random.Next(1, 6);
- }
- else if (Strength >= 15)
- {
- damageRoll = (random.Next(1, 6)) + 1;
- }
- else
- {
- damageRoll = 0;
- }
- basicDamage = Math.Max((damageRoll - target.Armor), 0);
- injury = (int) (basicDamage * ThrustDamageType);
- target.HitPoints -= injury;
- Console.WriteLine("\nRolling for damage... {0} rolled {1} and did {2} damage.\n", Name, damageRoll, injury);
- AliveOrDead(target);
- } // End Thrust Damage Roll function.
- public void AliveOrDead(Character target)
- {
- if (target.HitPoints <= 0)
- {
- target.Alive = false;
- Console.WriteLine("\n{0} was slain!\n", target.Name);
- }
- } // End Alive Or Dead function.
- } // End Character class.
- class Program
- {
- // Declare the Random class, give it the name "random," then make a new instance of the Random class:
- static Random random = new Random(Environment.TickCount);
- static bool gameRunning = true;
- static void EndFight(Character player, Character target)
- {
- if (player.Alive == false)
- {
- Console.Clear();
- Console.WriteLine(@"
- ________ ________
- / _____/_____ _____ ____ \_____ \___ __ ___________
- ╔══/ \ ___\__ \══/ \_/ __ \═══/ | \ \/ // __ \_ __ \══╗
- ║ \ \_\ \/ __ \| Y Y \ ___/ / | \ /\ ___/| | \/ ║
- ║ \______ (____ /__|_| /\___ > \_______ /\_/ \___ >__| ║
- ╚══════════\/═════\/══════\/═════\/══════════\/══════════\/═════════╝
- YOU DIED IN THE ARENA!");
- Console.ReadKey();
- Console.Clear();
- gameRunning = false;
- }
- if (target.Alive == false)
- {
- player.Gold += target.Gold;
- }
- } // End End Fight function.
- static void Main(string[] args) //The Main function.
- {
- // Create instances of the Character class:
- // (string name, int strength, int dexterity, int intelligence, int health, int maxHitPoints, int hitPoints, int speed, int weaponSkill, int armor, float speed, bool alive)
- Character player = new Character("", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0F, 1F, 1F, true);
- // Begin game:
- Console.WriteLine(@"
- ENTER...
- ___________ __ _____
- \__ ___/| |__ ____ / _ \_______ ____ ____ _____
- ╔═══| |═══| | \_/ __ \═══/ /_\ \_ __ \_/ __ \ / \\__ \════╗
- ║ | | | Y \ ___/ / | \ | \/\ ___/| | \/ __ \_ ║
- ║ |____| |___| /\___ > \____|__ /__| \___ >___| (____ / ║
- ╚═════════════════\/═════\/══════════\/════════════\/═════\/═════\/═══╝
- ...IF YOU DARE!
- Press any key...
- ''The Arena'' by Richard D. Sharpe
- camaro_driver@hotmail.com
- *** Special thanks to GameDev.net! ***
- version 0.102611.01");
- Console.ReadKey();
- Console.Clear();
- while (gameRunning)
- {
- Console.WriteLine(@"
- ╔═════════════════ MAIN MENU ═════════════════╗
- ║ (C)reate a Character ╔═══ Character ═══╗ ║
- ║ (D)isplay Character ║ Name:{0} ║ ║
- ║ (E)quipment ║ Hit Points: {1} ║ ║
- ║ (S)leep ║ Level: ║ ║
- ║ (H)ealer ║ EXP: ║ ║
- ║ (A)rmory ║ Gold: {2} ║ ║
- ║ (F)ight in the arena! ╚═════════════════╝ ║
- ╚═════════════════════════════════════════════╝", player.Name.PadLeft(10), player.HitPoints.ToString().PadLeft(3), player.Gold.ToString().PadLeft(6));
- Console.WriteLine("\n");
- Console.WriteLine(" Make your selection: \n");
- string menuChoice = Console.ReadLine();
- switch (menuChoice.ToUpper())
- {
- case "C":
- Console.Clear();
- if (player.Name == "")
- {
- Console.WriteLine("\nCurrently, no character creation functions are available in this version.\n");
- Console.WriteLine("\nName your character: \n");
- player.Name = Console.ReadLine();
- player.Strength = 14;
- player.Dexterity = 12;
- player.Intelligence = 10;
- player.Health = 12;
- player.MaxHitPoints = 14;
- player.HitPoints = 14;
- player.WeaponSkill = 12;
- player.Gold = 250;
- player.Speed = 6.00F;
- Console.WriteLine("\nCharacter created!\n");
- }
- else
- {
- Console.WriteLine("You have already created a character named {0}.\n", player.Name);
- }
- Console.WriteLine("\nPress any key to continue... ");
- Console.ReadKey();
- Console.Clear();
- break; // End 'C' case.
- case "D":
- Console.Clear();
- Console.WriteLine(@"
- ╔═══════════════ CHARACTER SHEET ═══════════════╗
- ║ ║
- ║ Name: {0} ║
- ║ Species: ║
- ║ Class: ║
- ║ ║
- ║ ╔═══ Attributes ════╗╔══ Characteristics ═══╗ ║
- ║ ║ Strength: {1} ║║ Hit Points: {5} ║ ║
- ║ ║ Dexterity: {2} ║║ Willpower: ║ ║
- ║ ║ Intelligence: {3} ║║ Perception: ║ ║
- ║ ║ Health: {4} ║║ Fatigue Points: ║ ║
- ║ ╚═══════════════════╝╚══════════════════════╝ ║
- ║ ╔═══════ Armor ════════╦════ Equipment ═════╗ ║
- ║ ║ Helmet: ║ R. Hand: ║ ║
- ║ ║ Body: ║ L. Hand: ║ ║
- ║ ║ Arms: ╠════════════════════╣ ║
- ║ ║ Hands: ║ Gold: ║ ║
- ║ ║ Legs: ║ Ring: ║ ║
- ║ ║ Feet: ║ Necklace: ║ ║
- ║ ╚══════════════════════╩════════════════════╝ ║
- ╚═══════════════════════════════════════════════╝", player.Name.PadRight(10),
- player.Strength.ToString().PadLeft(3),
- player.Dexterity.ToString().PadLeft(3),
- player.Intelligence.ToString().PadLeft(3),
- player.Health.ToString().PadLeft(3),
- player.MaxHitPoints.ToString().PadLeft(3));
- Console.WriteLine("\nPress any key to continue... ");
- Console.ReadKey();
- Console.Clear();
- break;
- case "E":
- Console.Clear();
- Console.WriteLine("This selection not yet implemented.");
- Console.WriteLine("\nPress any key...");
- Console.ReadKey();
- Console.Clear();
- break;
- case "S":
- Console.Clear();
- Console.WriteLine("This selection not yet implemented.");
- Console.WriteLine("\nPress any key...");
- Console.ReadKey();
- Console.Clear();
- break;
- case "H":
- Console.Clear();
- Console.WriteLine("This selection not yet implemented.");
- Console.WriteLine("\nPress any key...");
- Console.ReadKey();
- Console.Clear();
- break;
- case "A":
- bool shopping = true;
- Console.Clear();
- do
- {
- Console.WriteLine(@"
- ╔══════════════════ ARMORY ═══════════════════╗
- ║ ║
- ║╔═══════ Armor ════════╗ ╔═══ Character ═══╗ ║
- ║║ 1. Leather $ 250 ║ ║ Name:{0} ║ ║
- ║║ 2. Chain $ 1000 ║ ║ Gold: {1} ║ ║
- ║╠══════ Weapons ═══════╣ ║ ║ ║
- ║║ 3. Club $ 100 ║ ║ ║ ║
- ║║ 4. Sword $ 450 ║ ║ ║ ║
- ║╚══════════════════════╝ ╚═════════════════╝ ║
- ╚═════════════════════════════════════════════╝", player.Name.PadLeft(10), player.Gold.ToString().PadLeft(6));
- Console.WriteLine("\nSelect a number of the item you wish to purchace, or '0' to exit.\n");
- int armoryChoice = int.Parse(Console.ReadLine());
- switch (armoryChoice)
- {
- case 1:
- {
- Console.WriteLine("\nDo you wish to purchace the Leather Armor for $250?\n");
- Console.WriteLine("(Y)es or (N)o.\n");
- string yesOrNo = Console.ReadLine().ToUpper();
- if (yesOrNo == "Y")
- {
- if (player.Gold >= 250)
- {
- player.Gold -= 250;
- player.Armor = 2;
- Console.WriteLine("\nPleasure do'n business with ya.\n");
- Console.WriteLine("\nPress any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- } // End check for enough gold = yes.
- else
- {
- Console.WriteLine("\nBegone! Come back when you get the gold!\n");
- Console.WriteLine("\nPress any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- } // End check for enough gold = no.
- } // End "Yes" if block.
- else if (yesOrNo == "N")
- {
- Console.WriteLine("\nQuit wasting my time then!\n");
- Console.WriteLine("\nPress any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- } // End "No" if block.
- else
- {
- Console.WriteLine("\nNot a valid option.\n");
- Console.WriteLine("\nPress any key to continue...\n");
- Console.ReadKey();
- Console.Clear();
- } // End catch if block.
- break; // Break from Case '1.'
- } // End Case '1.'
- default:
- {
- shopping = false;
- break;
- }
- } // End Armory Choice swtich block.
- } while (shopping == true);
- Console.Clear();
- break; // Break from 'A' case.
- case "F":
- Console.Clear();
- Console.WriteLine("\nChose your opponent: (G)oblin, (O)rc.\n");
- string opponentChoice = Console.ReadLine();
- switch (opponentChoice.ToUpper())
- {
- case "G":
- Character goblin = new Character("the goblin", 10, 13, 9, 12, 10, 10, 14, 1, 250, 6.25F, 1.5F, 2F, true);
- Console.Clear();
- Console.WriteLine("\nYou're fighting a goblin!\n");
- do
- {
- if (player.Speed >= goblin.Speed)
- {
- if (player.Alive == true)
- {
- player.Combat(goblin);
- }
- if (goblin.Alive == true)
- {
- Console.WriteLine("\nThe goblin is attacking!\n");
- goblin.Swing(player);
- }
- }
- else
- {
- if (goblin.Alive == true)
- {
- Console.WriteLine("\nThe goblin is attacking!\n");
- goblin.Swing(player);
- }
- if (player.Alive == true)
- {
- player.Combat(goblin);
- }
- }
- } while (player.Alive == true && goblin.Alive == true);
- EndFight(player, goblin);
- break; // Break from combat with the goblin.
- case "O":
- Character orc = new Character("the orc", 12, 11, 8, 12, 12, 12, 13, 2, 500, 5.75F, 1.5F, 2F, true);
- Console.Clear();
- Console.WriteLine("\nYou're fighting an orc!\n");
- do
- {
- if (player.Speed >= orc.Speed)
- {
- if (player.Alive == true)
- {
- player.Combat(orc);
- }
- if (orc.Alive == true)
- {
- Console.WriteLine("\nThe orc is attacking!\n");
- orc.Swing(player);
- }
- }
- else
- {
- if (orc.Alive == true)
- {
- Console.WriteLine("\nThe orc is attacking!\n");
- orc.Swing(player);
- }
- if (player.Alive == true)
- {
- player.Combat(orc);
- }
- }
- } while (player.Alive == true && orc.Alive == true);
- EndFight(player, orc);
- break; // Break from combat with the orc.
- default:
- Console.Clear();
- Console.WriteLine("Not a valid choice.");
- break;
- } // End opponenet choice.
- break;
- default:
- Console.Clear();
- Console.WriteLine("Not a valid selection.");
- Console.WriteLine("\nPress any key...");
- Console.ReadKey();
- Console.Clear();
- break;
- } // End main menu switch.
- } // End game running loop.
- } // End Main.
- } // End Program class.
- } // End namespace.
Add Comment
Please, Sign In to add comment