Sei sulla pagina 1di 7

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hitGame
{
class Program
{
int life = 10;
int revengeBar = 0;
int powerBar = 0;
//3 methods for Punch
public int lowPunch()
{
life -= 6;
powerBar = 6 / 2;
revengeBar = 6 / 2;
return life;
}
public int midPunch()
{
life -= 9;
powerBar = 9 / 2;
revengeBar = 9 / 2;
return life;
}
public int highPunch()
{
life -= 11;
powerBar = 11 / 2;
revengeBar = 11 / 2;
return life;
}

// 3 methods for Kick


public int lowKick()
{
life -= 9;
powerBar = 9 / 2;
revengeBar = 9 / 2;
return life;
}
public int midKick()
{
life -= 12;
powerBar = 12 / 2;
revengeBar = 12 / 2;
return life;
}

public int highKick()


{
life -= 16;
powerBar = 16 / 2;
revengeBar = 16 / 2;
return life;
}
// super attack method
public int superAttack1()
{
life -= 10;
return life;
}
public int superAttack2()
{
life -= 20;
return life;
}
public int superAttack3()
{
life -= 30;
return life;
}
public int superAttack4()
{
life -= 40;
return life;
}
// Ultra attack method
public int ultraAttack()
{
life -= 50;
return life;
}
// Actions of player B
public static void player2(Program p2, Program p1)
{
while (p2.life > 0 && p1.life > 0)
{
Console.WriteLine("\t\t Player B (Attack)");
Console.WriteLine("Power bar: " + p2.powerBar);
Console.WriteLine("Power bar: " + p2.revengeBar);
Console.WriteLine("Health " + p2.life);
Console.WriteLine("Press:");
Console.WriteLine("1-Low Punch");
Console.WriteLine("2-Medium Punch");
Console.WriteLine("3-High Punch");
Console.WriteLine("4-Low Kick");
Console.WriteLine("5-Medium Kick");
Console.WriteLine("6-High Kick");
Console.WriteLine("7-Super Attack");
Console.WriteLine("8-Ultra Attack");
Console.WriteLine("--------------");
Console.WriteLine("Kindly select attack from above choices");
int hitChoice = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("--------------");
if (hitChoice == 8 && p2.revengeBar < 100)
{
Console.WriteLine("You dont have sufficient points in revenge
bar yet. Try another attack");
continue;
}
// Defense logic starts
bool defense = false;
Console.WriteLine("\t\tPlayer A (Defense): ");
Console.WriteLine("-------------------");
if (hitChoice == 1 || hitChoice == 4)
Console.WriteLine("A, B , C, D");

else if (hitChoice == 2 || hitChoice == 5)


Console.WriteLine("A, B , C");

else if (hitChoice == 3 || hitChoice == 6)


Console.WriteLine("A, B");

else if (hitChoice == 7 || hitChoice == 8)


Console.WriteLine("D,E,F,G,H,I,J");

char d = Console.ReadKey().KeyChar;
Console.WriteLine();
Console.WriteLine();
if (hitChoice == 1 || hitChoice == 4)
{
if (d == 'C')
{
defense = true;
}
}
else if (hitChoice == 2 || hitChoice == 5)
{
if (d == 'B')
{
defense = true;
}
}
else if (hitChoice == 3 || hitChoice == 6)
{
if (d == 'A')
{
defense = true;
}
}
else if (hitChoice == 7 || hitChoice == 8)
{
if (d == 'E')
{
defense = true;
}
}
// attack method calls if defense got failed
if (defense == false)
{
switch (hitChoice)
{
case 1:
{
p1.lowPunch();
break;
}
case 2:
{
p1.midPunch();
break;
}
case 3:
{
p1.highPunch();
break;
}

case 4:
{
p1.lowKick();
break;
}
case 5:
{
p1.midKick();
break;
}
case 6:
{
p1.highKick();
break;
}
case 7:
{
if (p2.powerBar >= 100)
p1.superAttack4();

else if (p2.powerBar >= 75)


p1.superAttack3();
else if (p2.powerBar >= 50)
p1.superAttack2();
else if (p2.powerBar >= 25)
p1.superAttack1();
break;
}
case 8:
{
p2.ultraAttack();
break;
}
}
}
// Now its turn of player A to attack
if (p1.life < 1)
{
Console.WriteLine("B winner");
}
else
{
Console.WriteLine("else");
player1(p1, p2);
}
}
}
// Actions of player A
public static void player1(Program p1, Program p2)
{
while (p1.life > 0 && p2.life > 0)
{
Console.WriteLine("\t\t Player A (Attack)");
Console.WriteLine("Power bar: " + p1.powerBar);
Console.WriteLine("Power bar: " + p1.revengeBar);
Console.WriteLine("Health " + p1.life);
Console.WriteLine("Press:");
Console.WriteLine("1-Low Punch");
Console.WriteLine("2-Medium Punch");
Console.WriteLine("3-High Punch");
Console.WriteLine("4-Low Kick");
Console.WriteLine("5-Medium Kick");
Console.WriteLine("6-High Kick");
Console.WriteLine("7-Super Attack");
Console.WriteLine("8-Ultra Attack");
Console.WriteLine("--------------");
Console.WriteLine("Kindly select attack from above choices");
int hitChoice = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("--------------");
if (hitChoice == 8 && p1.revengeBar < 100)
{
Console.WriteLine("You dont have sufficient points in revenge
bar yet. Try another attack");
continue;
}
// defense logic
bool defense = false;
Console.WriteLine("\t\tPlayer B (Defense): ");
Console.WriteLine("----------");
if (hitChoice == 1 || hitChoice == 4)
Console.WriteLine("A, B , C, D");
else if (hitChoice == 2 || hitChoice == 5)
Console.WriteLine("A, B , C");
else if (hitChoice == 3 || hitChoice == 6)
Console.WriteLine("A, B");
else if (hitChoice == 7 || hitChoice == 8)
Console.WriteLine("D,E,F,G,H,I,J");
char d = Console.ReadKey().KeyChar;
Console.WriteLine();
Console.WriteLine();
if (hitChoice == 1 || hitChoice == 4)
{
if (d == 'C')
{
defense = true;
}
}
else if (hitChoice == 2 || hitChoice == 5)
{
if (d == 'B')
{
defense = true;
}
}
else if (hitChoice == 3 || hitChoice == 6)
{
if (d == 'A')
{
defense = true;
}
}
else if (hitChoice == 7 || hitChoice == 8)
{
if (d == 'E')
{
defense = true;
}
}
// defense failed, so attack method calls
if (defense == false)
{
switch (hitChoice)
{
case 1:
{
p2.lowPunch();
break;
}
case 2:
{
p2.midPunch();
break;
}
case 3:
{
p2.highPunch();
break;
}
case 4:
{
p1.lowKick();
break;
}
case 5:
{
p2.midKick();
break;
}
case 6:
{
p2.highKick();
break;
}
case 7:
{
if (p1.powerBar >= 100)
p1.superAttack4();
else if (p1.powerBar >= 75)
p2.superAttack3();
else if (p1.powerBar >= 50)
p2.superAttack2();
else if (p1.powerBar >= 25)
p2.superAttack1();
break;
}
case 8:
{
p2.ultraAttack();
break;
}
}
}
// Now its turn of player B to attack
if (p2.life < 1)
Console.WriteLine("A winner");
else
player2(p2, p1);
}
}
static void Main(string[] args)
{
Console.WriteLine("Press:");
Console.WriteLine("1- New Game");
Console.WriteLine("2- Exit");
Console.WriteLine("--------------");
int initialChoice = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("--------------");
Program a = new Program();
Program b = new Program();
if (initialChoice == 1)
{
player1(a, b);
Console.WriteLine("Congratulations");
}
else if (initialChoice == 2)
{
Environment.Exit(0);
}
else
{
Console.WriteLine("Invalid entry! TRY AGAIN");
}
Console.ReadLine();
}
}
}

Potrebbero piacerti anche