void UpdateReplacePlayer()
        {
            int userID2 = 0;

            userID2 = ValidateReplacePlayer();

            if (userID2 == -1 || userID2 == 0)
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorReplacePlayerSelection, "");
                return;
            }

            DataSet ds = SocketClient.UpdateReplacePlayer(this.Tournament.TournamentID, this.UserID, userID2);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);
                    if (kv.GetInt32("Result") > 0)
                    {
                        MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"));
                        return;
                    }
                }
            }

            TournamentRegisterPlayer TournamentRegisterPlayer = (TournamentRegisterPlayer)this.ParentForm;

            TournamentRegisterPlayer.DialogResult = DialogResult.OK;
        }
Esempio n. 2
0
        private void DownloadUpgrades()
        {
            try
            {
                DataSet ds = UpdateUtility.GetAvailablePatches(Config.Version);
                if (ds != null && ds.Tables.Count > 0)
                {
                    Kv   kv         = new Kv(ds.Tables[0]);
                    long patchSize  = kv.GetInt32("PatchSize");
                    long setupSize  = kv.GetInt32("SetupSize");
                    int  multiplier = 6;
                    if (patchSize >= (setupSize * multiplier))
                    {
                        if (MessageForm.Confirm(null, MsgE.ConfirmPatchSizeDownload, patchSize + " MB", setupSize + " MB") == DialogResult.No)
                        {
                            return;
                        }
                    }
                    string newVersion      = kv.Get("PatchFile1").Replace(".zip", "");
                    string currentPatchUrl = KeyValues.Instance.GetKeyValue(KeyValueE.PatchUrl).Value;
                    this.Invoke(new UpdateClient.BeginUpdateDelegateKv(UpdateClient.BeginUpdate), kv, currentPatchUrl, newVersion);
                }
            }

            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
        private void RestartGameWithSetupAsked(Kv kv)
        {
            Ap.Game.Pause();

            int moveID = kv.GetInt32("MoveID");
            int wMin   = kv.GetInt32("WhiteMin");
            int wSec   = kv.GetInt32("WhiteSec");
            int bMin   = kv.GetInt32("BlackMin");
            int bSec   = kv.GetInt32("BlackSec");

            DialogResult dr = SetupMatch.Show(this.ParentForm, moveID, base.Game.DbGame.TournamentMatchID, kv.GetInt32("SenderUserID"), kv.GetInt32("ReceiverUserID"), wMin, wSec, bMin, bSec, false);

            ResetGameE reset = ResetGameE.Decline;

            if (dr == DialogResult.OK)
            {
                reset = ResetGameE.Accepted;
            }

            SocketClient.RestartGameWithSetup(reset, base.Game.DbGame.GameID, moveID, kv.GetInt32("SenderUserID"), base.Game.DbGame.OpponentUserID, wMin, wSec, bMin, bSec, false);

            if (reset == ResetGameE.Decline)
            {
                Ap.Game.Resume();
            }
        }
        private void UserNewGame(Kv kv)
        {
            int      gameID  = kv.GetInt32("GameID");
            NewGameE newGame = (NewGameE)kv.GetInt32("NewGame");

            switch (newGame)
            {
            case NewGameE.Asked:
                if (MessageForm.Confirm(this, MsgE.ConfirmPlay) == DialogResult.Yes)
                {
                    AcceptNewGameOffer();
                }
                else
                {
                    RejectNewGameOffer();
                }
                break;

            case NewGameE.Accepted:
                NewGame(kv);
                break;

            case NewGameE.Decline:
                ChatClient.Write(ChatTypeE.GameWindow, ChatMessageTypeE.Info, ChatTypeE.GameWindow, MsgE.InfoNewGameOffer, gameID);
                break;

            default:
                break;
            }
        }
        private void UpdateMatchStatus(TournamentMatchStatusE tournamentMatchStatusID, string matchStatus)
        {
            if (this.Tournament == null)
            {
                return;
            }
            if (this.Tournament.TournamentID == 0)
            {
                return;
            }

            string matchIDs = string.Empty;

            foreach (DataGridViewRow row in dgvMatches.Rows)
            {
                if (row.Cells["Select"].Value != null)
                {
                    if ((bool)row.Cells["Select"].Value)
                    {
                        if (GridTable.Rows[row.Index]["WhiteUserID"].ToString() != "2" && GridTable.Rows[row.Index]["BlackUserID"].ToString() != "2")
                        {
                            matchIDs += "," + GridTable.Rows[row.Index]["TournamentMatchID"].ToString();
                        }
                    }
                }
            }

            if (matchIDs.Length > 0)
            {
                matchIDs = matchIDs.Remove(0, 1);

                if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemTask, "update match status to ", matchStatus) != DialogResult.Yes)
                {
                    return;
                }

                ProgressForm frmProgress = ProgressForm.Show(this, "Updating match status...");
                DataSet      ds          = SocketClient.UpdateTournamentMatchStatus(tournamentMatchStatusID, this.Tournament.TournamentID, matchIDs);
                frmProgress.Close();

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        Kv kv = new Kv(ds.Tables[0]);
                        if (kv.GetInt32("Result") > 0)
                        {
                            MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"));
                            return;
                        }
                    }
                }
                RefreshGrid();
            }
            else
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentMatchStartRequest);
            }
        }
