Ejemplo n.º 1
0
        public bool Add(Identity from, IItem item)
        {
            if (from.Equals(this.Shopper))
            {
                this.vendorsBag.Add(this.vendorsBag.FindFreeSlot(), item);
                LogUtil.Debug(DebugInfoDetail.Shopping, "Added Item from character " + from.ToString(true));
            }
            else
            {
                this.charactersBag.Add(from.Instance);
                LogUtil.Debug(DebugInfoDetail.Shopping, "Added Item from shop on position " + from.ToString(true));
            }

            // For now no invalid trades
            return true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            List<MessageBody> replies = new List<MessageBody>();
            string reply = "Looking up for statel in playfield " + character.Playfield.Identity.Instance;
            replies.Add(ChatTextMessageHandler.Default.Create(character, reply));
            StatelData o = null;
            StaticDynel o2 = null;
            Vendor o3 = null;
            Coordinate tempCoordinate = character.Coordinates();
            if (!PlayfieldLoader.PFData.ContainsKey(character.Playfield.Identity.Instance))
            {
                reply = "Could not find data for playfield " + character.Playfield.Identity.Instance;
                replies.Add(ChatTextMessageHandler.Default.Create(character, reply));
            }
            else
            {
                if (target.Equals(Identity.None))
                {
                    PlayfieldData pfData = PlayfieldLoader.PFData[character.Playfield.Identity.Instance];
                    foreach (StatelData s in pfData.Statels)
                    {
                        if (o == null)
                        {
                            o = s;
                        }
                        else
                        {
                            if (Coordinate.Distance2D(tempCoordinate, s.Coord())
                                < Coordinate.Distance2D(tempCoordinate, o.Coord()))
                            {
                                o = s;
                            }
                        }
                    }

                    foreach (StaticDynel sd in Pool.Instance.GetAll<StaticDynel>(character.Playfield.Identity))
                    {
                        if (o2 == null)
                        {
                            o2 = sd;
                        }
                        else
                        {
                            if (Coordinate.Distance2D(tempCoordinate, sd.Coordinate)
                                < Coordinate.Distance2D(tempCoordinate, o2.Coordinate))
                            {
                                o2 = sd;
                            }
                        }

                    }

                }
                else
                {
                    o =
                        PlayfieldLoader.PFData[character.Playfield.Identity.Instance].Statels.FirstOrDefault(
                            x => x.Identity == target);
                    o2 =
                        Pool.Instance.GetAll<StaticDynel>(character.Playfield.Identity)
                            .FirstOrDefault(x => x.Identity == target);
                    o3 =
                        Pool.Instance.GetAll<Vendor>(character.Playfield.Identity)
                            .FirstOrDefault(x => x.Identity == target);
                }

                if ((o == null) && (o2 == null) && (o3 == null))
                {
                    replies.Add(
                        ChatTextMessageHandler.Default.Create(
                            character,
                            "No statel/static dynel on this playfield... Very odd, where exactly are you???"));
                }
                else
                {
                    if (o3 != null)
                    {
                        replies.Add(
                                                    ChatTextMessageHandler.Default.Create(
                                                        character,
                                                        o3.Identity.Type.ToString() + " " + ((int)o3.Identity.Type).ToString("X8") + ":"
                                                        + o3.Identity.Instance.ToString("X8")));
                        replies.Add(
                            ChatTextMessageHandler.Default.Create(character, "Item Template Id: " + o3.Template.ID));
                        foreach (Event se in o3.Events)
                        {
                            replies.Add(ChatTextMessageHandler.Default.Create(character, se.ToString()));
                        }
                    }
                    else if (((o != null) && (o2 == null))
                        || ((o != null) && (Coordinate.Distance2D(tempCoordinate, o.Coord())
                            < Coordinate.Distance2D(tempCoordinate, o2.Coordinate))))
                    {

                        replies.Add(
                            ChatTextMessageHandler.Default.Create(
                                character,
                                o.Identity.Type.ToString() + " " + ((int)o.Identity.Type).ToString("X8") + ":"
                                + o.Identity.Instance.ToString("X8")));
                        replies.Add(
                            ChatTextMessageHandler.Default.Create(character, "Item Template Id: " + o.TemplateId));
                        foreach (Event se in o.Events)
                        {
                            replies.Add(ChatTextMessageHandler.Default.Create(character, se.ToString()));
                        }
                    }
                    else
                    {

                        replies.Add(ChatTextMessageHandler.Default.Create(character, o2.Identity.ToString() + " " + o2.Identity.ToString(true)));
                        replies.Add(ChatTextMessageHandler.Default.Create(character, "Item template Id: " + o2.Stats[(int)StatIds.acgitemtemplateid].ToString()));
                        foreach (Event se in o2.Events)
                        {
                            replies.Add(ChatTextMessageHandler.Default.Create(character, se.ToString()));
                        }
                    }
                }
            }

            character.Playfield.Publish(Bulk.CreateIM(character.Controller.Client, replies.ToArray()));
        }
Ejemplo n.º 3
0
 public IItem Remove(Identity from, int slot)
 {
     if (from.Equals(this.Shopper))
     {
         LogUtil.Debug(DebugInfoDetail.Shopping, "Removed Item from character in shopbag from slot " + slot);
         return this.vendorsBag.Remove(slot);
     }
     this.charactersBag.Remove(slot);
     return null;
 }