Beispiel #1
0
        private void OnChessmanSelected(ChessmanType type, ChessmanColorType colorType, BoardCoord coord)
        {
            switch (_currentState.TurnState)
            {
            case MatchTurnState.Idle:
            {
                if (colorType == _currentState.Player)
                {
                    SelectChessman(coord);
                }
                break;
            }

            case MatchTurnState.ChessmanSelected:
            {
                if (colorType == _currentState.Player)
                {
                    SelectChessman(coord);
                }
                else
                {
                    if (_currentState.PossibleMoves.Contains(coord))
                    {
                        Move(_currentState.SelectedCoord, coord, SwitchTurn);
                    }
                }
                break;
            }
            }
        }
Beispiel #2
0
        private long getRandomNum()
        {
            ChessmanType type      = ChessmanType.OneStar;
            int          randomInt = randomNum.Next(1, 100);

            string[] strs = getRatioByLevel(1);

            int ratio = 0;

            for (int i = 0; i < strs.Length; i++)
            {
                ratio += Convert.ToInt32(strs[i]);
                if (randomInt < ratio)
                {
                    type = (ChessmanType)i + 1;
                    break;
                }
            }

            if (chessmanKinds.TryGetValue(type, out List <long> chessList))
            {
                return(chessList[randomNum.Next(1, chessList.Count)]);
            }

            return(0);
        }
Beispiel #3
0
        public void Should_Attack(ChessmanType cmType, Size boardSize, Point startCoords, Point[] obstacles,
                                  int result)
        {
            var inst = new DurnevAttackCounter();
            var res  = inst.CountUnderAttack(cmType, boardSize, startCoords, obstacles);

            Assert.Equal(result, res);
        }
 public int CountUnderAttack(ChessmanType cmType, Size boardSize, Point startCoords, Point[] obstacles)
 {
     if (cmType == ChessmanType.Bishop)
     {
         return(3);
     }
     return(2);
 }
        public int CountUnderAttack(ChessmanType cmType, Size boardSize, Point startCoords, Point[] obstacles)
        {
            if (boardSize.Height < 0 || boardSize.Width < 0 || startCoords.X < 1 || startCoords.X > boardSize.Width ||
                startCoords.Y < 1 || startCoords.Y > boardSize.Height)
            {
                throw new ArgumentException();
            }

            if (!_dic.ContainsKey(cmType) || _dic[cmType] == null)
            {
                throw new NotImplementedException();
            }

            return(_dic[cmType].Invoke(boardSize, startCoords, obstacles));
        }
Beispiel #6
0
 public ChessmanDataModel(ChessmanType type, ChessmanColorType colorType)
 {
     Type      = type;
     ColorType = colorType;
 }
Beispiel #7
0
 private int GetChessmanNumByType(ChessmanType chessmanType)
 {
     return(10);
 }