Пример #1
0
        public void Death(XmlData 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     = acc.AccountId,
                ChrId     = character.CharId,
                TotalFame = finalFame
            };

            DbLegend.Insert(this, death.DeathTime, entry);
        }
Пример #2
0
        public static void Insert(Database db, DateTime time, DbLegendEntry entry)
        {
            double t = time.ToUnixTimestamp();

            byte[] buff = new byte[12];
            Buffer.BlockCopy(BitConverter.GetBytes(entry.TotalFame), 0, buff, 0, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(entry.AccId), 0, buff, 4, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(entry.ChrId), 0, buff, 8, 4);
            db.SortedSets.Add(0, "legends", buff, t);
        }