Esempio n. 1
0
        public virtual void OnLootRoll(DungeonLootEntry entry, DungeonLootRoll roll)
        {
            if (entry == null || !entry.Valid)
            {
                return;
            }

            GroupMessage(
                m =>
                String.Format(
                    "{0} select{1} {2} for:  {3}",
                    m == roll.Mobile ? "You" : roll.Mobile.RawName,
                    m != roll.Mobile ? "s" : String.Empty,
                    roll.Action,
                    entry.Item.ResolveName(m).ToUpperWords()));
        }
Esempio n. 2
0
        public virtual void OnLootWin(DungeonLootEntry entry, DungeonLootRoll roll, bool timeout)
        {
            if (entry == null || !entry.Valid)
            {
                return;
            }

            entry.Item.Movable = true;

            if (!GiveLoot(roll.Mobile, entry.Item, false))
            {
                entry.Winner = null;
                entry.Rolls.Remove(roll.Mobile);
                roll.Free();
                return;
            }

            foreach (var val in entry.Rolls.Values)
            {
                DungeonLootRoll r;

                if (val != null)
                {
                    r = val.Value;
                }
                else
                {
                    continue;
                }

                GroupMessage(
                    m =>
                    String.Format(
                        "{0} roll{1} {2}",
                        m == r.Mobile ? "You" : r.Mobile.RawName,
                        m != r.Mobile ? "s" : String.Empty,
                        r.Value));
            }

            GroupMessage(
                m =>
                String.Format(
                    "{0} receive{1} loot: {2}",
                    m == roll.Mobile ? "You" : roll.Mobile.RawName,
                    m != roll.Mobile ? "s" : String.Empty,
                    entry.Item.ResolveName(m).ToUpperWords()));
        }
        private int Roll(PlayerMobile m, DungeonLootAction action)
        {
            if (!Valid || HasWinner || m == null || m.Deleted)
            {
                return(-1);
            }

            var roll = Rolls.GetValue(m);

            if (roll == null)
            {
                var value = action != DungeonLootAction.Pass ? (1 + Utility.Random(100)) : 0;

                Rolls.AddOrReplace(m, roll = new DungeonLootRoll(m, action, value));
            }

            if (Dungeon != null)
            {
                Dungeon.OnLootRoll(this, roll.Value);
            }

            return(roll.Value);
        }
        public virtual void Deserialize(GenericReader reader)
        {
            reader.GetVersion();

            Item    = reader.ReadItem();
            Created = reader.ReadDateTime();
            Expire  = reader.ReadDeltaTime();
            Winner  = reader.ReadMobile <PlayerMobile>();

            Rolls = reader.ReadDictionary(
                r =>
            {
                var k             = r.ReadMobile <PlayerMobile>();
                DungeonLootRoll?v = null;

                if (r.ReadBool())
                {
                    v = new DungeonLootRoll(r);
                }

                return(new KeyValuePair <PlayerMobile, DungeonLootRoll?>(k, v));
            });
        }