Beispiel #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);
        }
Beispiel #2
0
        public void Death(XmlData dat, DbAccount acc, DbChar character, FameStats stats, string killer)
        {
            character.Dead = true;
            var classStats = new DbClassStats(acc);

            // calculate total fame given bonuses
            bool firstBorn;
            var  finalFame = stats.CalculateTotal(dat, character,
                                                  classStats, out firstBorn);

            // save character
            character.FinalFame = finalFame;
            SaveCharacter(acc, character, classStats, acc.LockToken != null);

            var death = new DbDeath(acc, character.CharId)
            {
                ObjectType = character.ObjectType,
                Level      = character.Level,
                TotalFame  = finalFame,
                Killer     = killer,
                FirstBorn  = firstBorn,
                DeathTime  = DateTime.UtcNow
            };

            death.FlushAsync();

            var idBuff = BitConverter.GetBytes(character.CharId);

            _db.SetRemoveAsync(
                "alive." + acc.AccountId, idBuff, CommandFlags.FireAndForget);
            _db.ListLeftPushAsync(
                "dead." + acc.AccountId, idBuff, When.Always, CommandFlags.FireAndForget);

            UpdateFame(acc, finalFame);

            var guild = new DbGuild(acc);

            if (!guild.IsNull)
            {
                UpdateGuildFame(guild, finalFame);
                UpdatePlayerGuildFame(acc, finalFame);
            }

            if (!acc.Admin)
            {
                DbLegend.Insert(_db, acc.AccountId, character.CharId, finalFame);
            }
        }
Beispiel #3
0
        public static FameStats Read(byte[] bytes)
        {
            var     ret    = new FameStats();
            NReader 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);
        }