Тема: Допоможіть дописати іграшку
abstract class Warrior
{
private Names _name;
private WarriorType _type;
protected int _health;
protected int _damage;
protected bool _isAlive;
protected int _battlesCount;
protected int _armor;
public Warrior(int health, int damage, bool isAlive, int battlesCount, int armor)
{
_armor = armor;
_health = health;
_damage = damage;
_isAlive = isAlive = true;
_battlesCount = battlesCount;
}
public string Name
{
get { return _name.ToString(); }
}
public WarriorType Type
{
get { return _type; }
}
public abstract int Health { get; set; }
public abstract int Damage { get; set; }
public abstract int Armor { get; set; }
public bool isAlive
{
get { return _isAlive ? Health >= 0 : false; }
}
public int BattlesCount
{
get { return _battlesCount; }
}
public override string ToString()
{
return string.Format("Name = {0}, Health = {1}, Armor = {2}, BattlesCount = {3}", Name, Health, Armor, BattlesCount);
}
public override int GetHashCode()
{
int hash = 13;
hash = hash * 7 + _health.GetHashCode();
hash = hash * 7 + _damage.GetHashCode();
hash = hash * 7 + _battlesCount.GetHashCode();
hash = hash * 7 + _isAlive.GetHashCode();
hash = hash * 7 + _name.GetHashCode();
hash = hash * 7 + _type.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
Warrior warr = (Warrior) obj;
if(obj == this) return true;
if (obj == warr)
return warr.Armor == Armor &&
warr.Damage == Damage &&
warr.Health == Health;
return false;
}
}
class Tribe
{
public TribeNames _name;
public int _battlesCount;
List<Warrior> _warriors;
public int _aliveCount;
public int _totalCount;
public Tribe(int battlesCount, int totalCount)
{
_battlesCount = battlesCount;
_totalCount = totalCount;
_warriors = new List<Warrior>();
}
public string Name
{
get { return _name.ToString(); }
}
public int BattlesCount
{
get { return _battlesCount; }
}
public int AliveCount
{
get { return _aliveCount; }
set { _aliveCount = value < 0 ? 0 : value; }
}
public int TotalCount
{
get { return _totalCount; }
set { _totalCount = value < 0 ? 1000 : value; }
}
public Warrior this[int index]
{
get {return _warriors[index];}
set {_warriors[index] = value;}
}
public void Add(Warrior war)
{
_warriors.Add(war);
}
public override int GetHashCode()
{
int hash = 13;
hash = hash * 7 + _battlesCount.GetHashCode();
hash = hash * 7 + _aliveCount.GetHashCode();
hash = hash * 7 + _name.GetHashCode();
hash = hash * 7 + _totalCount.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
Warrior tribe = (Warrior)obj;
if (obj == this) return true;
if (obj == tribe)
return tribe.Name == Name;
return false;
}
public override string ToString()
{
return string.Format("Name of Tribe: {0} Count of Battles: {1} Own count of warrior: {2} ", Name, BattlesCount, TotalCount);
}
}
class Battle
{
public Tribe[] _tribes;
public int _round;
public Tribe _winner;
public bool _isOver;
public Battle(int round, bool isOver, params Tribe[] tribes)
{
_round = round = 0;
_isOver = isOver;
_tribes = tribes;
}
public int RoundCount
{
get { return _round; }
}
public bool NextRound()
{
if( _isOver == true)
{
Console.WriteLine("Round is over!");
_round++;
}
return true;
}
public Tribe Winner(Tribe _winner)
{
if (_isOver == true && _tribes.Length >= 0 && _tribes.Length < 2 )
{
Console.WriteLine("Winner of this round is - " + _winner);
}
return _winner;
}
}
class TribeCreator
{
public int numIronMen;
public int numRedWolfs;
public int numWildAxes;
public int numBrownGhoust;
public Tribe CreateInstance(TribeNames vubor, Tribe number_war)
{
Console.WriteLine("Create Tribes: ");
Console.Write("Maybe name for tribes:");
TribeNames i;
TribeNames my_tribe, first_tribe, second_tribe, thirsd_tribe;
for (i = TribeNames.RedWolfs; i <= TribeNames.BrownGhoust; i++)
{
Console.WriteLine(i);
}
Console.WriteLine("Create first your own tribe with name Iron Men");
switch(vubor)
{
case TribeNames.IronMen:
{
my_tribe = TribeNames.IronMen;
Console.WriteLine("Enter number citizen for tribe: ");
string s = Console.ReadLine();
numIronMen = Convert.ToInt32(s);
break;
Console.WriteLine("Your tride will have name: " + my_tribe + " and have " + numIronMen + " citizen");
}
case TribeNames.RedWolfs:
{
first_tribe = TribeNames.RedWolfs;
Console.WriteLine("Enter number citizen for tribe: ");
string s = Console.ReadLine();
numRedWolfs = Convert.ToInt32(s);
break;
Console.WriteLine("Tride will have name: " + first_tribe + " and have " + numRedWolfs + " citizen");
}
case TribeNames.WildAxes:
{
second_tribe = TribeNames.WildAxes;
Console.WriteLine("Enter number citizen for tribe: ");
string s = Console.ReadLine();
numWildAxes = Convert.ToInt32(s);
break;
Console.WriteLine("Tride will have name: " + second_tribe + " and have " + numWildAxes + " citizen");
}
case TribeNames.BrownGhoust:
{
thirsd_tribe = TribeNames.BrownGhoust;
Console.WriteLine("Enter number citizen for tribe: ");
string s = Console.ReadLine();
numBrownGhoust = Convert.ToInt32(s);
break;
Console.WriteLine("Tride will have name: " + thirsd_tribe + " and have " + numBrownGhoust + " citizen");
}
}
return number_war;
}
}
class Triarius : Warrior
{
public Triarius(int health, int damage, bool isAlive, int battlesCount, int armor) : base(health, damage, isAlive, battlesCount, armor) { }
public override string ToString()
{
return string.Format("Name = {0}, Health = {1}, Armor = {2}, BattlesCount = {3}", Name, Health, Armor, BattlesCount);
}
}
class Princeps : Warrior
{
public Princeps(int health, int damage, bool isAlive, int battlesCount, int armor) : base(health, damage, isAlive, battlesCount, armor) { }
public override string ToString()
{
return string.Format("Name = {0}, Health = {1}, Armor = {2}, BattlesCount = {3}", Name, Health, Armor, BattlesCount);
}
}
class Hastatus : Warrior
{
public Hastatus(int health, int damage, bool isAlive, int battlesCount, int armor) : base(health, damage, isAlive, battlesCount, armor) { }
public override string ToString()
{
return string.Format("Name = {0}, Health = {1}, Armor = {2}, BattlesCount = {3}", Name, Health, Armor, BattlesCount);
}
}
class Accensi : Warrior
{
public Accensi(int health, int damage, bool isAlive, int battlesCount, int armor) : base(health, damage, isAlive, battlesCount, armor) { }
public override string ToString()
{
return string.Format("Name = {0}, Health = {1}, Armor = {2}, BattlesCount = {3}", Name, Health, Armor, BattlesCount);
}
}
enum TribeNames : int
{
RedWolfs, IronMen, WildAxes, BrownGhoust
};
enum WarriorType
{
Tank, Dodge, Critical
};
1. Створюється плем’я користувача з воїнами типу Accensi в кількості заданим користувачем N (TribeCreator)
При створенні воїна TribeCreator задає довільним чином показники воїнів в діапазоні 70-100%
Створюється (TribeCreator) 3 племені з N воїнами (Hastatus, Princeps, Triarius відповідно до кожного племені)
2. Розпочинається перша битва племені користувача з плем’ям воїнів Hastatus (Battle)
Удар (D), що наносить воїн залежить додатково від його здоров’я та є випадковою величино діапазону (0,7-1,0)*D
Втрати залежать від отриманого удару та захисту воїна
3. За умови перемоги племені користувача воїни, що вижили лікуються та отримують бонус до параметрів (Bonus)
4. Повторюються кроки 2-3 з племенами воїнів Princeps, Triarius