public Player(GameSession session, Account account, PlayerDto dto) { Session = session; Account = account; _playtime = dto.PlayTime; _tutorialState = dto.TutorialState; _level = dto.Level; _totalExperience = dto.TotalExperience; _pen = (uint)dto.PEN; _ap = (uint)dto.AP; _coins1 = (uint)dto.Coins1; _coins2 = (uint)dto.Coins2; TotalMatches = (uint)dto.TotalMatches; _totallosses = (uint)dto.TotalLosses; _totalwins = (uint)dto.TotalWins; Settings = new PlayerSettingManager(this, dto); DenyManager = new DenyManager(this, dto); Mailbox = new Mailbox(this, dto); stats = new StatsManager(this, dto); Inventory = new Inventory(this, dto); CharacterManager = new CharacterManager(this, dto); Club = GameServer.Instance.ClubManager.GetClubByAccount(account.Id); RoomInfo = new PlayerRoomInfo(); }
/// <summary> /// Saves all pending changes to the database /// </summary> public void Save() { using (var db = GameDatabase.Open()) { if (NeedsToSave) { db.Update(new PlayerDto { Id = (int)Account.Id, PlayTime = PlayTime, TutorialState = TutorialState, Level = Level, TotalExperience = TotalExperience, PEN = (int)PEN, AP = (int)AP, Coins1 = (int)Coins1, Coins2 = (int)Coins2, CurrentCharacterSlot = CharacterManager.CurrentSlot, TotalMatches = (int)(TotalWins + TotalLosses), TotalLosses = (int)TotalLosses, TotalWins = (int)TotalWins }); NeedsToSave = false; } Settings.Save(db); Inventory.Save(db); CharacterManager.Save(db); DenyManager.Save(db); Mailbox.Save(db); stats.Save(db); } }