Example #1
0
        public bool Execute(params object[] Params)
        {
            var player = (Habbo)Params[0];

            if (player == null || player.CurrentRoom == null || !player.InRoom)
            {
                return(false);
            }

            var user = player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(player.Username);

            if (user == null)
            {
                return(false);
            }
            if (BoolData && Instance.OwnerId != player.Id || string.IsNullOrWhiteSpace(StringData))
            {
                return(false);
            }

            IChatCommand chatCommand = null;

            if (!PlusEnvironment.GetGame().GetChatManager().GetCommands()
                .TryGetCommand(StringData.Replace(":", "").ToLower(), out chatCommand))
            {
                return(false);
            }

            if (player.ChatCommand == chatCommand)
            {
                player.WiredInteraction = true;
                var effects    = Instance.GetWired().GetEffects(this);
                var conditions = Instance.GetWired().GetConditions(this);
                foreach (var condition in conditions.ToList())
                {
                    if (!condition.Execute(player))
                    {
                        return(false);
                    }

                    Instance.GetWired().OnEvent(condition.Item);
                }

                player.GetClient().SendPacket(new WhisperComposer(user.VirtualId, StringData, 0, 0));

                //Check the ICollection to find the random addon effect.
                var hasRandomEffectAddon = effects.Count(x => x.Type == WiredBoxType.AddonRandomEffect) > 0;
                if (hasRandomEffectAddon)
                {
                    //Okay, so we have a random addon effect, now lets get the IWiredItem and attempt to execute it.
                    var randomBox = effects.FirstOrDefault(x => x.Type == WiredBoxType.AddonRandomEffect);
                    if (!randomBox.Execute())
                    {
                        return(false);
                    }

                    //Success! Let's get our selected box and continue.
                    var selectedBox = Instance.GetWired().GetRandomEffect(effects.ToList());
                    if (!selectedBox.Execute())
                    {
                        return(false);
                    }

                    //Woo! Almost there captain, now lets broadcast the update to the room instance.
                    if (Instance != null)
                    {
                        Instance.GetWired().OnEvent(randomBox.Item);
                        Instance.GetWired().OnEvent(selectedBox.Item);
                    }
                }
                else
                {
                    foreach (var effect in effects.ToList())
                    {
                        if (!effect.Execute(player))
                        {
                            return(false);
                        }

                        Instance.GetWired().OnEvent(effect.Item);
                    }
                }

                return(true);
            }

            return(false);
        }
Example #2
0
        public bool Execute(params object[] Params)
        {
            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.CurrentRoom == null || !Player.InRoom)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

            if (User == null)
            {
                return(false);
            }

            if ((BoolData && Instance.OwnerId != Player.Id) || string.IsNullOrWhiteSpace(StringData))
            {
                return(false);
            }

            if (!NeonEnvironment.GetGame().GetChatManager().GetCommands().TryGetCommand(StringData.Replace(":", "").ToLower(), out IChatCommand ChatCommand))
            {
                return(false);
            }

            if (Player.IChatCommand == ChatCommand)
            {
                Player.WiredInteraction = true;
                ICollection <IWiredItem> Effects    = Instance.GetWired().GetEffects(this);
                ICollection <IWiredItem> Conditions = Instance.GetWired().GetConditions(this);

                foreach (IWiredItem Condition in Conditions.ToList())
                {
                    if (!Condition.Execute(Player))
                    {
                        return(false);
                    }

                    Instance.GetWired().OnEvent(Condition.Item);
                }

                Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, StringData, 0, 0));
                //Check the ICollection to find the random addon effect.
                bool HasRandomEffectAddon = Effects.Where(x => x.Type == WiredBoxType.AddonRandomEffect).ToList().Count() > 0;
                if (HasRandomEffectAddon)
                {
                    //Okay, so we have a random addon effect, now lets get the IWiredItem and attempt to execute it.
                    IWiredItem RandomBox = Effects.FirstOrDefault(x => x.Type == WiredBoxType.AddonRandomEffect);
                    if (!RandomBox.Execute())
                    {
                        return(false);
                    }

                    //Success! Let's get our selected box and continue.
                    IWiredItem SelectedBox = Instance.GetWired().GetRandomEffect(Effects.ToList());
                    if (!SelectedBox.Execute())
                    {
                        return(false);
                    }

                    //Woo! Almost there captain, now lets broadcast the update to the room instance.
                    if (Instance != null)
                    {
                        Instance.GetWired().OnEvent(RandomBox.Item);
                        Instance.GetWired().OnEvent(SelectedBox.Item);
                    }
                }
                else
                {
                    foreach (IWiredItem Effect in Effects.ToList())
                    {
                        if (!Effect.Execute(Player))
                        {
                            return(false);
                        }

                        Instance.GetWired().OnEvent(Effect.Item);
                    }
                }
                return(true);
            }

            return(false);
        }