public void AddGame(PGNGameDetails details) { if (!ids.Contains (details.ID)) ids.Add (details.ID); }
public void RemoveGame(PGNGameDetails details) { ids.Remove (details.ID); }
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; }
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; }
public void SaveGame(PGNGameDetails info) { db.Set (info); }
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; }
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; }
public void AddGame(ChessGame game, GameRating rating, out PGNGameDetails updated) { FindOrCreateGame (game, out updated); if (updated.Rating != rating) { updated.Rating = rating; SaveGame (updated); } }
public void AddGame(ChessGame game, out PGNGameDetails updated) { AddGame (game, GameRating.Unknown, out updated); }
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 (); }