public PlayerPuzzleData(IGameDataArchive archive, InMemoryDatabase.PlayerProfile profile, int uid) { this.archive = archive; this.profile = profile; this.uid = uid; this.entry = profile[uid]; }
public void UpdatePlayerProfile(InMemoryDatabase.PlayerProfile playerProfile) { var path = GetPlayerProfilePath(playerProfile.Name); using (var writer = OpenZipArchiveEntryForWriting(path)) { var pairs = (from uid in playerProfile.EntryUIDs let entry = playerProfile[uid] where entry.BestTime.HasValue select new { ID = uid, BestTime = entry.BestTime.Value }).ToList(); writer.WriteLine(pairs.Count); foreach (var pair in pairs) { writer.WriteLine("{0} {1}", pair.ID, pair.BestTime.Ticks); } } }
public InMemoryDatabase.PlayerProfile ReadPlayerProfile(string playerName) { var path = GetPlayerProfilePath(playerName); using (var reader = OpenZipArchiveEntryForReading(path)) { var playerProfile = new InMemoryDatabase.PlayerProfile(playerName); var entryCount = int.Parse(reader.ReadLine()); for (var i = 0; i != entryCount; ++i) { var line = reader.ReadLine(); var parts = line.Split(' '); var uid = int.Parse(parts[0]); var bestTime = long.Parse(parts[1]); playerProfile[uid].BestTime = TimeSpan.FromTicks(bestTime); } return(playerProfile); } }
public PlayerProfileData(IGameDataArchive archive, InMemoryDatabase.PlayerProfile profile) { this.archive = archive; this.profile = profile; }
public void UpdatePlayerProfile(InMemoryDatabase.PlayerProfile playerProfile) { WithWriteableArchive(archive => archive.UpdatePlayerProfile(playerProfile)); }