Beispiel #1
0
        public TempInventory(MR_Type type, int size, int dwCharId)
        {
            Type      = type;
            maxsize   = size;
            Meso      = 0;
            dwOwnerID = dwCharId;

            MasterManager.TempInvManager.Add(dwCharId, this);
            LoadFromDB();
        }
        private readonly Dictionary <int, List <TempInventory> > stack = new Dictionary <int, List <TempInventory> >(); // searchable by char id

        /// <summary>
        /// This function will return a temp inventory of defined type, if none exists, it will create it.
        /// Searchable by character ID.
        /// </summary>
        public TempInventory Get(MR_Type type, int dwCharId)
        {
            var list = stack[dwCharId] ?? new List <TempInventory>();

            return(list.FirstOrDefault(ctx => ctx.Type == type) ?? new TempInventory(type, 9, dwCharId));
        }
Beispiel #3
0
        public void CreateMiniRoom(Character c, MR_Type nType, CInPacket p)
        {
            switch (nType)
            {
            case MR_Type.Omok:
                // todo
                break;

            case MR_Type.MemoryGame:
                // todo
                break;

            case MR_Type.TradingRoom:
                if (c.CurMiniRoom != null)
                {
                    c.SendPacket(CPacket.SystemMessage("You are already in a trade."));
                }
                else
                {
                    Log.Debug($"Adding trade mini room to field minirooms.");
                    Add(new CTradingRoom(c));
                }
                break;

            // Recv [CP_MiniRoom] 90 00 00 05 07 00 70 65 65 66 61 63 65 00 01 00 76 C0 4C 00
            case MR_Type.PersonalShop:
                c.SendMessage("no");
                break;

            case MR_Type.EntrustedShop:
            {
                // TODO check closeness to other shops
                var sTitle = p.DecodeString();
                p.Skip(3);         // TODO what is this
                var nShopTemplateId = p.Decode4();

                var(nItemSlot, pItem) = InventoryManipulator.GetAnyItem(c, InventoryType.Cash, nShopTemplateId);

                Log.Info($"Player [{c.Stats.sCharacterName}] attempting to create a shop with ItemID [{nShopTemplateId}] and Title [{sTitle}]");

                if (pItem == null || nItemSlot == 0)
                {
                    c.SendPacket(CPacket.SystemMessage("Invalid item or item slot."));         // packet editing?
                }
                else if (!c.Field.MapId.InRange(910000000, 910000023))
                {
                    c.SendPacket(CPacket.SystemMessage("Item does not work in this map."));
                }
                else if (!ItemConstants.is_entrusted_shop_item(pItem.nItemID))
                {
                    c.SendPacket(CPacket.SystemMessage("Invalid shop item."));         // packet editing??
                }
                else
                {
                    var pMiniRoom = new CEntrustedShop(c, nShopTemplateId, sTitle);

                    if (pMiniRoom.HasItems())
                    {
                        c.SendMessage("Please retrieve items from fredrick before opening a shop.");
                    }
                    else
                    {
                        //Add(pMiniRoom); // packet is sent in here
                    }
                }
                break;
            }

            case MR_Type.CashTradingRoom:
                // todo
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        // --------------------------------------------------- constructor

        public CMiniRoomBase(Character owner, MR_Type type)
        {
            Position = owner.Position.Clone();
            nMiniRoomType = type;
            OwnerID = owner.dwId;
        }