7. ساخت یک نبرد اتوماتیک
زبان نوشتاری #C
سطح برنامه : متوسط رو به بالا
*********//*********
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace de_coder
{
class Program
{
static void Main(string[] args)
{
int herohealth;
int monsterhealth;
string monstername;
int monsterhealthbegining;
Random healthgen = new Random();
herohealth = healthgen.Next(5, 21);
Console.WriteLine("you have " + herohealth + " health");
monsterhealth = healthgen.Next(5, 21);
monsterhealthbegining = monsterhealth;
if (monsterhealth <= 8)
{
monstername = "goblin";
Console.WriteLine("A simple goblin with " + monsterhealth + " health attacks!");
goto heroattack;
}
else if (monsterhealth >= 9 && 13 >= monsterhealth )
{
monstername = "owlbear";
Console.WriteLine("An owlbear with " + monsterhealth + " health attacks!");
goto heroattack;
}
else if (monsterhealth >= 14 && 17 >= monsterhealth)
{
monstername = "orc";
Console.WriteLine("An orc with " + monsterhealth + " health attacks!");
goto heroattack;
}
else
{
monstername = "dragon";
Console.WriteLine("A dragon with " + monsterhealth + " health attacks!");
goto heroattack;
}
heroattack:
System.Threading.Thread.Sleep(50);
if (herohealth >= 0)
{
Random roll = new Random();
int roll20;
int roll6;
int damage;
roll20 = roll.Next(1, 21);
if (roll20 >= 9)
{
Console.Write("You hit it for ");
roll6 = roll.Next(1, 7);
Console.WriteLine(roll6 + " damage!");
damage = roll6;
monsterhealth -= damage;
if (monsterhealth >= 0)
{
goto monsterattack;
}
else
{
Console.WriteLine("You win!");
}
}
else
{
Console.WriteLine("You missed!");
goto monsterattack;
}
}
else
{
Console.WriteLine("You loose!");
}
monsterattack:
System.Threading.Thread.Sleep(50);
if (monsterhealth >= 0)
{
Random roll = new Random();
int roll202;
int roll62;
int damage2;
roll202 = roll.Next(1, 21);
if (roll202 >= 9)
{
Console.Write("It hits you for ");
roll62 = roll.Next(1, 7);
Console.WriteLine(roll62 + " damage!");
damage2 = roll62;
herohealth -= damage2;
if (herohealth >= 0)
{
goto heroattack;
}
else
{
Console.WriteLine("You loose!");
}
}
else
{
Console.WriteLine("It missed!");
goto heroattack;
}
}
else
{
int reward;
reward = monsterhealthbegining * 10;
Console.WriteLine("You got " + reward + " silver for slaying the " + monstername + ".");
}
}
}
}
@de_coder
زبان نوشتاری #C
سطح برنامه : متوسط رو به بالا
*********//*********
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace de_coder
{
class Program
{
static void Main(string[] args)
{
int herohealth;
int monsterhealth;
string monstername;
int monsterhealthbegining;
Random healthgen = new Random();
herohealth = healthgen.Next(5, 21);
Console.WriteLine("you have " + herohealth + " health");
monsterhealth = healthgen.Next(5, 21);
monsterhealthbegining = monsterhealth;
if (monsterhealth <= 8)
{
monstername = "goblin";
Console.WriteLine("A simple goblin with " + monsterhealth + " health attacks!");
goto heroattack;
}
else if (monsterhealth >= 9 && 13 >= monsterhealth )
{
monstername = "owlbear";
Console.WriteLine("An owlbear with " + monsterhealth + " health attacks!");
goto heroattack;
}
else if (monsterhealth >= 14 && 17 >= monsterhealth)
{
monstername = "orc";
Console.WriteLine("An orc with " + monsterhealth + " health attacks!");
goto heroattack;
}
else
{
monstername = "dragon";
Console.WriteLine("A dragon with " + monsterhealth + " health attacks!");
goto heroattack;
}
heroattack:
System.Threading.Thread.Sleep(50);
if (herohealth >= 0)
{
Random roll = new Random();
int roll20;
int roll6;
int damage;
roll20 = roll.Next(1, 21);
if (roll20 >= 9)
{
Console.Write("You hit it for ");
roll6 = roll.Next(1, 7);
Console.WriteLine(roll6 + " damage!");
damage = roll6;
monsterhealth -= damage;
if (monsterhealth >= 0)
{
goto monsterattack;
}
else
{
Console.WriteLine("You win!");
}
}
else
{
Console.WriteLine("You missed!");
goto monsterattack;
}
}
else
{
Console.WriteLine("You loose!");
}
monsterattack:
System.Threading.Thread.Sleep(50);
if (monsterhealth >= 0)
{
Random roll = new Random();
int roll202;
int roll62;
int damage2;
roll202 = roll.Next(1, 21);
if (roll202 >= 9)
{
Console.Write("It hits you for ");
roll62 = roll.Next(1, 7);
Console.WriteLine(roll62 + " damage!");
damage2 = roll62;
herohealth -= damage2;
if (herohealth >= 0)
{
goto heroattack;
}
else
{
Console.WriteLine("You loose!");
}
}
else
{
Console.WriteLine("It missed!");
goto heroattack;
}
}
else
{
int reward;
reward = monsterhealthbegining * 10;
Console.WriteLine("You got " + reward + " silver for slaying the " + monstername + ".");
}
}
}
}
@de_coder
TrieDictionary.rar
50.4 KB