public void addStack(BattleUnitStack us) { if (army.Count < 9) { army.Add(us); } }
public string attack(BattleUnitStack att, BattleUnitStack def) { if (att.bus.Defence != att.bus.StandardDefence) { att.bus.Defence = att.bus.StandardDefence; } if (att.army != def.army) { double totald1; double totald2; Random rnd = new Random(); if (att.bus.Attack > def.bus.Defence) { totald1 = att.bus.qty * att.bus.Damage.Item1 * (1 + 0.05 * (att.bus.Attack - def.bus.Defence)); totald2 = att.bus.qty * att.bus.Damage.Item2 * (1 + 0.05 * (att.bus.Attack - def.bus.Defence)); } else { totald1 = att.bus.qty * att.bus.Damage.Item1 / (1 + 0.05 * (def.bus.Defence - att.bus.Attack)); totald2 = att.bus.qty * att.bus.Damage.Item2 / (1 + 0.05 * (def.bus.Defence - att.bus.Attack)); } int totaldamage = rnd.Next((int)totald1, (int)totald2); int beat = def.bus.Hitpoints + (def.bus.StandardHitpoints * def.bus.qty); if (beat - totaldamage <= 0) { Kill(def); return("Killed"); } if ((beat - totaldamage < def.bus.StandardHitpoints) && (beat - totaldamage > 0)) { def.bus.Hitpoints = beat - totaldamage; def.bus.qty = 0; } def.bus.qty = (beat - totaldamage) / def.bus.StandardHitpoints; def.bus.Hitpoints = (beat - totaldamage) % def.bus.StandardHitpoints; // att.canBeUse = false; if (!(att.mod.Contains(new Modificators.No_Counter())) && (counter == 0)) { counter++; var a = counterAttack(att, def); if (a == "Was Failed by") { return("Was Failed by"); } counter = 0; } return("Damaged"); } return("Same Army"); }
public void Kill(BattleUnitStack def) { if (player[0].army.Contains(def)) { player[0].army.Remove(def); attem.Remove(def); } else if (player[1].army.Contains(def)) { player[1].army.Remove(def); attem.Remove(def); } }
public string counterAttack(BattleUnitStack att, BattleUnitStack def) { //атака в половину от стандартной def.bus.Attack /= 2; string a = attack(def, att); def.bus.Attack *= 2; if (a == "Killed") { return("Was Failed by"); } return(" "); }
public string defeat(BattleUnitStack u) { string str = " "; if (player[0].army.Contains(u)) { str = "player 2 wins this battle"; } if (player[1].army.Contains(u)) { str = "player 1 wins this battle"; } return(str); }
public void queue() { ini(); for (int i = 0; i < player[0].army.Count + player[1].army.Count; i++) { for (int j = 0; j < player[0].army.Count + player[1].army.Count; j++) { if (attem[i].bus.Initiative > attem[j].bus.Initiative) { BattleUnitStack tmp = attem[j]; attem[j] = attem[i]; attem[i] = tmp; } } } }
public void defend(BattleUnitStack u) { u.bus.Defence *= (int)1.3; u.canBeUse = false; }
public void wait(BattleUnitStack u) { u.bus.Initiative = -u.bus.Initiative; queue(); }