コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Attack.cs プロジェクト: trananh1992/Coc-bot-Csharp
        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...");
        }
コード例 #3
0
        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!
        }