public void opponentMoveExecution(int moveNum, int chargeNum, character player, character opponent, string pType, string oType, game g, ref bool check) { while (check == false) { switch (moveNum) { case 1: Console.WriteLine("Opponent used Punch!"); player.changeHP(opponent.punch()); check = true; break; case 2: Console.WriteLine("Opponent used {0}!", SM1MoveName(oType)); player.changeHP(opponent.SM1(pType)); check = true; break; case 3: Console.WriteLine("Opponent used {0}!", SM2MoveName(oType)); player.changeHP(opponent.SM2(pType, chargeNum)); check = true; break; case 4: Console.WriteLine("Opponent used Charge!"); if (opponent.Charge() == false) { g.opponentMoveExecution(g.opponentMoveNum(), opponent.getCharge(), player, opponent, pType, oType, g, ref check); } else { check = true; } break; } } }
static void Main(string[] args) { /*character test = new character("fire"); * test.punch(); * test.displayHP(); * Console.ReadLine();*/ string characterName = "", characterType = "", opponentType = "", opponentName = ""; int characterNumber = 0, opponentNumber = 0, first = 0; int choice = 0; bool p1XPCheck, oXPCheck, chargeCheck1 = false, chargeCheck2 = false; game test2 = new game(); //creates a new game test2.chooseCharacter(ref characterName, ref characterType, ref characterNumber, test2); //user picks character test2.opponentNumber(characterNumber, ref opponentNumber); //opponent's character is randomised test2.opponentChar(opponentNumber, ref opponentType, ref opponentName); //opponent's character details are set var P1 = characterFactory.Create(characterType); //player's character is created var Opponent = characterFactory.Create(opponentType); //opponent's character is created Console.WriteLine("The opponent has chosen to use {0}", Opponent.returnName()); first = test2.whoGoesFirst(); if (first == 1) { Console.WriteLine("You get to take the first turn!"); do { oXPCheck = Opponent.checkHP(); p1XPCheck = P1.checkHP(); choice = test2.chooseMove(characterType, test2); test2.moveExecution(choice, P1, opponentType, P1.getCharge(), Opponent, test2, ref chargeCheck1); Console.WriteLine("Opponent's HP is now {0}", Opponent.displayHP()); oXPCheck = Opponent.checkHP(); p1XPCheck = P1.checkHP(); if (oXPCheck == false) { break; } test2.opponentMoveExecution(test2.opponentMoveNum(), Opponent.getCharge(), P1, Opponent, characterType, opponentType, test2, ref chargeCheck2); Console.WriteLine("Players 1's HP is now {0}", P1.displayHP()); p1XPCheck = P1.checkHP(); chargeCheck1 = false; chargeCheck2 = false; } while ((p1XPCheck == true) && (oXPCheck == true)); } else { Console.WriteLine("The computer will take the first turn"); do { test2.opponentMoveExecution(test2.opponentMoveNum(), Opponent.getCharge(), P1, Opponent, characterType, opponentType, test2, ref chargeCheck2); Console.WriteLine("Players 1's HP is now {0}", P1.displayHP()); p1XPCheck = P1.checkHP(); if (p1XPCheck == false) { break; } choice = test2.chooseMove(characterType, test2); test2.moveExecution(choice, P1, opponentType, P1.getCharge(), Opponent, test2, ref chargeCheck1); Console.WriteLine("Opponent's HP is now {0}", Opponent.displayHP()); oXPCheck = Opponent.checkHP(); chargeCheck1 = false; chargeCheck2 = false; } while ((p1XPCheck == true) && (oXPCheck == true)); } if (p1XPCheck == false) { Console.WriteLine("You Lose!"); } else { Console.WriteLine("You Win!"); } Console.ReadLine(); }