public void theBattle(Hokemon attacker, Hokemon defender) { int roundNum = 0; int attackNum = 0; int defenceNum = 0; Hokemon tempHoke; Console.WriteLine("{0}: waits...", attacker.name); System.Threading.Thread.Sleep(2000); Console.WriteLine("{0}: and waits...", attacker.name); System.Threading.Thread.Sleep(1000); Console.WriteLine("{0}: 'I Accept The Challenger!!!'", defender.name); Console.WriteLine("--- Contender Stats ---"); attacker.get_details(); defender.get_details(); Console.WriteLine("--- BATTLE BEGINS ---\n"); while (Convert.ToInt32(defender.health) >= 0 || Convert.ToInt32(attacker.health) >= 0) { roundNum = roundNum + 1; attackNum = attacker.attackCalculator(); defenceNum = defender.defenceCalculator(); Console.WriteLine("---Round{0}---\n\n", roundNum); for (int i = 0; i < 2; i++) { System.Threading.Thread.Sleep(2000); Console.WriteLine("{0}: prepares to attack...", attacker.Name); System.Threading.Thread.Sleep(1000); Console.WriteLine("{0}: attacks for:{1}...\n\n", attacker.Name, attackNum); System.Threading.Thread.Sleep(1000); Console.WriteLine("{0}: prepares for the attack and build up its defence value to: {1}", defender.Name, defenceNum); System.Threading.Thread.Sleep(1000); Console.WriteLine("{0}: was hurt for (HEALTH {1} + DEFENCE {2}) = {3} - ATTACK {4}\n", defender.Name, defender.health, defenceNum, (defender.health + defenceNum), attackNum); defender.health = (defender.health + defenceNum) - attackNum; Console.WriteLine("{0}: now has {1} health ", defender.Name, ((defender.health + defenceNum) - attackNum)); Console.WriteLine("\n-----------------------------\n"); Console.WriteLine("\n----\nSwitch turns Defender becomes the Attacker...\n----\n"); tempHoke = attacker; attacker = defender; defender = tempHoke; } } if (attacker.health > defender.health) { Console.WriteLine("{0}: WINS", attacker.Name); } else { Console.WriteLine("{0}: WINS", defender.Name); } }
static void Main(string[] args) { Hokemon hokemon1 = new Hokemon(); Hokemon hokemon2 = new Hokemon(); battleArena battleArena1 = new battleArena(); if (battleArena1.battleRequest(hokemon1, hokemon2) == true) { battleArena1.battle(hokemon1, hokemon2); } }
public void fight(Hokemon hokemon1) { int damage; damage = attackValue(Attack, Speed); hokemon1.Health = Convert.ToInt32((hokemon1.ApparentHealth - damage) / hokemon1.Defence); hokemon1.ApparentHealth -= damage; Console.WriteLine("{0} attacks \ndealing {1} damage to {2} \n{2} blocks some of it and is now at {3} health", Name, damage, hokemon1.Name, hokemon1.Health); Console.WriteLine("pess any key to continue"); Console.ReadKey(); }
static void Main(string[] args) { Hokemon hokeObject01 = new Hokemon(); Console.WriteLine("\nHokemon name is: {0}", hokeObject01.Name); hokeObject01.get_details(); Hokemon hokeObject02 = new Hokemon(); Console.WriteLine("\nHokemon name is: {0}", hokeObject02.Name); hokeObject02.get_details(); // Using the about method hokeObject01.about(); Battle_Arena firstArena = new Battle_Arena(); // Instantiated Battle_Arena firstArena.ChallengeMe(hokeObject01); firstArena.ChallengeAccepted(hokeObject02); firstArena.Battle(hokeObject01, hokeObject02); // Declaring members Hinstinct[] ChallengerArray = new Hinstinct[3]; Random rnd = new Random(); bool repeatGame = true; string result; // Creating player Hokemon Halor playerHokemon01 = new Halor(); // Instantiation from Halor class // NPC Hokemon for (int i = 0; i < ChallengerArray.Length; i++) { ChallengerArray[i] = new Hinstinct(); // Instatiating challenger Hokemon } while (repeatGame == true) { playerHokemon01.about(); firstArena.ChallengeMe(playerHokemon01); firstArena.Battle(playerHokemon01, ChallengerArray[rnd.Next(0, ChallengerArray.Length)]); Console.WriteLine("\nDo you want to repeat the game? (y/n)"); result = Console.ReadLine(); if (result.ToLower()[0] == 'n') { repeatGame = false; } } }
public void Battle(Hokemon Attacker, Hokemon Defender) { int attackValue; int defenceValue; int round = 0; Hokemon tempHoke; while (Attacker.Health >= 0 || Defender.Health >= 0) { round += 1; Console.WriteLine("\n****** ROUND {0} ******\n\n", round); for (int i = 0; i < 2; i++) { attackValue = Attacker.attackCalculator(); defenceValue = Defender.defenceCalculator(); Console.WriteLine("{0}: Attacks with value: {1}", Attacker.Name, attackValue); Console.WriteLine("{0}: Generates a defence...", Defender.Name); Console.WriteLine("{0}: Defence value {1}\n", Defender.Name, defenceValue); Console.WriteLine("{0}: Defender Health {1}"); Defender.Health = (Defender.Health + defenceValue) - attackValue; Console.WriteLine("{0} Defender New Health {1}", Defender.Name, Defender.Health); // Example of how OBJECTS can be switched identifier names // This saves having ot repeat code Console.WriteLine("\n***Switch turns: Defender becomes the attacker***\n\n"); tempHoke = Attacker; Attacker = Defender; Defender = tempHoke; } } if (Attacker.Health > Defender.Health) { Console.WriteLine("{0}: WINS", attacker.Name); } else { Console.WriteLine("{0}: WINS", defender.Name); } }
public void Battle(Hokemon Attacker, Hokemon Defender) // Passing in two PARAMETERS // two Hokemon for the Battle { Hokemon tempHoke; int round = 0; while (Convert.ToInt32(Attacker.Health) >= 0 || Convert.ToInt32(Defender.Health) >= 0) { int attackValue = Attacker.attackCalculator(); int defenceValue = Defender.defenceCalculator(); round += 1; // Alternate to statement round = round + 1 Console.WriteLine("\n******** ROUND {0} ********\n", round); for (int i = 0; i < 2; i++) { // Attacker attacks Console.WriteLine("{0}: Attacks with value {1} ", Attacker.Name, attackValue); // Defenders defence Console.WriteLine("{0}: Defends with Value {1}", Defender.Name, defenceValue); Console.WriteLine("{0}: health = {1}", Defender.Name, Defender.Health); // Calculate the impact of the Attach on defenders health Defender.Health = (Defender.Health + defenceValue) - attackValue; Console.WriteLine("{0}: New health value = {1} // Calc: {1} + {2} - {3}", Defender.Name, Defender.Health, defenceValue, attackValue); // IMPORTANT part of the Battle Console.WriteLine("\n\n*** SWITCHING TURNS - Attacker now the Defender ***\n"); tempHoke = Attacker; // tempHoke is assigned the attacker object Attacker = Defender; Defender = tempHoke; } } if (Attacker.Health > Defender.Health) { Console.WriteLine("{0} WINS", Attacker.Name); } else { Console.WriteLine("{0} WINS", Defender.Name); } }
static void Main(string[] args) { Console.WriteLine("Welcome to Hokeworld! "); Hokemon[] ChallengerArray = new Hokemon[3]; Battle_Arena firstArena = new Battle_Arena(); //INSTANTIATED Battle_Arena Random rnd = new Random(); bool repeatGame; string result; Hokemon hokeObject01 = new Hokemon(); hokeObject01.get_details(); Console.WriteLine("\n*********\n"); Halor haloHokemon01 = new Halor(); haloHokemon01.get_details(); haloHokemon01.about(); Console.WriteLine("\n*********\n"); Hystic hystHokemon01 = new Hystic(); hystHokemon01.get_details(); hystHokemon01.about(); Console.WriteLine("\n*********\n"); // NPC Hokemon for (int i = 0; i < ChallengerArray.Length; i++) { ChallengerArray[i] = new Hokemon(); // INSTATANTIATING Challenger Hokemon } Battle_Arena firstArena = new Battle_Arena(); firstArena.Battle(hokeObject01, ChallengerArray[rnd.Next(0, ChallengerArray.Length)]); firstArena.ChallengeAccepted(hokeObject01, hystHokemon01); // Passing two objects into // the firstArena }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Console.WriteLine("Hello to Hokeworld!"); Hokemon hokeObject01 = new Hokemon(); // INSTANTIATION of object hokeObject01 //Console.WriteLine("Hokemon name is: {0}", hokeObject01.Name); hokeObject01.get_details(); Hokemon hoke02 = new Hokemon(); // INSTANTIATION of object 2 //Console.WriteLine("Hokemon name is: {0}", hokeObject01.Name); Console.WriteLine("Name of Hokemon: {0}", hoke02.Name); Console.WriteLine("***********"); Console.WriteLine("****Details below***"); hoke02.get_details(); Hokemon hoke03 = new Hokemon(); // INSTANTIATION of object 2 //Console.WriteLine("Hokemon name is: {0}", hokeObject01.Name); hoke03.get_details(); Battle_Arena firstArena = new Battle_Arena(); // INSTANTIATED Battle_Arena firstArena.ChallengeMe(hokeObject01); firstArena.ChallengeAccepted(hokeObject01, hoke03); // Passing two objects into // the firstArena Hokemon hoke04 = new Hokemon(); //INSTANTIATION from Hokeon Class Halor haloHokemon01 = new Halor(); //INSTANTIATION from Hokeon Class haloHokemon01.get_details(); //Demonstrating POLYMORPHISM with about method //a Hokemon instance hoke02 //a halor instance haloHokemon01 hoke02.about(); haloHokemon01.about() /* * Battle_Arena firstArena = new Battle_Arena(); // INSTANTUATED Battle_Arena */ }
public bool battleRequest(Hokemon challenger1, Hokemon challenger2) { string request; Console.WriteLine("{0} wants to fight {1}. do you accept?", challenger1.Name, challenger2.Name); request = Console.ReadLine(); if (request.ToUpper() == "YES") { return(true); } else { return(false); } }
public void battle(Hokemon Attacker, Hokemon Defender) { Hokemon temp_hoke; int round = 0; while (Convert.ToInt32(Attacker.Health) >= 0 || Convert.ToInt32(Defender.Health) >= 0) { int attack_value = Attacker.attack_calculator(); int defence_value = Defender.defence_calculator(); round += 1; if (round > 40) { Console.WriteLine("ITS A DRAW!!!!"); break; } Console.WriteLine("\n\n-*-*-*-ROUND" + round + "-*-*-*-\n\n"); for (int i = 0; i < 2; i++) { Console.WriteLine("{0} : Attackes with value {1}", Attacker.Name, attack_value); Console.WriteLine("{0} : Defends with value {1}", Defender.Name, defence_value); Console.WriteLine("{0} : Health = {1}", Defender.Name, Defender.Health); Defender.Health = (Defender.Health + defence_value) - attack_value; Console.WriteLine("\n{0}: Current Health = {1} // Calc: {1} + {2} - {3}", Defender.Name, Defender.Health, defence_value, attack_value); Console.WriteLine("\n\n**** SWITCHING SIDES ****\n**** Attacker now defender ****"); temp_hoke = Attacker; Attacker = Defender; Defender = temp_hoke; } } if (Attacker.Health > Defender.Health) { Console.WriteLine(Attacker.Name + " IS THE WINNER"); } else { Console.WriteLine(Defender.Name + " IS THE WINNER"); } }
static void Main(string[] args) { Console.WriteLine("Welcome to Hokeworld!"); Console.WriteLine(); // instantiate new Hokemon object (player 1) Hokemon hoke01 = new Hokemon(); hoke01.get_details(); hoke01.about(); Console.WriteLine(); // delays System.Threading.Thread.Sleep(1000); // instantiate new Hokemon object (player 2) Hokemon hoke02 = new Hokemon(); hoke02.get_details(); hoke02.about(); Console.WriteLine(); /* * Halor halorHoke01 = new Halor(); // inherits from Halor * halorHoke01.get_details(); * * Hokemon hoke04 = new Hokemon(); // instantiation from Hokemon class * * // demonstrating polymorphism with about method * // a Hokemon instance hoke04 * // a halor instance halorHoke01 * hoke04.about(); * halorHoke01.about(); */ // creates the object firstArena from Battle_Arena class Battle_Arena firstArena = new Battle_Arena(); firstArena.Request_A_Challenger(hoke01); System.Threading.Thread.Sleep(3000); firstArena.Accept_The_Battle(hoke01, hoke02); firstArena.Battle(hoke01, hoke02); }
public void Battle(Hokemon Attacker, Hokemon Defender) { int attackValue; int defenceValue; int round = 0; Hokemon tempHoke; while (Attacker.Health >= 0 && Defender.Health >= 0) { for (int i = 0; i < 2; i++) { round += 1; // This is the same as round = round + 1 Console.WriteLine("\n\nROUND {0}\n\n", round); attackValue = Attacker.attackCalculator(); defenceValue = Defender.defenceCalculator(); Console.WriteLine("{0}: Attacks with value {1}", Attacker.Name, attackValue); Console.WriteLine("\n{0}: Generates a defence...", Defender.Name); Console.WriteLine("\n{0}: Defends with value {1}", Defender.Name, defenceValue); Console.WriteLine("\n{0}: Health is {1}", Defender.Name, Defender.Health); Console.WriteLine("\nCalculation: (Health {0} + Defence {1}) - Attack {2}", Defender.Health, defenceValue, attackValue); Defender.Health = (Defender.Health + defenceValue) - attackValue; Console.WriteLine("\n{0}: Health changed to {1}", Defender.Name, Defender.Health); Console.WriteLine("\nSwitch turns: Defender becomes the attacker..."); tempHoke = Attacker; Attacker = Defender; Defender = tempHoke; } } if (Attacker.Health > Defender.Health) { Console.WriteLine("\n{0} wins the battle!", Attacker.Name); } else { Console.WriteLine("\n{0} wins the battle!", Defender.Name); } }
static void Main(string[] args) { Console.WriteLine("Hello Welcome to Hokeworld, home of the hokemon!"); //instanation of new Hokemon Hokemon hoke01 = new Hokemon(); // INSTANTIATE new Hokemon object referred to as Hoke01 hoke01.get_details(); Console.WriteLine("Attack value is: {0}", hoke01.attackCalculator()); Console.WriteLine("Defence value is: {0}", hoke01.defenceCalculator()); Hokemon hoke02 = new Hokemon(); // INSTANTIATE Hoke02 hoke02.get_details(); Console.WriteLine("Attack value is: {0}", hoke02.attackCalculator()); Console.WriteLine("Defence value is: {0}", hoke02.defenceCalculator()); Hokemon hokemonObject = new Hokemon(); // INSTANTIATE hokemonObject hokemonObject.get_details(); Console.WriteLine("Attack value is: {0}", hokemonObject.attackCalculator()); Console.WriteLine("Defence value is: {0}", hokemonObject.defenceCalculator()); Hokemon hoke03 = new Hokemon(); // INSTANTIATE from Hokemon Parent class HALOR hoke04 = new HALOR(); // INSTANTIATE from Halor child class Console.WriteLine("I am part of {0} team.", hoke04.team); Battle_Arena newBattleObject = new Battle_Arena(); newBattleObject.requestAChallenger(hoke03); // In newBattleObject passing // Hoke02 object as an // Argument newBattleObject.theBattle(hoke03, hoke04); }
static void Main(string[] args) { Console.WriteLine("Welcome to the world of Hokemon!\n\n"); Hokemon HokeObject01 = new Hokemon(); // INSTANTIATING our first object HokeObject01.get_details(); System.Threading.Thread.Sleep(1000); // Sleep for 1 second // Create a second Hokemon Hokemon Hoke02 = new Hokemon(); Hoke02.get_details(); HokeObject01.about(); Hoke02.about(); /* * Halor halorHoke01 = new Halor(); * halorHoke01.get_details(); * // Example of POLYMORPHISM with the about method in following objects * Hoke02.about(); * halorHoke01.about(); */ Battle_Arena firstArena = new Battle_Arena(); // Instiating the object firstArena // from the Battle_Arena CLASS firstArena.RequestAChallenger(HokeObject01); // ARGUMENT HokeObject01 // passed into the // firstArena object // method Req.... firstArena.AcceptingTheBattle(HokeObject01, Hoke02); firstArena.Battle(HokeObject01, Hoke02); // Starts the Battle }
public void battle(Hokemon hokemon1, Hokemon hokemon2) { while (hokemon1.Health >= 0 && hokemon2.Health >= 0) { if (hokemon1.Speed >= hokemon2.Speed) { Console.WriteLine("{0} has a higher speed so it attacks first", hokemon1.Name); hokemon1.fight(hokemon2); Console.WriteLine("*****************"); if (hokemon2.Health > 0) { hokemon2.fight(hokemon1); Console.WriteLine("*****************"); } } else { Console.WriteLine("{0} has a higher speed so it attacks first", hokemon2.Name); hokemon2.fight(hokemon1); Console.WriteLine("*****************"); if (hokemon1.Health > 0) { hokemon1.fight(hokemon2); Console.WriteLine("*****************"); } } } if (hokemon1.Health <= 0) { Console.WriteLine("{0} won", hokemon2.Name); } if (hokemon2.Health <= 0) { Console.WriteLine("{0} won", hokemon1.Name); } }
static void Main(string[] args) { Console.WriteLine("Welcome to the world of Hokemon!!!\n\n"); Hokemon hoke1 = new Hokemon(); hoke1.get_details(); Hokemon hoke2 = new Hokemon(); hoke2.get_details(); Halor halor_hoke1 = new Halor(); halor_hoke1.get_details(); Hinstinct hinstinct_hoke1 = new Hinstinct(); hinstinct_hoke1.get_details(); Hystic hystic_hoke1 = new Hystic(); hystic_hoke1.get_details(); hoke1.about(); halor_hoke1.about(); hinstinct_hoke1.about(); hystic_hoke1.about(); battle_arena arena1 = new battle_arena(); // creating the object of the first arena arena1.challenge_request(hoke1); //argument hoke1 passed into the first arena arena1.accept_battle(hoke1, hoke2); arena1.battle(hoke1, hoke2); }
public void ChallengeAccepted(Hokemon Challenger, Hokemon Accepter) { Console.WriteLine("{0}: 'I accept you challenge for a fight'" + "Come on then {1} lets RUMBLE!!", Accepter.Name, Challenger.Name); }
public void ChallengeMe(Hokemon hokeChallenge) // Passing a Hoke Object into Method //to use in the method { Console.WriteLine("{0}: says ' I want a BATTLE!!!!!'", hokeChallenge.Name); }
public void ChallengeMe(Hokemon hokeChallenger) { Console.WriteLine("\n\n{0} says: 'I want to battle!'", hokeChallenger.Name); }
public void ChallengeAccepted(Hokemon hokeAccepter) { Console.WriteLine("\n{0} says: 'I accept your challenge!'", hokeAccepter.Name); }
public void accept_battle(Hokemon contender1, Hokemon contender2) { Console.WriteLine(contender2.Name + ": 'I accept your challenge " + contender1.Name + "' "); System.Threading.Thread.Sleep(2000); Console.WriteLine(contender1.Name + ": 'LETS GO!!!' "); }
public void requestAChallenger(Hokemon requestor) { Console.WriteLine("{0}: says 'I Want A Challenger!!!'", requestor.name); }
public void request_challenge(Hokemon requestor) { Console.WriteLine("{0}: says 'I want a battle!'", requestor.Name); }
public void RequestAChallenger(Hokemon contender) { Console.WriteLine("{0}: say's 'I want a BATTLE... Who is ready to challenge me?'", contender.Name); }
public void AcceptingTheBattle(Hokemon contender01, Hokemon contendor02) { Console.WriteLine("{0}: 'I accept the challenge to fight {1}' ", contendor02.Name, contender01.Name); System.Threading.Thread.Sleep(2000); Console.WriteLine("{1}: 'Great {0}, lets start a BATTLE!!!' ", contendor02.Name, contender01.Name); }
public void Request_A_Challenger(Hokemon contender) { Console.WriteLine("{0}: I want a battle. Who is ready to challenge me?", contender.Name); Console.WriteLine(); }
public void Battle(Hokemon Attacker, Hokemon Defender) { Hokemon tempHoke; int round = 0; while (Convert.ToInt32(Attacker.Health) >= 0 || Convert.ToInt32(Defender.Health) >= 0) { int attackValue; int defenseValue; round = (round + 1); Console.WriteLine("************* ROUND {0} *************", round); for (int i = 0; i < 2; i++) { attackValue = Attacker.attackCalculator(); defenseValue = Defender.defenseCalculator(); // Attacker attacks Console.WriteLine("{0}: Attacks with value {1}", Attacker.Name, attackValue); // Defender's defense Console.WriteLine("{0}: Defends with value {1}", Defender.Name, defenseValue); Console.WriteLine("{0}'s health = {1}", Defender.Name, Defender.Health); // calculates impact of attack on defender's health Defender.Health = (Defender.Health + defenseValue) - attackValue; Console.WriteLine("{0}'s new health = {1}", Defender.Name, Defender.Health, attackValue); Console.WriteLine(); // switch turns if ((((Attacker.Health > 0) & (Defender.Health > 0))) & (round != 10)) { Console.WriteLine("----- SWITCHING TURNS -----"); tempHoke = Attacker; // tempHoke assigned to Attacker object Attacker = Defender; Defender = tempHoke; Console.WriteLine(); } } if (Attacker.Health <= 0) { if (Defender.Health > Attacker.Health) { Console.WriteLine("{0} WINS!", Defender.Name); Environment.Exit(0); } } else if (Defender.Health <= 0) { if (Attacker.Health > Defender.Health) { Console.WriteLine("{0} WINS!", Attacker.Name); Environment.Exit(0); } } if (round == 10) { if ((Attacker.Health <= 0) || (Defender.Health > Attacker.Health)) { Console.WriteLine("END OF BATTLE! {0} WINS!", Defender.Name); Environment.Exit(0); } else if ((Defender.Health <= 0) || (Attacker.Health > Defender.Health)) { Console.WriteLine("END OF BATTLE! {0} WINS!", Attacker.Name); Environment.Exit(0); } else { Console.WriteLine("END OF BATTLE! IT'S A TIE!"); } } //if ((Attacker.Health > Defender.Health) || (Defender.Health <= 0)) //{ // Console.WriteLine("{0} WINS!", Attacker.Name); // Environment.Exit(0); //} //else if ((Defender.Health > Attacker.Health) || (Attacker.Health <= 0)) //{ // Console.WriteLine("{0} WINS!", Defender.Name); // Environment.Exit(0); //} } }
public void challenge_request(Hokemon contender) { Console.WriteLine("{0}: Say's 'I want to battle... Anyone willing to challenge me!?!?'", contender.Name); }