Class Program
{
struct player
{
public string name;
public int hp;
public int attack;
public int defend;
public int quick;
Public Wugong WG;
}
struct Wugong
{
public string name;
public int ATK;
}
static void Gongfu (wugong[] WG)
{
Wg[0].name= "descending dragon 18 Palm";
WG[0].ATK = 500;
Wg[1].name = "Beat the Dog Stick method";
WG[1].ATK = 600;
Wg[2].name = "Lone solitary Nine Swords";
WG[2].ATK = 600;
}
static void Main (string[] args)
{
Console.backgroundcolor = Consolecolor.white;
Console.foregroundcolor = Consolecolor.black;
Console.clear ();
Player P1 = new player ();
Player P2 = new player ();
Random r = new Random ();
Generate two players
Console.Write ("Please enter the name of the first Warrior:");
P1.name = Console.ReadLine ();
Console.Write ("Please enter the name of the first Warrior:");
P2.name = Console.ReadLine ();
Generate Blood Volume
P1.HP = R.next (1, 1000) + 1000;//initial blood volume
P2.HP = R.next (1, 1000) + 1000;
Generate attack and defense
P1.attack = R.next (1, 50) + 80;
P2.attack = R.next (1, 50) + 80;
P1.defend = R.next (1, 50) + 50;
P2.defend = R.next (1, 50) + 50;
Generate SHENFA-Agility
P1.quick = R.next (100);
P2.quick = R.next (100);
Console.WriteLine ("Player:" + P1.name + "blood Volume:" + p1.hp + "\ t attack:" + p1.attack
+ "\ T Object protection:" + p1.defend + "Agility:" + P1.quick);
Console.WriteLine ("VS");
Console.WriteLine ("Player:" + P2.name + "blood Volume:" + p2.hp + "\ t attack:" + p2.attack
+ "\ T Object protection:" + p2.defend + "Agility:" + P2.quick);
Console.WriteLine ("Click on any key to start the game .....");
Console.readkey ();
while (true)
{
Draw the final result, jump out of the loop
if (p1.hp <= 0 && p2.hp <= 0)
{
Console.WriteLine (p1.name + "+" + P2.name + "Perish! ");
Console.ReadLine ();
Break
}
if (p1.hp <= 0)
{
Console.WriteLine (P1.name + "put" + P2.name + "KO");
Console.ReadLine ();
Break
}
if (p2.hp <= 0)
{
Console.WriteLine (P2.name + "put" + P1.name + "KO");
Console.ReadLine ();
Break
}
War
Wugong[] WG = new WUGONG[3];
Gongfu (WG);
Big strokes
int dz1 = R.next (10);//Large strokes random
if (DZ1 >= 5)//The random number from 1 to 9 takes 8 and 9 has a 20% chance to use the big strokes.
{
Random x = new Random ();
int a = X.next (0, 3);
int dx1 = r.next (100);//Declaration of the Blood-drop variable
int gj1 = r.next (100)-50;//for the purpose of floating P2 attack;
int fy1 = r.next (100)-50;//for the defensive force of floating P1;
Dx1 = ((dx1 + wg[a].atk)-(p1.defend + fy1)) < 0? 0: ((dx1 + wg[a].atk)-(p1.defend + fy1));
To prevent negative blood drop,
P1.HP-= dx1;
if (P1.HP < 0)
{
P1.HP = 0;
}
Console.foregroundcolor = consolecolor.red;
Console.WriteLine (P2.name + "use big strokes" +wg[a].name+ "attack," + P1.name + "cause" + dx1 + "damage. ");
}
else//Normal moves
{
Dodge
int SF1 = R.next (80);//random number of SHENFA
if (p1.quick-sf1 >= 0)
{
Console.foregroundcolor = Consolecolor.black;
Console.WriteLine (P1.name + "dodge" + P2.name + "attack");
}
Else
{
int dx1 = r.next (100);//Declaration of the Blood-drop variable
int gj1 = r.next (100)-50;//for the purpose of floating P2 attack;
int fy1 = r.next (100)-50;//for the defensive force of floating P1;
DX1 = (dx1 + (P2.attack + gj1)-(p1.defend + fy1)) < 0? 0: (dx1 + (P2.attack + gj1)-(p1.defend + fy1));
To prevent negative blood drop,
P1.HP-= dx1;
if (P1.HP < 0)
{
P1.HP = 0;
}
Console.foregroundcolor = consolecolor.red;
Console.WriteLine (P1.name + "uses normal attacks, the" + P2.name + "cause" + dx1 + "damage. ");
}
}
Hold on a second.
System.Threading.Thread.Sleep (1000);
int dz2 = R.next (10);
if (dz2 >= 5)
{
Random y = new random ();
int b = Y.next (0,3);
int dx2 = r.next (100);
int gj2 = r.next (100)-50;//for the purpose of floating P1 attack;
int fy2 = r.next (100)-50;//for the defensive force of floating P2;
DX2 = ((dx2 + wg[b].atk)-(p2.defend + fy2)) < 0? 0: ((dx2 + wg[b].atk)-(p2.defend + fy2));
To prevent negative blood drop,
P2.HP-= DX2;
if (P2.HP < 0)
{
P2.HP = 0;
}
Console.foregroundcolor = Consolecolor.darkmagenta;
Console.WriteLine (P1.name + "use big strokes" +wg[b].name+ "attack," + P2.name + "cause" + dx2 + "damage. ");
}
Else
{
Dodge
int SF2 = R.next (80);
if (P2.quick-sf2 > SF2)
{
Console.foregroundcolor = Consolecolor.black;
Console.WriteLine (P2.name + "dodge" + P1.name + "attack");
}
Else
{
int dx2 = r.next (100);
int gj2 = r.next (100)-50;//for the purpose of floating P1 attack;
int fy2 = r.next (100)-50;//for the defensive force of floating P2;
DX2 = (dx2 + (P1.attack + gj2)-(p2.defend + fy2)) < 0? 0: (dx2 + (P1.attack + gj2)-(p2.defend + fy2));
To prevent negative blood drop,
P2.HP-= DX2;
if (P2.HP < 0)
{
P2.HP = 0;
}
Console.foregroundcolor = Consolecolor.darkmagenta;
Console.WriteLine (P2.name + "uses normal attacks, the" + P1.name + "cause" + dx2 + "damage. ");
}
}
Hold on a second.
System.Threading.Thread.Sleep (1000);
Console.foregroundcolor = Consolecolor.darkblue;
Console.WriteLine ("Player:" + p1.name + "\ t blood Volume:" + p1.hp + "\ t");
Console.WriteLine ("Player:" + p2.name + "\ t blood Volume:" + p2.hp);
}
}
}
C # Battle Game