コード例 #1
0
ファイル: PinataHandler.cs プロジェクト: ImNotSatan/Yupi
        /// <summary>
        ///     Delivers the random pinata item.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="room">The room.</param>
        /// <param name="item">The item.</param>
        internal void DeliverRandomPinataItem(RoomUser user, Room room, RoomItem item)
        {
            if (room == null || item == null || item.GetBaseItem().InteractionType != Interaction.Pinata ||
                !Pinatas.ContainsKey(item.GetBaseItem().ItemId))
                return;

            PinataItem pinataItem;
            Pinatas.TryGetValue(item.GetBaseItem().ItemId, out pinataItem);

            if (pinataItem == null || pinataItem.Rewards.Count < 1)
                return;

            item.RefreshItem();

            //@TODO :: KESSILER, now PINATA DOESNT WORK. MUST CREATE SOLUTION LATER.

            //item.BaseName = pinataItem.Rewards[new Random().Next((pinataItem.Rewards.Count - 1))];

            item.ExtraData = string.Empty;
            room.GetRoomItemHandler().RemoveFurniture(user.GetClient(), item.Id, false);

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(
                    $"UPDATE items_rooms SET item_name='{item.BaseName}', extra_data='' WHERE id='{item.Id}'");

            if (!room.GetRoomItemHandler().SetFloorItem(user.GetClient(), item, item.X, item.Y, 0, true, false, true))
                user.GetClient().GetHabbo().GetInventoryComponent().AddItem(item);
        }
コード例 #2
0
ファイル: TeleHandler.cs プロジェクト: weslley17w/Yupi
 /// <summary>
 ///     Determines whether [is tele linked] [the specified tele identifier].
 /// </summary>
 /// <param name="teleId">The tele identifier.</param>
 /// <param name="pRoom">The p room.</param>
 /// <returns><c>true</c> if [is tele linked] [the specified tele identifier]; otherwise, <c>false</c>.</returns>
 internal static bool IsTeleLinked(uint teleId, Room pRoom)
 {
     uint linkedTele = GetLinkedTele(teleId, pRoom);
     if (linkedTele == 0u)
         return false;
     RoomItem item = pRoom.GetRoomItemHandler().GetItem(linkedTele);
     return (item != null &&
             (item.GetBaseItem().InteractionType == Interaction.Teleport ||
              item.GetBaseItem().InteractionType == Interaction.QuickTeleport)) ||
            GetTeleRoomId(linkedTele, pRoom) != 0u;
 }
コード例 #3
0
ファイル: TeleHandler.cs プロジェクト: weslley17w/Yupi
        /// <summary>
        ///     Gets the tele room identifier.
        /// </summary>
        /// <param name="teleId">The tele identifier.</param>
        /// <param name="pRoom">The p room.</param>
        /// <returns>System.UInt32.</returns>
        internal static uint GetTeleRoomId(uint teleId, Room pRoom)
        {
            if (pRoom.GetRoomItemHandler().GetItem(teleId) != null)
                return pRoom.RoomId;

            uint result;

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                commitableQueryReactor.SetQuery($"SELECT room_id FROM items_rooms WHERE id = {teleId} LIMIT 1");
                DataRow row = commitableQueryReactor.GetRow();

                result = row == null ? 0 : Convert.ToUInt32(row[0]);
            }

            return result;
        }
コード例 #4
0
ファイル: WiredSaver.cs プロジェクト: weslley17w/Yupi
        private static List<RoomItem> GetFurniItems(ClientMessage request, Room room)
        {
            List<RoomItem> list = new List<RoomItem>();
            int itemCount = request.GetInteger();

            for (int i = 0; i < itemCount; i++)
            {
                RoomItem item = room.GetRoomItemHandler().GetItem(request.GetUInteger());

                if (item != null)
                    list.Add(item);
            }

            return list;
        }
コード例 #5
0
ファイル: Rooms.cs プロジェクト: AngelRmz/Yupi
        internal void PlantMonsterplant(RoomItem mopla, Room room)
        {
            int rarity = 0, internalRarity;

            if (room == null || mopla == null)
                return;

            if ((mopla.GetBaseItem().InteractionType != Interaction.Moplaseed) &&
                (mopla.GetBaseItem().InteractionType != Interaction.RareMoplaSeed))
                return;

            if (string.IsNullOrEmpty(mopla.ExtraData) || mopla.ExtraData == "0")
                rarity = 1;

            if (!string.IsNullOrEmpty(mopla.ExtraData) && mopla.ExtraData != "0")
                rarity = int.TryParse(mopla.ExtraData, out internalRarity) ? internalRarity : 1;

            int getX = mopla.X;
            int getY = mopla.Y;

            room.GetRoomItemHandler().RemoveFurniture(Session, mopla.Id, false);

            Pet pet = CatalogManager.CreatePet(Session.GetHabbo().Id, "Monsterplant", "pet_monster", "0", "0", rarity);

            Response.Init(LibraryParser.OutgoingRequest("SendMonsterplantIdMessageComposer"));
            Response.AppendInteger(pet.PetId);
            SendResponse();

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(string.Concat("UPDATE pets_data SET room_id = '", room.RoomId, "', x = '", getX, "', y = '", getY, "' WHERE id = '", pet.PetId, "'"));

            pet.PlacedInRoom = true;
            pet.RoomId = room.RoomId;

            RoomBot bot = new RoomBot(pet.PetId, pet.OwnerId, pet.RoomId, AiType.Pet, "freeroam", pet.Name, "", pet.Look, getX, getY, 0.0, 4, null, null, "", 0, "");

            room.GetRoomUserManager().DeployBot(bot, pet);

            if (pet.DbState != DatabaseUpdateState.NeedsInsert)
                pet.DbState = DatabaseUpdateState.NeedsUpdate;

            using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor2.RunFastQuery($"DELETE FROM items_rooms WHERE id = {mopla.Id}");
                room.GetRoomUserManager().SavePets(queryreactor2);
            }
        }