Ejemplo n.º 1
0
        private void AutometicAcceptChallenges(DataTable dt)
        {
            if (Ap.IsGameInProgress)
            {
                return;
            }

            if ((Ap.SelectedRoomID == (int)RoomE.ComputerChess || Ap.SelectedRoomID == (int)RoomE.EngineHall || Ap.SelectedRoomID == (int)RoomE.FreestyleChess || Ap.SelectedRoomID == (int)RoomE.TestRoom) && Ap.PlayingMode.ChessTypeID == (int)ChessTypeE.Engine && Ap.CurrentUser.UserStatusIDE == UserStatusE.Engine)
            {
                if (PlayingModeData.Instance.AutometicAccepts && dt != null && dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Select("ChessTypeID=2 AND ChallengeStatusID=1")[0];

                    foreach (DataGridViewRow item in dataGridView1.Rows)
                    {
                        if (item.Cells[0].Value == dr[0])
                        {
                            item.Selected = true;
                            toolStripButtonAccept.PerformClick();
                            return;
                        }
                    }
                }
                if (PlayingModeData.Instance.AutometicChallenges && Ap.CanAutoChallenge)
                {
                    Ap.CanAutoChallenge = false;
                    GameType gameTypeIDE = GameTime.GetGameType(PlayingModeData.Instance.Time, 0);
                    DataSet  ds          = SocketClient.AddChallengeData(Ap.CurrentUserID, 0, ChallengeTypeE.Seek, gameTypeIDE, ColorE.Autometic, Ap.SelectedRoomID, PlayingModeData.Instance.Time, PlayingModeData.Instance.GainPerMove, 2, true, true, false, string.Empty, 0, 0);
                    ChallengesUc.Instance.LoadChallenges(ds.Tables[0]);
                }
            }
        }
Ejemplo n.º 2
0
        private void SaveChallenge()
        {
            int      chessTypeID, roomID, timeMin, gainPerMove;
            bool     isRated, withClock, challengerSendsGame;
            string   description = "";
            ColorE   colorIDE;
            GameType gameTypeIDE;

            decimal stake = 0, flate = 0;

            if (userFiniUc1.IsFiniApplicable(opponentUserID))
            {
                return;
            }

            stake = userFiniUc1.Stake;
            flate = userFiniUc1.Flate;

            chessTypeID = PlayingModeData.Instance.ChessTypeID;
            if (rbAutometic.Checked)
            {
                colorIDE = ColorE.Autometic;
            }
            else if (rbWhite.Checked)
            {
                colorIDE = ColorE.White;
            }
            else
            {
                colorIDE = ColorE.Black;
            }
            if (Ap.SelectedRoomID != 0)
            {
                roomID = Ap.SelectedRoomID;
            }
            else
            {
                roomID = Ap.CurrentUser.RoomID;
            }

            isRated   = chkRated.Checked;
            withClock = chkWithClock.Checked;

            if (withClock)
            {
                if (chessTypeID == 3)
                {
                    gameTypeIDE = GameType.Long;
                }
                else
                {
                    gameTypeIDE = GameTime.GetGameType((int)numericUpDownTime.Value, 0);
                }
                timeMin     = Convert.ToInt32(numericUpDownTime.Value);
                gainPerMove = Convert.ToInt32(numericUpDownGainMove.Value);
            }
            else
            {
                gameTypeIDE = GameType.NoClock;
                timeMin     = 0;
                gainPerMove = 0;
            }

            challengerSendsGame = chkChallengesSendsGame.Checked;
            description         = "";

            try
            {
                DataSet ds = SocketClient.AddChallengeData(Ap.CurrentUserID, opponentUserID, ChallengeTypeE.Challenge, gameTypeIDE, colorIDE, roomID, timeMin, gainPerMove, chessTypeID, isRated, withClock, challengerSendsGame, description, Convert.ToInt32(stake), Convert.ToInt32(flate));
                ChallengesUc.Instance.LoadChallenges(ds.Tables[0]);
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
            }
        }