Esempio n. 6
0
        private bool StartTournament()
        {
            bool isTrue = false;

            if (this.Tournament == null)
            {
                return(false);
            }

            if (this.Tournament.TournamentID == 0)
            {
                return(false);
            }

            if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemTask, "start", "tournament " + "'" + this.Tournament.Name + "'") == DialogResult.Yes)
            {
                ProgressForm frmProgress = ProgressForm.Show(this, "Creating matches...");

                this.Tournament.TournamentStatusIDE = TournamentStatusE.InProgress;
                DataSet ds = SocketClient.TournamentStart(this.Tournament.TournamentID, this.Tournament.TournamentStatusIDE);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        Kv kv = new Kv(ds.Tables[0]);
                        if (kv.GetInt32("Result") > 0)
                        {
                            frmProgress.Close();
                            if ((int)MsgE.ErrorTournamentUserExist == kv.GetInt32("Result") && this.Tournament.TournamentTypeIDE == TournamentTypeE.Knockout)
                            {
                                MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"), this.Tournament.Name, 4);
                            }
                            else
                            {
                                MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"), this.Tournament.Name, 2);
                            }

                            this.Tournament.TournamentStatusIDE = TournamentStatusE.Scheduled;
                            return(false);
                        }
                    }

                    tsbRescheduleTask.Visible = true;
                    frmProgress.Close();

                    MessageForm.Show(this.ParentForm, MsgE.ConfirmTournamentStarted, this.Tournament.Name);
                    isTrue = true;
                }
                else
                {
                    MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentUserExist, this.Tournament.Name);

                    return(false);
                }
            }
            return(isTrue);
        }
Esempio n. 7
0
 private void WriteChatMessage(Kv kv)
 {
     if ((ChatTypeE)kv.GetInt32("ChatType") == ChatTypeE.AllWindows)
     {
         ChatClient.Write(ChatTypeE.GameWindow, (ChatMessageTypeE)kv.GetInt32("MessageType"), ChatTypeE.GameWindow, kv.Get("Message"), 0);
         ChatClient.Write(ChatTypeE.OnlineClient, (ChatMessageTypeE)kv.GetInt32("MessageType"), ChatTypeE.OnlineClient, kv.Get("Message"), 0);
     }
     else
     {
         ChatClient.Write(ChatTypeE.OnlineClient, (ChatMessageTypeE)kv.GetInt32("MessageType"), (ChatTypeE)kv.GetInt32("ChatType"), kv.Get("Message"), 0);
     }
 }
        private void RestartGameWithSetupResetAsked(Kv kv)
        {
            int moveID = kv.GetInt32("MoveID");
            int wMin   = kv.GetInt32("WhiteMin");
            int wSec   = kv.GetInt32("WhiteSec");
            int bMin   = kv.GetInt32("BlackMin");
            int bSec   = kv.GetInt32("BlackSec");

            Ap.Game.Pause();
            Ap.MsgQueue.Clear(this.Game.DbGame.GameID);

            //send back with Done
            SocketClient.RestartGameWithSetup(ResetGameE.ResetDone, base.Game.DbGame.GameID, moveID, kv.GetInt32("SenderUserID"), base.Game.DbGame.OpponentUserID, wMin, wSec, bMin, bSec, false);
        }
        private void TimeIsExpired(Kv kv)
        {
            GameResultE result = (GameResultE)kv.GetInt32("GameResult");

            base.Game.TimeExpired(result, false);
            ClockUc.TimeExpired(result);
        }
