public Movements SetChosenPeice(int x, int y) { Coords coords = new Coords(x, y); Troop troop = gameData.GetTroopFromMap(coords); foreach (Movements move in LastMoveables) { if (troop.Equals(move.Troop)) { return(move); } } return(null); }
public static void PrepareAttack() { Main.Bot.WriteToOutput("Preparing Attack..."); for (int i = 0; i < 9; i++) { Troop troopKind = IdentifyTroop(i); int troopQuantity = ReadTroopQuantity(i); if (!troopKind.Equals(Troop.None)) { troopDict.Add(troopKind, troopQuantity); } } Main.Bot.WriteToOutput("Finished Preparing..."); }
public List <Coords> unitToVectors(Troop troop) { List <Coords> output = new List <Coords>(); bool queenFlag = false; if (troop.Gender == GenderTypes.Checkers) { lineVectorGenerator(-1, -1, troop, output, troop.Location); lineVectorGenerator(+1, -1, troop, output, troop.Location); lineVectorGenerator(-1, +1, troop, output, troop.Location); lineVectorGenerator(+1, +1, troop, output, troop.Location); return(output); } switch (troop.Type) { case UnitTypes.Pawn: if (!troop.color) { if (troop.Location.Row == 6) { output.Add(new Coords(troop.Location.Column, 4)); } output.Add(new Coords(troop.Location.Column, troop.Location.Row - 1)); Coords tempC = new Coords(troop.Location.Column - 1, troop.Location.Row - 1); Troop temp = gameData.GetTroopFromMap(tempC); if (!temp.Equals(null)) { if (temp.color) { output.Add(temp.Location); } } tempC.Column += 2; temp = gameData.GetTroopFromMap(tempC); if (!temp.Equals(null)) { if (temp.color) { output.Add(temp.Location); } } } else { if (troop.Location.Row == 1) { output.Add(new Coords(troop.Location.Column, 3)); } output.Add(new Coords(troop.Location.Column, troop.Location.Row + 1)); Coords tempC = new Coords(troop.Location.Column - 1, troop.Location.Row + 1); Troop temp = gameData.GetTroopFromMap(tempC); if (temp.Equals(null)) { if (!temp.color) { output.Add(temp.Location); } } tempC.Column += 2; temp = gameData.GetTroopFromMap(tempC); if (temp.Equals(null)) { if (!temp.color) { output.Add(temp.Location); } } } outputValidator(output, troop); return(output); case UnitTypes.King: output.Add(new Coords(troop.Location.Column - 1, troop.Location.Row - 1)); output.Add(new Coords(troop.Location.Column, troop.Location.Row - 1)); output.Add(new Coords(troop.Location.Column + 1, troop.Location.Row - 1)); output.Add(new Coords(troop.Location.Column - 1, troop.Location.Row)); output.Add(new Coords(troop.Location.Column + 1, troop.Location.Row)); output.Add(new Coords(troop.Location.Column - 1, troop.Location.Row + 1)); output.Add(new Coords(troop.Location.Column, troop.Location.Row + 1)); output.Add(new Coords(troop.Location.Column + 1, troop.Location.Row + 1)); outputValidator(output, troop); return(output); case UnitTypes.Knight: output.Add(new Coords(troop.Location.Column - 2, troop.Location.Row - 1)); output.Add(new Coords(troop.Location.Column - 2, troop.Location.Row + 1)); output.Add(new Coords(troop.Location.Column + 2, troop.Location.Row - 1)); output.Add(new Coords(troop.Location.Column + 2, troop.Location.Row + 1)); output.Add(new Coords(troop.Location.Column - 1, troop.Location.Row - 2)); output.Add(new Coords(troop.Location.Column - 1, troop.Location.Row + 2)); output.Add(new Coords(troop.Location.Column + 1, troop.Location.Row - 2)); output.Add(new Coords(troop.Location.Column + 1, troop.Location.Row + 2)); outputValidator(output, troop); return(output); case UnitTypes.Queen: queenFlag = true; goto case UnitTypes.Rook; case UnitTypes.Rook: lineVectorGenerator(-1, 0, troop, output, troop.Location); lineVectorGenerator(+1, 0, troop, output, troop.Location); lineVectorGenerator(0, -1, troop, output, troop.Location); lineVectorGenerator(0, +1, troop, output, troop.Location); if (!queenFlag) { return(output); } goto case UnitTypes.Bishop; case UnitTypes.Bishop: lineVectorGenerator(-1, -1, troop, output, troop.Location); lineVectorGenerator(+1, -1, troop, output, troop.Location); lineVectorGenerator(-1, +1, troop, output, troop.Location); lineVectorGenerator(+1, +1, troop, output, troop.Location); return(output); } return(null); //if this happens, con-f*****g-ratz! }