Ejemplo n.º 1
0
        public void Save(SQLite.DataStore store, System.Data.SQLite.SQLiteConnection connection)
        {
            if (this.Saved == true)
            {
                return;
            }

            if (string.IsNullOrEmpty(this.PlayerName))
            {
                return;
            }

            this.PlayerId = -1;
            if (store.PlayerIdCache.ContainsKey(this.PlayerName))
            {
                this.PlayerId = store.PlayerIdCache[this.PlayerName];
            }
            else
            {
                Data.Player player = store.GetPlayer(this.SiteId, this.PlayerName, connection);
                if (player == null)
                {
                    this.PlayerId = store.InsertPlayer(this.SiteId, this.PlayerName, connection);
                }
                else
                {
                    this.PlayerId = player.Id;
                }

                store.PlayerIdCache[this.PlayerName] = this.PlayerId;
            }

            long handId = this.HandId;
            long offButton = -1; // TODO

            this.Id = store.InsertHandPlayer(handId, this.PlayerId, this.Stack,
                this.SeatNumber, offButton, this.HoleCard1, this.HoleCard2,
                this.FinalHand, connection);

            this.Saved = true;
        }