Esempio n. 10
0
        private void BlockMachine(Kv kv)
        {
            String machineKey;

            BlockMachineE blockMachineE = (BlockMachineE)kv.GetInt32("BlockMachineE");

            switch (blockMachineE)
            {
            case BlockMachineE.Initialized:
                machineKey = WmiHelper.GetMachineKey();
                if (!String.IsNullOrEmpty(machineKey))
                {
                    MessageForm.Show(this, MsgE.InfoBlockMachine);
                    kv.Set("MachineKey", machineKey);
                    kv.Set("BlockMachine", (int)BlockMachineE.Done);
                }
                SocketClient.SendAvResponse(kv);
                break;

            case BlockMachineE.Done:
                machineKey = kv.Get("MachineKey");
                if (!String.IsNullOrEmpty(machineKey))
                {
                    MessageForm.Show(this, MsgE.ErrorBlockMachine);
                }
                break;
            }
        }
Esempio n. 11
0
        private void FillWinners(DataTable dtResults)
        {
            if (Tournament.TournamentTypeE != TournamentTypeE.Knockout)
            {
                return;
            }
            if (Tournament.MaxWinners == 0)
            {
                return;
            }

            int     lastRound = Convert.ToInt32(dtResults.Compute("Max(Round)", ""));
            DataSet ds        = SocketClient.IsKnockOutTournamentCompleted(Tournament.TournamentID, lastRound + 1);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);
                    if (kv.GetInt32("Result") > 0)
                    {
                        // tournament not yet completed, so no winners could decided here...
                        return;
                    }
                }
            }

            dgvWinners.Visible    = true;
            dgvWinners.DataSource = LoadWinners(dtResults, lastRound);
            if (dgvWinners.Columns.Contains("WinnerId"))
            {
                dgvWinners.Columns["WinnerId"].Visible = false;
            }
        }
        private void FillWinners(DataTable dtResults)
        {
            if (Tournament.MaxWinners == 0)
            {
                LoadWinners(null);
                return;
            }

            int     lastRound = Convert.ToInt32(dtResults.Compute("Max(Round)", ""));
            DataSet ds        = SocketClient.IsKnockOutTournamentCompleted(Tournament.TournamentID, lastRound + 1);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);
                    if (kv.GetInt32("Result") > 0)
                    {
                        // tournament not yet completed, so no winners could decided here...
                        LoadWinners(null);
                        return;
                    }
                }
            }

            DataTable dtWinners = LoadWinners(dtResults, lastRound);

            LoadWinners(dtWinners);
        }
Esempio n. 13
0
 private void RestartGameResetAsked(Kv kv)
 {
     Ap.Game.Pause();
     Ap.MsgQueue.Clear(this.Game.DbGame.GameID);
     Ap.Game.Flags.IsReady = false;
     //send back with Done
     SocketClient.RestartGame(kv.GetInt32("TournamentID"), kv.Get("GameID"), 0, kv.GetInt32("SenderUserID"), kv.GetInt32("ReceiverUserID"), ResetGameE.ResetDone, kv.GetBool("IsResetFromLastMove"), kv.Get("GameXml"));
 }
Esempio n. 14
0
        void DoConsumeMessage(Kv kv)
        {
            MethodNameE MethodName = (MethodNameE)kv.GetInt32("MethodName");

            #region Switch MethodName
            switch (MethodName)
            {
            case MethodNameE.BannedUser:
                BanUser(kv);
                break;

            case MethodNameE.KickedUser:
                KickUser();
                break;

            case MethodNameE.BlockIP:
                BlockIP();
                break;

            case MethodNameE.WriteChatMessage:
                WriteChatMessage(kv);
                break;

            case MethodNameE.SystemInformation:
                SystemInformation(kv);
                break;

            case MethodNameE.UpdateGameDataByGameID:
            case MethodNameE.Abort:
                Abort(kv);
                break;

            case MethodNameE.AvChat:
                AvChat(kv);
                break;

            case MethodNameE.ForceLogoff:
                CloseAllWindows();
                break;

            case MethodNameE.BlockMachine:
                BlockMachine(kv);
                break;

            case MethodNameE.StartTournamentMatch:
                StartTournamentMatch(kv);
                break;

            case MethodNameE.PingClient:
                PingClient();
                break;

            case MethodNameE.GetDataByRoomID:
                GetDataByRoomID(kv);
                break;
            }
            #endregion
        }
