Exemple #1
0
 public void TurnIntoQueen(Case c, Pawn p, string color, bool whiteC)
 {
     Queen q = new Queen(PieceTextures[String.Format("{0} Queen", color)], whiteC);
     ListPieces.Remove(p);
     c.Piece = q;
     ListPieces.Add(q);
 }
Exemple #2
0
        public Boolean authorizedMvm(Case current, int togo, List<Case> map, Boolean isLeftMvm, Boolean isRightMvm,
            Boolean takeOnFly, Boolean onlyTake, Boolean isSameLineNumber, Boolean isSameLineLetter)
        {
            if (togo >= 0 && togo < 64)
            {
                if (isLeftMvm)
                {
                    if (lineValue(getCoord(map.IndexOf(current)).Key) > lineValue(getCoord(togo).Key))
                    {
                        if (!takeOnFly && map.ElementAt(togo).Piece != null)
                        {
                            return false;
                        }
                        if (onlyTake && map.ElementAt(togo).Piece == null)
                        {
                            return false;
                        }
                        if(map.ElementAt(togo).Piece != null && map.ElementAt(togo).Piece.IsWhite == current.Piece.IsWhite)
                        {
                            return false;
                        }
                        if (isSameLineNumber && getCoord(map.IndexOf(current)).Value != getCoord(togo).Value)
                        {
                            return false;
                        }
                        return true;
                    }
                    return false;
                }
                if (isRightMvm)
                {
                    if (lineValue(getCoord(map.IndexOf(current)).Key) < lineValue(getCoord(togo).Key))
                    {
                        if (!takeOnFly && map.ElementAt(togo).Piece != null)
                        {
                            return false;
                        }
                        if (onlyTake && map.ElementAt(togo).Piece == null)
                        {
                            return false;
                        }
                        if (map.ElementAt(togo).Piece != null && map.ElementAt(togo).Piece.IsWhite == current.Piece.IsWhite)
                        {
                            return false;
                        }
                        if (isSameLineNumber && getCoord(map.IndexOf(current)).Value != getCoord(togo).Value)
                        {
                            return false;
                        }
                        return true;
                    }
                    return false;
                }
                if(!takeOnFly && map.ElementAt(togo).Piece != null)
                {
                    return false;
                }
                if (onlyTake && map.ElementAt(togo).Piece == null)
                {
                    return false;
                }
                if (map.ElementAt(togo).Piece != null && map.ElementAt(togo).Piece.IsWhite == current.Piece.IsWhite)
                {
                    return false;
                }
                if(isSameLineLetter && getCoord(map.IndexOf(current)).Key != getCoord(togo).Key)
                {
                    return false;
                }
                return true;

            }
            return false;
        }
Exemple #3
0
        public void SameColorEchec(Case currentCase, List<Case> mapCases, bool whiteEchec, bool blackEchec)
        {
            var casesToDelete = new List<Case>();

            foreach (Case ac in AvailableCases)
            {
                Piece tempPiece = this;

                Piece backupA = null;
                if (ac.Piece != null)
                    backupA = ac.Piece;

                ac.Piece = this;
                currentCase.Piece = null;

                foreach (Case c1 in mapCases)
                {
                    if (c1.Piece != null && c1.Piece.IsWhite == !IsWhite)
                    {
                        c1.Piece.DefineAvailableCases(c1, mapCases, whiteEchec, blackEchec, false);

                        foreach (Case c2 in c1.Piece.AvailableCases)
                        {
                            if (c2.Piece != null && c2.Piece.IsWhite == IsWhite && c2.Piece is King)
                            {
                                casesToDelete.Add(ac);
                            }
                        }
                        c1.Piece.UndefineAvailableCases();
                    }
                }

                ac.Piece = backupA;
                currentCase.Piece = this;
            }

            foreach (Case cd in casesToDelete)
            {
                if (AvailableCases.Contains(cd))
                {
                    cd.AvailableCase = false;
                    AvailableCases.Remove(cd);
                }
            }

            foreach(Case cd in AvailableCases)
            {
                cd.AvailableCase = true;
            }
        }
Exemple #4
0
        public void MoveOnlyIfNotEchec(Case currentCase, List<Case> mapCases, bool whiteEchec, bool blackEchec)
        {
            if (currentCase.Piece.IsWhite)
            {
                    SameColorEchec(currentCase, mapCases, true, blackEchec);

                if (blackEchec)
                {
                    DifferentColorEchec();
                }
            }
            else
            {
                    SameColorEchec(currentCase, mapCases, whiteEchec, true);

                if (whiteEchec)
                {
                    DifferentColorEchec();
                }
            }
        }
Exemple #5
0
 public bool isInEchec(Boolean white, Case c, List<Case> mapCases)
 {
     return false;
 }
Exemple #6
0
 public virtual void DefineAvailableCases(Case c, List<Case> map, bool whiteEchec, bool blackEchec,
     bool firstEntry)
 {
 }
Exemple #7
0
        public void GenerateMap()
        {
            int columnNum = 8;

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    Case newCase = new Case(tileTextures[mapArray[y, x]], tileTextures[2], tileTextures[3], 50 + y * 50, 50 + x * 50, 50, 50, alpha.ElementAt(x), columnNum.ToString());
                    newCase.RockTexture = tileTextures[4];
                    CaseList.Add(newCase);
                    columnNum--;
                }
            }
        }