예제 #1
0
        /// <summary>
        /// Adds all initial Looters of nearby Characters who may loot this Loot.
        /// When all of the initial Looters gave up the Loot, the Loot becomes free for all.
        /// </summary>
        public void Initialize(Character chr, IList <LooterEntry> looters, MapId mapid)
        {
            Looters = looters;
            if (IsGroupLoot)
            {
                var groupMember = chr.GroupMember;
                if (groupMember != null)
                {
                    Group     = groupMember.Group;
                    Method    = Group.LootMethod;
                    Threshold = Group.LootThreshold;

                    var decision = Method == LootMethod.MasterLoot ? LootDecision.Master : LootDecision.Rolling;

                    IList <LooterEntry> nearbyLooters = null;

                    // TODO: masterlooter
                    foreach (var item in Items)
                    {
                        if (item.Template.Flags.HasFlag(ItemFlags.MultiLoot) ||
                            item.Template.Quality >= Threshold)
                        {
                            if (UsesRoundRobin)
                            {
                                nearbyLooters = new List <LooterEntry>();
                                Group.GetNearbyLooters(Lootable, chr, nearbyLooters);
                            }
                            else
                            {
                                nearbyLooters = Looters;
                            }
                        }

                        if (item.Template.Flags.HasFlag(ItemFlags.MultiLoot))
                        {
                            item.AddMultiLooters(nearbyLooters);
                        }
                        else if (item.Template.Quality >= Threshold)
                        {
                            item.Decision = decision;
                            if (decision == LootDecision.Rolling)
                            {
                                item.RollProgress = new LootRollProgress(this, item, nearbyLooters);
                                LootHandler.SendStartRoll(this, item, nearbyLooters, mapid);
                            }
                        }
                    }
                    return;
                }
            }
            Method = LootMethod.FreeForAll;
        }