Esempio n. 15
0
        private void UserDraw(Kv kv)
        {
            int   gameID = kv.GetInt32("GameID");
            DrawE draw   = (DrawE)kv.GetInt32("Draw");

            switch (draw)
            {
            case DrawE.Asked:
                if (PlayingModeData.Instance.AutometicAccepts || PlayingModeData.Instance.AutometicChallenges)
                {
                    RejectDrawOffer();
                    return;
                }
                EnableBarButtons(false);
                if (MessageForm.Confirm(this, MsgE.DrawAsked) == DialogResult.Yes)
                {
                    base.Game.Draw();
                    AcceptDrawOffer();
                    EnableBarButtons(false);
                }
                else
                {
                    RejectDrawOffer();
                    EnableBarButtons(true);
                }
                break;

            case DrawE.Accepted:
                base.Game.Draw();
                break;

            case DrawE.Decline:
                ChatClient.Write(ChatTypeE.GameWindow, ChatMessageTypeE.Info, ChatTypeE.GameWindow, MsgE.DrawDecline, gameID);
                EnableBarButtons(true);
                break;

            default:
                break;
            }
        }
Esempio n. 16
0
        private void AvChat(Kv kv)
        {
            AvChatE avChat = (AvChatE)kv.GetInt32("AvChat");

            switch (avChat)
            {
            case AvChatE.Asked:
                if (!AvPlayer.IsIdle())
                {
                    kv.Set("AvChat", (int)AvChatE.Busy);
                    SocketClient.SendAvResponse(kv);
                    return;
                }
                this.Invoke(new AvPlayer.StartChatDelegate(AvPlayer.StartChat), kv.DataTable);
                break;

            case AvChatE.Accepted:
                this.Invoke(new AvPlayer.PlayChatDelegate(AvPlayer.PlayChat));
                break;

            case AvChatE.Declined:
                this.Invoke(new AvPlayer.StopChatDelegate(AvPlayer.StopChat));
                ChatClient.Write((ChatTypeE)kv.GetInt32("ClientWindow"), ChatMessageTypeE.Error, (ChatTypeE)kv.GetInt32("ClientWindow"), Msg.GetMsg(MsgE.ErrorAvChatDenied, kv.Get("ToUserName")), 0);
                break;

            case AvChatE.Busy:
                this.Invoke(new AvPlayer.StopChatDelegate(AvPlayer.StopChat));
                ChatClient.Write((ChatTypeE)kv.GetInt32("ClientWindow"), ChatMessageTypeE.Error, (ChatTypeE)kv.GetInt32("ClientWindow"), Msg.GetMsg(MsgE.ErrorAvChatBusy, kv.Get("ToUserName")), 0);
                break;

            case AvChatE.NoService:
                this.Invoke(new AvPlayer.StopChatDelegate(AvPlayer.StopChat));
                ChatClient.Write((ChatTypeE)kv.GetInt32("ClientWindow"), ChatMessageTypeE.Error, (ChatTypeE)kv.GetInt32("ClientWindow"), MsgE.InfoNoAvService, 0);
                break;

            default:
                break;
            }
        }
