public void Death(EmbeddedData dat, DbAccount acc, DbChar character, FameStats stats, string killer) { character.Dead = true; SaveCharacter(acc, character, acc.LockToken != null); bool firstBorn; var finalFame = stats.CalculateTotal(dat, character, new DbClassStats(acc), out firstBorn); var death = new DbDeath(acc, character.CharId); death.ObjectType = character.ObjectType; death.Level = character.Level; death.TotalFame = finalFame; death.Killer = killer; death.FirstBorn = firstBorn; death.DeathTime = DateTime.Now; death.Flush(); var idBuff = BitConverter.GetBytes(character.CharId); Sets.Remove(0, $"alive.{acc.AccountId}", idBuff); Lists.AddFirst(0, $"dead.{acc.AccountId}", idBuff); UpdateFame(acc, finalFame); var entry = new DbLegendEntry() { AccId = int.Parse(acc.AccountId), ChrId = character.CharId, TotalFame = finalFame }; DbLegend.Insert(this, death.DeathTime, entry); }
public static FameStats Read(byte[] bytes) { var ret = new FameStats(); var reader = new NReader(new MemoryStream(bytes)); byte id; while (reader.PeekChar() != -1) { id = reader.ReadByte(); switch (id) { case 0: ret.Shots = reader.ReadInt32(); break; case 1: ret.ShotsThatDamage = reader.ReadInt32(); break; case 2: ret.SpecialAbilityUses = reader.ReadInt32(); break; case 3: ret.TilesUncovered = reader.ReadInt32(); break; case 4: ret.Teleports = reader.ReadInt32(); break; case 5: ret.PotionsDrunk = reader.ReadInt32(); break; case 6: ret.MonsterKills = reader.ReadInt32(); break; case 7: ret.MonsterAssists = reader.ReadInt32(); break; case 8: ret.GodKills = reader.ReadInt32(); break; case 9: ret.GodAssists = reader.ReadInt32(); break; case 10: ret.CubeKills = reader.ReadInt32(); break; case 11: ret.OryxKills = reader.ReadInt32(); break; case 12: ret.QuestsCompleted = reader.ReadInt32(); break; case 13: ret.PirateCavesCompleted = reader.ReadInt32(); break; case 14: ret.UndeadLairsCompleted = reader.ReadInt32(); break; case 15: ret.AbyssOfDemonsCompleted = reader.ReadInt32(); break; case 16: ret.SnakePitsCompleted = reader.ReadInt32(); break; case 17: ret.SpiderDensCompleted = reader.ReadInt32(); break; case 18: ret.SpriteWorldsCompleted = reader.ReadInt32(); break; case 19: ret.LevelUpAssists = reader.ReadInt32(); break; case 20: ret.MinutesActive = reader.ReadInt32(); break; case 21: ret.TombsCompleted = reader.ReadInt32(); break; case 22: ret.TrenchesCompleted = reader.ReadInt32(); break; case 23: ret.JunglesCompleted = reader.ReadInt32(); break; case 24: ret.ManorsCompleted = reader.ReadInt32(); break; } } return(ret); }