예제 #1
0
 public void AddGame(PGNGameDetails details)
 {
     if (!ids.Contains (details.ID))
         ids.Add (details.ID);
 }
예제 #2
0
 public void RemoveGame(PGNGameDetails details)
 {
     ids.Remove (details.ID);
 }
예제 #3
0
            public void SaveGameDetails(ChessGame game,
						     out ChessGame updated,
						     bool overrite)
            {
                if (!(game is PGNGameDetails))
                    game = new PGNGameDetails (game);
                PGNGameDetails updatedgame;
                AddGame (game, out updatedgame);	// this will check for duplicates
                updated = updatedgame;
            }
예제 #4
0
            public bool GetGameDetails(ChessGame game,
						    out ChessGame details)
            {
                PGNGameDetails gamedetails;
                if (!(game is PGNGameDetails))
                    gamedetails =
                        new PGNGameDetails (game);
                else
                    gamedetails = (PGNGameDetails) game;

                PGNGameDetails dbgame;
                bool ret = FindGame (gamedetails, out dbgame);
                details = dbgame;
                return ret;
            }
예제 #5
0
 public void SaveGame(PGNGameDetails info)
 {
     db.Set (info);
 }
예제 #6
0
            private bool FindGame(PGNGameDetails info,
					       out PGNGameDetails match)
            {
                match = null;
                com.db4o.query.Query query = db.Query ();
                query.Constrain (typeof (PGNGameDetails));
                query.Descend ("hash").
                    Constrain (info.Hash).Equal ();
                ObjectSet res = query.Execute ();
                if (!res.HasNext ())
                    return false;
                ChessGame game1 = info;
                while (res.HasNext ())
                  {
                      PGNGameDetails info2 =
                          (PGNGameDetails) res.
                          Next ();
                      ChessGame game2 = info2;
                      if (game1.Moves.
                          Count != game2.Moves.Count)
                          continue;
                      int i = game1.Moves.Count - 1;
                      bool matched = true;
                      while (i >= 0)
                        {
                            PGNChessMove move1 =
                                (PGNChessMove)
                                game1.Moves[i];
                            PGNChessMove move2 =
                                (PGNChessMove)
                                game2.Moves[i];
                            if (!move1.Move.
                            Equals (move2.Move))
                              {
                                  matched = false;
                                  break;
                              }
                            i--;
                        }

                      if (matched)
                        {
                            match = info2;
                            return true;
                        }
                  }

                // nothing matched (but the games had the same hash!)
                return false;
            }
예제 #7
0
            public bool FindOrCreateGame(ChessGame game,
						      out PGNGameDetails
						      updated)
            {
                PGNGameDetails info;
                if (game is PGNGameDetails)
                    info = (PGNGameDetails) game;
                else
                    info = new PGNGameDetails (game);

                PGNGameDetails existing;
                if (!FindGame (info, out existing))
                  {
                      info.ID = Config.Instance.NextID ();
                      db.Set (info);
                      Config.Instance.Save ();
                      updated = info;
                      return true;	// created
                  }

                updated = existing;
                return false;
            }
예제 #8
0
            public void AddGame(ChessGame game,
					     GameRating rating,
					     out PGNGameDetails updated)
            {
                FindOrCreateGame (game, out updated);
                if (updated.Rating != rating)
                  {
                      updated.Rating = rating;
                      SaveGame (updated);
                  }
            }
예제 #9
0
            public void AddGame(ChessGame game,
					     out PGNGameDetails updated)
            {
                AddGame (game, GameRating.Unknown,
                     out updated);
            }
예제 #10
0
 private void UpdateTagDetails(PGNGameDetails details)
 {
     tagsStore.Clear ();
     if (details == null)
         return;
     if (details.Tags != null)
       {
           foreach (string tag in details.Tags)
           {
               tagsStore.
                   AppendValues (tag);
           }
       }
 }
            private void OnMoveCursor(object o, EventArgs args)
            {
                TreePath path;
                CellRenderer r;
                gamesListWidget.View.GetCursor (out path,
                                out r);

                TreeIter iter;
                gamesListWidget.Model.GetIter (out iter,
                                   path);
                PGNGameDetails info =
                    (PGNGameDetails) gamesListWidget.
                    Model.GetValue (iter, 0);

                selectedGame = info;
                RefreshGameInfo ();
            }