public void rotateLines() { //-Here we rotate towers and locking for nearest threat int i = ownTowers.Count; if (i < 1) { return; } List <attackDef> attackersList = new List <attackDef>(); List <attackDef> tmp; attackDef near = new attackDef(); foreach (BoardObj t in this.ownTowers) { tmp = t.getImmediateAttackers(this); if (tmp.Count > 0 && (near.empty || near.time > tmp[0].time)) { near = tmp[0]; } } if (!near.empty) { Playfield p = new Playfield(this, near.time); BoardObj myObj = near.attacker.own ? near.attacker : near.target; opposite opp = KnowledgeBase.Instance.getOppositeToAll(p, myObj); if (opp != null) { if (opp.hc != null) { int callTime = near.time - opp.hc.card.DeployTime; if (callTime < 0) { callTime = 0; } p = new Playfield(p, callTime); VectorAI position = new VectorAI(0, 0); //VectorAI position = p.getDeployPosition(opp); //TODO: this decision takes a behavior or a time machine bestCast = new Cast(opp.hc.name, position, opp.hc); } else if (opp.bo != null) { if (opp.bo.TargetType == targetType.GROUND) { //TODO } } else { //TODO automatic creation opposite list in getOppositeToAll or do something else } } } }
public List <attackDef> getPossibleAttackers(Playfield p) { List <attackDef> attackersList = new List <attackDef>(); if (this.HP > 0) { List <BoardObj> enemies = this.own ? p.enemyMinions : p.ownMinions; foreach (BoardObj e in enemies) { if (e.Line != this.Line && this.Line != 3) { continue; } attackDef ad = new attackDef(e, this); if (!ad.empty) { attackersList.Add(ad); } } enemies = this.own ? p.enemyBuildings : p.ownBuildings; foreach (BoardObj e in enemies) { if (e.Line != this.Line && this.Line != 3) { continue; } attackDef ad = new attackDef(e, this); if (!ad.empty) { attackersList.Add(ad); } } enemies = this.own ? p.enemyTowers : p.ownTowers; foreach (BoardObj e in enemies) { if (e.Line != this.Line && this.Line != 3) { continue; } attackDef ad = new attackDef(e, this); if (!ad.empty) { attackersList.Add(ad); } } attackersList.Sort((a, b) => a.time.CompareTo(b.time)); } return(attackersList); }
public List <attackDef> getPossibleAttackers(Playfield p) { List <attackDef> attackersList = new List <attackDef>(); if (this.HP > 0) { List <BoardObj> enemies = this.own ? p.enemyMinions : p.ownMinions; foreach (BoardObj e in enemies) { if (e.Line != this.Line && this.Line != 3) { continue; } attackDef ad = new attackDef(e, this); if (!ad.empty) { attackersList.Add(ad); } } int count = attackersList.Count; if (count > 2) { int skeletons = 0; int minions = 0; for (int i = 0; i < count; i++) { switch (attackersList[i].attacker.Name) { case CardDB.cardName.skeleton: skeletons++; break; case CardDB.cardName.minion: minions++; break; } } if (skeletons > 5) { for (int i = 0; i < count; i++) { if (attackersList[i].attacker.Name == CardDB.cardName.skeleton) { attackersList[i].attacker.Name = CardDB.cardName.skeletonarmy; } } } if (minions > 3) { for (int i = 0; i < count; i++) { if (attackersList[i].attacker.Name == CardDB.cardName.minion) { attackersList[i].attacker.Name = CardDB.cardName.minionhorde; } } } } enemies = this.own ? p.enemyBuildings : p.ownBuildings; foreach (BoardObj e in enemies) { if (e.Line != this.Line && this.Line != 3) { continue; } attackDef ad = new attackDef(e, this); if (!ad.empty) { attackersList.Add(ad); } } enemies = this.own ? p.enemyTowers : p.ownTowers; foreach (BoardObj e in enemies) { if (e.Line != this.Line && this.Line != 3) { continue; } attackDef ad = new attackDef(e, this); if (!ad.empty) { attackersList.Add(ad); } } attackersList.Sort((a, b) => a.time.CompareTo(b.time)); } return(attackersList); }
public List <attackDef> getImmediateAttackers(Playfield p) { List <attackDef> attackersList = new List <attackDef>(); if (this.HP > 0) { List <BoardObj> enemies = this.own ? p.enemyMinions : p.ownMinions; foreach (BoardObj e in enemies) { if (e.Line != this.Line && this.Line != 3) { continue; } attackDef bo1ad = new attackDef(this, e); attackDef bo2ad = new attackDef(e, this); if (bo1ad.time < bo2ad.time) { attackersList.Add(bo1ad); } else if (bo2ad.time != int.MaxValue) { attackersList.Add(bo2ad); } } enemies = this.own ? p.enemyBuildings : p.ownBuildings; foreach (BoardObj e in enemies) { if (e.Line != this.Line && this.Line != 3) { continue; } attackDef bo1ad = new attackDef(this, e); attackDef bo2ad = new attackDef(e, this); if (bo1ad.time < bo2ad.time) { attackersList.Add(bo1ad); } else if (bo2ad.time != int.MaxValue) { attackersList.Add(bo2ad); } } if (this.Tower == 0) { enemies = this.own ? p.enemyTowers : p.ownTowers; foreach (BoardObj e in enemies) { if (e.Line != this.Line) { continue; } attackDef bo1ad = new attackDef(this, e); attackDef bo2ad = new attackDef(e, this); if (bo1ad.time < bo2ad.time) { attackersList.Add(bo1ad); } else if (bo2ad.time != int.MaxValue) { attackersList.Add(bo2ad); } } } attackersList.Sort((a, b) => a.time.CompareTo(b.time)); } return(attackersList); }