Beispiel #1
0
        public string GetNextMatch()
        {
            DataSet.TournamentMatchs.DefaultView.RowFilter = "IsFinished='" + false + "'";

            if (DataSet.TournamentMatchs.DefaultView.Count > 0)
            {
                CurrentMatchID = (int)DataSet.TournamentMatchs.DefaultView[0]["TournamentMatchID"];
                string P1 = DataSet.TournamentMatchs.DefaultView[0]["Participant1"].ToString();
                string P2 = DataSet.TournamentMatchs.DefaultView[0]["Participant2"].ToString();

                DataSet.TournamentParticipants.DefaultView.RowFilter = "Name in ('" + P1 + "','" + P2 + "')";

                if (DataSet.TournamentParticipants.DefaultView[0]["IsEngine"].ToString() == "False")
                {
                    Participant1 = (InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow)DataSet.TournamentParticipants.DefaultView[0].Row;
                    Participant2 = (InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow)DataSet.TournamentParticipants.DefaultView[1].Row;
                }
                else
                {
                    Participant1 = (InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow)DataSet.TournamentParticipants.DefaultView[1].Row;
                    Participant2 = (InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow)DataSet.TournamentParticipants.DefaultView[0].Row;
                }
                // string strP1AndP2 = P1 + "," + P2 + "," + GameMode.ToString();

                DataSet.TournamentParticipants.DefaultView.RowFilter = "";

                return("");
            }
            else
            {
                return("Finished");
            }
        }
Beispiel #2
0
        //*************************************************

        public string GetNextHumanMatch()
        {
            Participant1 = null;
            Participant2 = null;
            DataSet.TournamentMatchs.DefaultView.RowFilter = "IsFinished='" + false + "'";

            foreach (DataRowView Row in DataSet.TournamentMatchs.DefaultView)
            {
                DataSet.TournamentParticipants.DefaultView.RowFilter = "Name in ('" + Row["Participant1"].ToString() + "','" + Row["Participant2"].ToString() + "')";

                if (DataSet.TournamentParticipants.DefaultView[0]["IsEngine"].ToString() == "False")
                {
                    CurrentMatchID = (int)Row["TournamentMatchID"];
                    Participant1   = (InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow)DataSet.TournamentParticipants.DefaultView[0].Row;
                    Participant2   = (InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow)DataSet.TournamentParticipants.DefaultView[1].Row;
                }
                else if (DataSet.TournamentParticipants.DefaultView[1]["IsEngine"].ToString() == "False")
                {
                    CurrentMatchID = (int)Row["TournamentMatchID"];
                    Participant1   = (InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow)DataSet.TournamentParticipants.DefaultView[1].Row;
                    Participant2   = (InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow)DataSet.TournamentParticipants.DefaultView[0].Row;
                }
            }

            if (Participant1 == null || Participant2 == null)
            {
                DataSet.TournamentParticipants.DefaultView.RowFilter = "";
                DataSet.TournamentMatchs.DefaultView.RowFilter       = "";
                return("Finished");
            }

            DataSet.TournamentParticipants.DefaultView.RowFilter = "";
            DataSet.TournamentMatchs.DefaultView.RowFilter       = "";
            return("");
        }
Beispiel #3
0
        private bool HasPlayed(InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow Participant1, InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow Participant2)
        {
            DataSet.TournamentMatchs.DefaultView.RowFilter = "Player1='" + Participant1.Name + "' AND Player2='" + Participant2.Name + "'";

            bool played = DataSet.TournamentMatchs.DefaultView.Count != 0;

            DataSet.TournamentMatchs.DefaultView.RowFilter = "";

            return(played);
        }
Beispiel #4
0
 private App.Model.PlayerType GetPlayerType(InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow p1)
 {
     if (p1.IsEngine)
     {
         return(App.Model.PlayerType.Engine);
     }
     else
     {
         return(App.Model.PlayerType.Human);
     }
 }
Beispiel #5
0
        public void AddParticipitant(string name, bool isEngine)
        {
            DataSet.TournamentParticipants.DefaultView.RowFilter = "Name='" + name + "' AND IsEngine=" + isEngine;

            if (DataSet.TournamentParticipants.DefaultView.Count == 0)
            {
                InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow row = DataSet.TournamentParticipants.NewTournamentParticipantsRow();

                row.Name     = name.Replace(".exe", "");
                row.IsEngine = isEngine;
                DataSet.TournamentParticipants.Rows.Add(row);
                DataSet.AcceptChanges();
                IsDataChange = true;
            }

            DataSet.TournamentParticipants.DefaultView.RowFilter = "";
        }
Beispiel #6
0
        private GameMode GetGameMode(InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow p1, InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow p2)
        {
            if (p1.IsEngine && p2.IsEngine)
            {
                return(GameMode.EngineVsEngine);
            }

            else if (!p1.IsEngine && p2.IsEngine)
            {
                return(GameMode.HumanVsEngine);
            }

            else if (p1.IsEngine && !p2.IsEngine)
            {
                return(GameMode.HumanVsEngine);
            }

            else
            {
                return(GameMode.None);
            }
        }
Beispiel #7
0
        public void PlayNextMatch()
        {
            for (int i = 0; i < DataSet.TournamentParticipants.Rows.Count; i++)
            {
                if (i + 1 >= DataSet.TournamentParticipants.Rows.Count)
                {
                    break;
                }

                for (int j = i + 1; j < DataSet.TournamentParticipants.Rows.Count; j++)
                {
                    InfinityChess.Data.Kv.Tournament.TournamentParticipantsRow px = null;

                    px = DataSet.TournamentParticipants[i];
                    if (!px.IsEngine)
                    {
                        Participant1 = px;
                        Participant2 = DataSet.TournamentParticipants[j];
                    }

                    px = DataSet.TournamentParticipants[j];
                    if (!px.IsEngine)
                    {
                        Participant1 = px;
                        Participant2 = DataSet.TournamentParticipants[i];
                    }
                    else
                    {
                        Participant1 = DataSet.TournamentParticipants[i];
                        Participant2 = DataSet.TournamentParticipants[j];
                    }

                    if (!HasPlayed(Participant1, Participant2))
                    {
                        this.Game.Stop();
                    }
                }
            }
        }