Esempio n. 17
0
        public static int LoginMsg(Kv kv, bool isGuest)
        {
            DataTable dt    = null;
            int       msgID = 0;

            if (isGuest)
            {
                msgID = kv.GetInt32("Msg");
            }
            else
            {
                Kv kv1 = new Kv(kv.GetDataTable("Msg"));
                dt    = kv1.DataTable;
                msgID = Convert.ToInt32(dt.Rows[0][0]);
            }

            if (msgID < 0)
            {
                msgID = msgID * -1;
                MsgE msge = (MsgE)msgID;

                switch (msge)
                {
                case MsgE.Active:
                    return((int)MsgE.Active);

                case MsgE.Disabled:
                case MsgE.Inactive:
                case MsgE.Deleted:
                case MsgE.BlockIp:
                    return((int)MsgE.BlockIp);

                case MsgE.InfoBlockMachine:
                case MsgE.WrongIdPassowrd:
                    return((int)MsgE.WrongIdPassowrd);

                case MsgE.NoRoles:
                    return((int)MsgE.NoRoles);

                case MsgE.Ban:
                    //MessageForm.Error(this, MsgE.ErrorBannedForever, Ap.CurrentUser.UserName);
                    return((int)MsgE.Ban);
                }
            }
            else if (msgID == 0)
            {
                //MessageForm.Error(this, MsgE.InfoBaned, kv.GetDateTime("BanEndDateTime"), kv.GetDateTime("BanEndDateTime1"));
                return(0);
            }
            return(msgID);
        }
        private void tsbStartRound_Click(object sender, EventArgs e)
        {
            if (this.Tournament == null)
            {
                return;
            }
            if (this.Tournament.TournamentID == 0)
            {
                return;
            }

            if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemTask, "start", "round") == DialogResult.Yes)
            {
                if (IsRoundStarted())
                {
                    DataSet ds = SocketClient.StartTournamentRound(this.Tournament.TournamentID);
                    if (ds != null)
                    {
                        if (ds.Tables.Count > 1)
                        {
                            Kv kv = new Kv(ds.Tables[1]);
                            if (kv.GetInt32("Result") > 0)
                            {
                                MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"));
                                RefreshGrid();
                                return;
                            }
                            else
                            {
                                RefreshGrid();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 19
0
        public static DataSet GetGameDataByChallengeID(DataTable dt)
        {
            Kv      kv = new Kv(dt);
            DataSet ds = new DataSet();

            ds = BaseCollection.ExecuteDataset("GetGameByChallengeID", kv.GetInt32("ChallengeID"), kv.GetInt32(StdKv.CurrentUserID));
            ds.Tables[0].TableName = "Challenge";
            ds.Tables[1].TableName = "Game";
            ds.Tables[2].TableName = "Users";
            ds.Tables[3].TableName = "Engines";
            ds.Tables[4].TableName = "TournamentMatch";
            ds.Tables[5].TableName = "Tournament";

            return(ds);
        }
Esempio n. 20
0
        private void ResetGameAsked(Kv kv)
        {
            Ap.Game.Pause();
            ResetGameE reset = ResetGameE.Decline;

            if (MessageForm.Confirm(this, MsgE.ConfirmRestartTournamentMatch) == DialogResult.Yes)
            {
                reset = ResetGameE.Accepted;
            }
            else
            {
                Ap.Game.Resume();
            }

            SocketClient.RestartGame(kv.GetInt32("TournamentID"), kv.Get("MatchIDs"), kv.GetInt32("TournamentDirectorID"), kv.GetInt32("SenderUserID"), kv.GetInt32("ReceiverUserID"), reset, kv.GetBool("IsResetFromLastMove"), kv.Get("GameXml"));
        }
Esempio n. 21
0
        private void ResetGameAccepted(Kv kv)
        {
            NewGame();

            Ap.Game.Flags.IsReady = true;

            if (kv.GetBool("IsResetFromLastMove") && !string.IsNullOrEmpty(kv.Get("GameXml")))
            {
                SetGamePrameters(kv.Get("GameXml"), true);
            }

            if (kv.GetInt32("TournamentDirectorID") > 0)
            {
                ChatClient.Write(ChatTypeE.GameWindow, ChatMessageTypeE.Info, ChatTypeE.GameWindow, MsgE.InfoRestartTournamentMatch, base.Game.DbGame.GameID);
            }
            else
            {
                ChatClient.Write(ChatTypeE.GameWindow, ChatMessageTypeE.Info, ChatTypeE.GameWindow, MsgE.InfoTournamentMatchStarted, base.Game.DbGame.GameID);
            }
        }
Esempio n. 22
0
        private void RestartGameWithSetup(Kv kv)
        {
            ResetGameE reset = (ResetGameE)kv.GetInt32("ResetGame");

            switch (reset)
            {
            case ResetGameE.Asked:
                RestartGameWithSetupAsked(kv);
                break;

            case ResetGameE.Accepted:
                RestartGameWithSetupAccepted(kv);
                break;

            case ResetGameE.Decline:
                RestartGameWithSetupDecline(kv);
                break;

            case ResetGameE.ResetAsked:
                RestartGameWithSetupResetAsked(kv);
                break;
            }
        }
Esempio n. 23
0
        private void RestartGame(Kv kv)
        {
            ResetGameE resetGame = (ResetGameE)kv.GetInt32("ResetGame");

            switch (resetGame)
            {
            case ResetGameE.Asked:
                ResetGameAsked(kv);
                break;

            case ResetGameE.Accepted:
                ResetGameAccepted(kv);
                break;

            case ResetGameE.Decline:
                ResetGameDecline();
                break;

            case ResetGameE.ResetAsked:
                RestartGameResetAsked(kv);
                break;
            }
        }
Esempio n. 24
0
        private void WriteChatMessage(Kv kv)
        {
            int gameID = kv.GetInt32("GameID");

            ChatClient.Write(ChatTypeE.GameWindow, (ChatMessageTypeE)kv.GetInt32("MessageType"), (ChatTypeE)kv.GetInt32("ChatType"), kv.Get("Message"), gameID);
        }
Esempio n. 25
0
        void DoConsumeMessage(Kv kv)
        {
            MethodNameE MethodName = (MethodNameE)kv.GetInt32("MethodName");

            switch (MethodName)
            {
            case MethodNameE.UpdateGameDataByGameID:
                SetGamePrameters(kv);
                break;

            case MethodNameE.Resign:
                UserResign(kv);
                break;

            case MethodNameE.Abort:
                UserAbort();
                break;

            case MethodNameE.Draw:
                UserDraw(kv);
                break;

            case MethodNameE.NewGame:
                UserNewGame(kv);
                break;

            case MethodNameE.TimeExpired:
                TimeIsExpired(kv);
                break;

            case MethodNameE.KingStaleMated:
                UserKingStaleMated();
                break;

            case MethodNameE.ThreefoldRepetition:
                UserThreefoldRepetition(kv);
                break;

            case MethodNameE.AddAudienceAsync:
                this.AddAudience(kv);
                break;

            case MethodNameE.RemoveAudience:
                this.RemoveAudience(kv);
                break;

            case MethodNameE.BanUser:
                BanUser(kv);
                break;

            case MethodNameE.KickUser:
                KickUser();
                break;

            case MethodNameE.BlockIP:
                BlockIP();
                break;

            case MethodNameE.WriteChatMessage:
                WriteChatMessage(kv);
                break;

            case MethodNameE.ForceLogoff:
                CloseAllWindows();
                break;

            case MethodNameE.SetGamePositionByFen:
                SetGamePositionByFen(kv);
                break;

            case MethodNameE.CloseInProgressGameWindow:
                CloseInProgressGameWindow(kv);
                break;

            case MethodNameE.RestartGame:
                RestartGame(kv);
                break;

            case MethodNameE.RestartGameWithSetup:
                RestartGameWithSetup(kv);
                break;

            case MethodNameE.RescheduleTournament:
                SetRescheduleTournament();
                break;

            case MethodNameE.ForcedGameWin:
                ForcedGameWin(kv);
                break;
            }
        }
Esempio n. 26
0
        private void UserResign(Kv kv)
        {
            GameResultE result = (GameResultE)kv.GetInt32("GameResult");

            base.Game.Resign(result);
        }
        private void CreateTournamentRounds()
        {
            if (this.Tournament == null)
            {
                return;
            }

            if (this.Tournament.TournamentID == 0)
            {
                return;
            }

            string msgID  = string.Empty;
            bool   isTrue = false;
            int    round  = 0;

            if (table != null)
            {
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow item in table.Rows)
                    {
                        TournamentMatchStatusE ts = (TournamentMatchStatusE)Convert.ToInt32(item["TournamentMatchStatusID"]);


                        if (ts != TournamentMatchStatusE.Finsihed && ts != TournamentMatchStatusE.Absent &&
                            Tournament.TournamentTypeIDE != TournamentTypeE.Knockout && Tournament.TournamentTypeIDE != TournamentTypeE.Swiss)
                        {
                            isTrue = true;
                        }

                        round = GetRoundNo(item["Round"].ToString());
                    }

                    if (isTrue)
                    {
                        MessageForm.Show(ParentForm, MsgE.ErrorTournamentNextRoundStarted);
                    }
                    else
                    {
                        DataSet ds = SocketClient.CreateTournamentRounds(Tournament.TournamentID, round + 1);

                        if (ds != null)
                        {
                            if (ds.Tables.Count > 0)
                            {
                                Kv kv = new Kv(ds.Tables[0]);
                                if (kv.GetInt32("Result") > 0)
                                {
                                    MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"));
                                    return;
                                }
                            }
                        }

                        if (this.Tournament.TournamentTypeE != TournamentTypeE.Swiss)
                        {
                            //Tournament.TournamentCurrentRound = round + 1;
                        }
                    }
                }
            }
            RefreshGrid();
        }
Esempio n. 28
0
        private void RemoveAudience(Kv kv)
        {
            int userID = kv.GetInt32("UserID");

            AudienceUc.RemoveAudience(userID);
        }
Esempio n. 29
0
        public static void StartChat(DataTable dt)
        {
            Kv          kv = new Kv(dt);
            string      chatType;
            int         fromUserId   = kv.GetInt32("FromUserID");
            int         toUserId     = kv.GetInt32("ToUserID");
            string      fromUserName = kv.Get("FromUserName");
            AvChatTypeE chatTypeE    = (AvChatTypeE)kv.GetInt32("AvChatType");

            if (chatTypeE == AvChatTypeE.Audio)
            {
                chatType = "audio";
            }
            else
            {
                chatType = "video";
            }

            if (MessageForm.Confirm(ActiveForm, MsgE.InfoAvChatRequested, chatType, fromUserName) == DialogResult.No)
            {
                kv.Set("AvChat", (int)AvChatE.Declined);
                SocketClient.SendAvResponse(kv);
                return;
            }

            state         = AvChatStateE.Talking;
            initiatedChat = false;
            ChatType      = chatTypeE;
            FromUserId    = fromUserId;
            FromUserName  = fromUserName;
            ToUserId      = toUserId;

            if (avPlayer != null)
            {
                avPlayer.Dispose();
                avPlayer = null;
            }

            StringBuilder connectionString = new StringBuilder("rtmp://");

            connectionString.Append(Config.AvServerIp);
            connectionString.Append(":");
            connectionString.Append(Config.AvServerPort);
            connectionString.Append("/videochat");

            try
            {
                avPlayer = new AvPlayer();
                if (ChatType == AvChatTypeE.Video)
                {
                    ShowPlayer();
                }

                string chatTypeString = ((int)ChatType + 1).ToString();
                avPlayer.player.CallFunction("<invoke name=\"StartChat\" returntype=\"xml\"><arguments><string>" + connectionString.ToString() + "</string><string>" + FromUserId + "</string><string>" + ToUserId + "</string><number>" + chatTypeString + "</number></arguments></invoke>");

                if (OnAvChatBegan != null)
                {
                    OnAvChatBegan.Invoke(typeof(AvPlayer), new AvChatEventArgs(ChatType));
                }
            }

            catch (AccessViolationException ex)
            {
                TestDebugger.Instance.WriteError(ex);
                StopChat();
                MessageForm.Show(null, MsgE.ErrorAvNoCamera, MessageBoxButtons.OK, MessageBoxIcon.Error, ex);
            }
            catch (COMException e)
            {
                TestDebugger.Instance.WriteError(e);
                if (e.Message.Substring(0, 20) == "Class not registered")
                {
                    MessageForm.Show(null, MsgE.ErrorAvNoPlayer, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 30
0
        private void ForcedGameWin(Kv kv)
        {
            GameResultE result = (GameResultE)kv.GetInt32("GameResultID");

            base.Game.GameForcefullyFinished(result);
        }