public override async Task <bool> Validate(UserViewModel user)
        {
            CurrencyModel rankSystem = this.RankSystem;

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

            RankModel rank = this.RequiredRank;

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

            if (!user.Data.IsCurrencyRankExempt)
            {
                if (this.MatchType == RankRequirementMatchTypeEnum.GreaterThanOrEqualTo)
                {
                    if (!rankSystem.HasAmount(user.Data, rank.Amount))
                    {
                        await this.SendChatMessage(string.Format("You do not have the required rank of {0} ({1} {2}) to do this", rank.Name, rank.Amount, rankSystem.Name));

                        return(false);
                    }
                }
                else if (this.MatchType == RankRequirementMatchTypeEnum.EqualTo)
                {
                    if (rankSystem.GetRank(user.Data) != rank)
                    {
                        await this.SendChatMessage(string.Format("You do not have the required rank of {0} to do this", rank.Name, rank.Amount, rankSystem.Name));

                        return(false);
                    }
                }
                else if (this.MatchType == RankRequirementMatchTypeEnum.LessThanOrEqualTo)
                {
                    RankModel nextRank = rankSystem.GetNextRank(user.Data);
                    if (nextRank != CurrencyModel.NoRank && rankSystem.HasAmount(user.Data, nextRank.Amount))
                    {
                        await this.SendChatMessage(string.Format("You are over the required rank of {0} ({1} {2}) to do this", rank.Name, rank.Amount, rankSystem.Name));

                        return(false);
                    }
                }
            }

            return(true);
        }
        public bool DoesMeetRankRequirement(UserDataModel userData)
        {
            if (userData.IsCurrencyRankExempt)
            {
                return(true);
            }

            CurrencyModel currency = this.GetCurrency();

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

            RankModel rank = this.RequiredRank;

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

            if (!currency.HasAmount(userData, rank.Amount))
            {
                return(false);
            }

            if (this.MustEqual && currency.GetRank(userData) != rank)
            {
                return(false);
            }

            return(true);
        }
        public override Task <Result> Validate(CommandParametersModel parameters)
        {
            CurrencyModel rankSystem = this.RankSystem;

            if (rankSystem == null)
            {
                return(Task.FromResult(new Result(MixItUp.Base.Resources.RankSystemDoesNotExist)));
            }

            RankModel rank = this.RequiredRank;

            if (rank == null)
            {
                return(Task.FromResult(new Result(MixItUp.Base.Resources.RankDoesNotExist)));
            }

            if (!parameters.User.Data.IsCurrencyRankExempt)
            {
                RankModel currentRank = rankSystem.GetRank(parameters.User.Data);
                if (this.MatchType == RankRequirementMatchTypeEnum.GreaterThanOrEqualTo)
                {
                    if (!rankSystem.HasAmount(parameters.User.Data, rank.Amount))
                    {
                        return(Task.FromResult(new Result(string.Format(MixItUp.Base.Resources.RankRequirementNotGreaterThanOrEqual, rank.Name, rank.Amount, rankSystem.Name) + " " + string.Format(MixItUp.Base.Resources.RequirementCurrentAmount, currentRank))));
                    }
                }
                else if (this.MatchType == RankRequirementMatchTypeEnum.EqualTo)
                {
                    if (rankSystem.GetRank(parameters.User.Data) != rank)
                    {
                        return(Task.FromResult(new Result(string.Format(MixItUp.Base.Resources.RankRequirementNotGreaterThanOrEqual, rank.Name, rank.Amount, rankSystem.Name) + " " + string.Format(MixItUp.Base.Resources.RequirementCurrentAmount, currentRank))));
                    }
                }
                else if (this.MatchType == RankRequirementMatchTypeEnum.LessThanOrEqualTo)
                {
                    RankModel nextRank = rankSystem.GetNextRank(parameters.User.Data);
                    if (nextRank != CurrencyModel.NoRank && rankSystem.HasAmount(parameters.User.Data, nextRank.Amount))
                    {
                        return(Task.FromResult(new Result(string.Format(MixItUp.Base.Resources.RankRequirementNotLessThan, rank.Name, rank.Amount, rankSystem.Name) + " " + string.Format(MixItUp.Base.Resources.RequirementCurrentAmount, currentRank))));
                    }
                }
            }

            return(Task.FromResult(new Result()));
        }
Пример #4
0
        private User AdjustCurrency(UserDataModel user, Guid currencyID, [FromBody] AdjustCurrency currencyUpdate)
        {
            if (!ChannelSession.Settings.Currency.ContainsKey(currencyID))
            {
                var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content = new ObjectContent <Error>(new Error {
                        Message = $"Unable to find currency: {currencyID.ToString()}."
                    }, new JsonMediaTypeFormatter(), "application/json"),
                    ReasonPhrase = "Currency ID not found"
                };
                throw new HttpResponseException(resp);
            }

            if (currencyUpdate == null)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <Error>(new Error {
                        Message = "Unable to parse currency adjustment from POST body."
                    }, new JsonMediaTypeFormatter(), "application/json"),
                    ReasonPhrase = "Invalid POST Body"
                };
                throw new HttpResponseException(resp);
            }

            CurrencyModel currency = ChannelSession.Settings.Currency[currencyID];

            if (currencyUpdate.Amount < 0)
            {
                int quantityToRemove = currencyUpdate.Amount * -1;
                if (!currency.HasAmount(user, quantityToRemove))
                {
                    var resp = new HttpResponseMessage(HttpStatusCode.Forbidden)
                    {
                        Content = new ObjectContent <Error>(new Error {
                            Message = "User does not have enough currency to remove"
                        }, new JsonMediaTypeFormatter(), "application/json"),
                        ReasonPhrase = "Not Enough Currency"
                    };
                    throw new HttpResponseException(resp);
                }

                currency.SubtractAmount(user, quantityToRemove);
            }
            else if (currencyUpdate.Amount > 0)
            {
                currency.AddAmount(user, currencyUpdate.Amount);
            }

            return(UserFromUserDataViewModel(user));
        }
Пример #5
0
        public override async Task <bool> Validate(UserViewModel user)
        {
            CurrencyModel currency = this.Currency;

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

            if (!user.Data.IsCurrencyRankExempt && !currency.HasAmount(user.Data, this.Amount))
            {
                await this.SendChatMessage(string.Format("You do not have the required {0} {1} to do this", this.Amount, currency.Name));

                return(false);
            }

            return(true);
        }
        public bool TrySubtractAmount(UserDataModel userData, int amount, bool requireAmount = false)
        {
            if (this.DoesMeetCurrencyRequirement(amount))
            {
                CurrencyModel currency = this.GetCurrency();
                if (currency == null)
                {
                    return(false);
                }

                if (requireAmount && !currency.HasAmount(userData, amount))
                {
                    return(false);
                }

                currency.SubtractAmount(userData, amount);
                return(true);
            }
            return(false);
        }
Пример #7
0
        protected override async Task PerformInternal(CommandParametersModel parameters)
        {
            CurrencyModel currency = null;

            InventoryModel     inventory = null;
            InventoryItemModel item      = null;

            StreamPassModel streamPass = null;

            string systemName = null;

            if (this.CurrencyID != Guid.Empty)
            {
                if (!ChannelSession.Settings.Currency.ContainsKey(this.CurrencyID))
                {
                    return;
                }
                currency   = ChannelSession.Settings.Currency[this.CurrencyID];
                systemName = currency.Name;
            }

            if (this.InventoryID != Guid.Empty)
            {
                if (!ChannelSession.Settings.Inventory.ContainsKey(this.InventoryID))
                {
                    return;
                }
                inventory  = ChannelSession.Settings.Inventory[this.InventoryID];
                systemName = inventory.Name;

                if (!string.IsNullOrEmpty(this.ItemName))
                {
                    string itemName = await ReplaceStringWithSpecialModifiers(this.ItemName, parameters);

                    item = inventory.GetItem(itemName);
                    if (item == null)
                    {
                        return;
                    }
                }
            }

            if (this.StreamPassID != Guid.Empty)
            {
                if (!ChannelSession.Settings.StreamPass.ContainsKey(this.StreamPassID))
                {
                    return;
                }
                streamPass = ChannelSession.Settings.StreamPass[this.StreamPassID];
                systemName = streamPass.Name;
            }

            if (this.ActionType == ConsumablesActionTypeEnum.ResetForAllUsers)
            {
                if (currency != null)
                {
                    await currency.Reset();
                }
                else if (inventory != null)
                {
                    await inventory.Reset();
                }
                else if (streamPass != null)
                {
                    await streamPass.Reset();
                }
            }
            else if (this.ActionType == ConsumablesActionTypeEnum.ResetForUser)
            {
                if (currency != null)
                {
                    currency.ResetAmount(parameters.User.Data);
                }
                else if (inventory != null)
                {
                    inventory.ResetAmount(parameters.User.Data);
                }
                else if (streamPass != null)
                {
                    streamPass.ResetAmount(parameters.User.Data);
                }
            }
            else
            {
                string amountTextValue = await ReplaceStringWithSpecialModifiers(this.Amount, parameters);

                amountTextValue = MathHelper.ProcessMathEquation(amountTextValue).ToString();

                if (!double.TryParse(amountTextValue, out double doubleAmount))
                {
                    await ChannelSession.Services.Chat.SendMessage(string.Format(MixItUp.Base.Resources.CounterActionNotAValidAmount, amountTextValue, systemName));

                    return;
                }

                int amountValue = (int)Math.Ceiling(doubleAmount);
                if (amountValue < 0)
                {
                    await ChannelSession.Services.Chat.SendMessage(string.Format(MixItUp.Base.Resources.GameCurrencyRequirementAmountGreaterThan, amountTextValue, systemName));

                    return;
                }

                HashSet <UserDataModel> receiverUserData = new HashSet <UserDataModel>();
                if (this.ActionType == ConsumablesActionTypeEnum.AddToUser)
                {
                    receiverUserData.Add(parameters.User.Data);
                }
                else if (this.ActionType == ConsumablesActionTypeEnum.AddToSpecificUser || this.ActionType == ConsumablesActionTypeEnum.SubtractFromSpecificUser)
                {
                    if (!string.IsNullOrEmpty(this.Username))
                    {
                        string usernameString = await ReplaceStringWithSpecialModifiers(this.Username, parameters);

                        UserViewModel receivingUser = null;
                        if (this.UsersMustBePresent)
                        {
                            receivingUser = ChannelSession.Services.User.GetActiveUserByUsername(usernameString, parameters.Platform);
                        }
                        else
                        {
                            receivingUser = await ChannelSession.Services.User.GetUserFullSearch(parameters.Platform, userID : null, usernameString);
                        }

                        if (receivingUser != null)
                        {
                            receiverUserData.Add(receivingUser.Data);
                        }
                        else
                        {
                            await ChannelSession.Services.Chat.SendMessage(MixItUp.Base.Resources.UserNotFound);

                            return;
                        }
                    }
                }
                else if (this.ActionType == ConsumablesActionTypeEnum.AddToAllChatUsers || this.ActionType == ConsumablesActionTypeEnum.SubtractFromAllChatUsers)
                {
                    foreach (UserViewModel chatUser in ChannelSession.Services.User.GetAllWorkableUsers())
                    {
                        if (chatUser.HasPermissionsTo(this.UsersToApplyTo))
                        {
                            receiverUserData.Add(chatUser.Data);
                        }
                    }
                    receiverUserData.Add(ChannelSession.GetCurrentUser().Data);
                }

                if ((this.DeductFromUser && receiverUserData.Count > 0) || this.ActionType == ConsumablesActionTypeEnum.SubtractFromUser)
                {
                    if (currency != null)
                    {
                        if (!currency.HasAmount(parameters.User.Data, amountValue))
                        {
                            await ChannelSession.Services.Chat.SendMessage(string.Format(MixItUp.Base.Resources.CurrencyRequirementDoNotHaveAmount, amountValue, systemName));

                            return;
                        }
                        currency.SubtractAmount(parameters.User.Data, amountValue);
                    }
                    else if (inventory != null)
                    {
                        if (!inventory.HasAmount(parameters.User.Data, item, amountValue))
                        {
                            await ChannelSession.Services.Chat.SendMessage(string.Format(MixItUp.Base.Resources.CurrencyRequirementDoNotHaveAmount, amountValue, item.Name));

                            return;
                        }
                        inventory.SubtractAmount(parameters.User.Data, item, amountValue);
                    }
                    else if (streamPass != null)
                    {
                        if (!streamPass.HasAmount(parameters.User.Data, amountValue))
                        {
                            await ChannelSession.Services.Chat.SendMessage(string.Format(MixItUp.Base.Resources.CurrencyRequirementDoNotHaveAmount, amountValue, systemName));

                            return;
                        }
                        streamPass.SubtractAmount(parameters.User.Data, amountValue);
                    }
                }

                if (receiverUserData.Count > 0)
                {
                    foreach (UserDataModel receiverUser in receiverUserData)
                    {
                        if (currency != null)
                        {
                            if (this.ActionType == ConsumablesActionTypeEnum.SubtractFromSpecificUser || this.ActionType == ConsumablesActionTypeEnum.SubtractFromAllChatUsers)
                            {
                                currency.SubtractAmount(receiverUser, amountValue);
                            }
                            else
                            {
                                currency.AddAmount(receiverUser, amountValue);
                            }
                        }
                        else if (inventory != null)
                        {
                            if (this.ActionType == ConsumablesActionTypeEnum.SubtractFromSpecificUser || this.ActionType == ConsumablesActionTypeEnum.SubtractFromAllChatUsers)
                            {
                                inventory.SubtractAmount(receiverUser, item, amountValue);
                            }
                            else
                            {
                                inventory.AddAmount(receiverUser, item, amountValue);
                            }
                        }
                        else if (streamPass != null)
                        {
                            if (this.ActionType == ConsumablesActionTypeEnum.SubtractFromSpecificUser || this.ActionType == ConsumablesActionTypeEnum.SubtractFromAllChatUsers)
                            {
                                streamPass.SubtractAmount(receiverUser, amountValue);
                            }
                            else
                            {
                                streamPass.AddAmount(receiverUser, amountValue);
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
        public async Task PerformShopCommand(UserViewModel user, IEnumerable <string> arguments = null, StreamingPlatformTypeEnum platform = StreamingPlatformTypeEnum.None)
        {
            try
            {
                if (ChannelSession.Services.Chat != null && ChannelSession.Settings.Currency.ContainsKey(this.ShopCurrencyID))
                {
                    CurrencyModel currency = ChannelSession.Settings.Currency[this.ShopCurrencyID];

                    if (arguments != null && arguments.Count() > 0)
                    {
                        string arg1 = arguments.ElementAt(0);
                        if (arguments.Count() == 1 && arg1.Equals("list", StringComparison.InvariantCultureIgnoreCase))
                        {
                            List <string> items = new List <string>();
                            foreach (UserInventoryItemModel item in this.Items.Values)
                            {
                                if (item.HasBuyAmount || item.HasSellAmount)
                                {
                                    items.Add(item.Name);
                                }
                            }
                            await ChannelSession.Services.Chat.SendMessage("Items Available to Buy/Sell: " + string.Join(", ", items));

                            return;
                        }
                        else if (arguments.Count() >= 2 &&
                                 (arg1.Equals("buy", StringComparison.InvariantCultureIgnoreCase) || arg1.Equals("sell", StringComparison.InvariantCultureIgnoreCase)))
                        {
                            int amount = 1;

                            IEnumerable <string>   itemArgs = arguments.Skip(1);
                            UserInventoryItemModel item     = this.GetItem(string.Join(" ", itemArgs));
                            if (item == null && itemArgs.Count() > 1)
                            {
                                itemArgs = itemArgs.Take(itemArgs.Count() - 1);
                                item     = this.GetItem(string.Join(" ", itemArgs));
                                if (item != null)
                                {
                                    if (!int.TryParse(arguments.Last(), out amount) || amount <= 0)
                                    {
                                        await ChannelSession.Services.Chat.SendMessage("A valid amount greater than 0 must be specified");

                                        return;
                                    }
                                }
                            }

                            if (item == null)
                            {
                                await ChannelSession.Services.Chat.SendMessage("The item you specified does not exist");

                                return;
                            }

                            int           totalcost = 0;
                            CustomCommand command   = null;
                            if (arg1.Equals("buy", StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (item.HasBuyAmount)
                                {
                                    int itemMaxAmount = (item.HasMaxAmount) ? item.MaxAmount : this.DefaultMaxAmount;
                                    if ((this.GetAmount(user.Data, item) + amount) <= itemMaxAmount)
                                    {
                                        totalcost = item.BuyAmount * amount;
                                        if (currency.HasAmount(user.Data, totalcost))
                                        {
                                            currency.SubtractAmount(user.Data, totalcost);
                                            this.AddAmount(user.Data, item, amount);
                                            command = this.ItemsBoughtCommand;
                                        }
                                        else
                                        {
                                            await ChannelSession.Services.Chat.SendMessage(string.Format("You do not have the required {0} {1} to purchase this item", totalcost, currency.Name));
                                        }
                                    }
                                    else
                                    {
                                        await ChannelSession.Services.Chat.SendMessage(string.Format("You can only have {0} {1} in total", itemMaxAmount, item.Name));
                                    }
                                }
                                else
                                {
                                    await ChannelSession.Services.Chat.SendMessage("This item is not available for buying");
                                }
                            }
                            else if (arg1.Equals("sell", StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (item.HasSellAmount)
                                {
                                    totalcost = item.SellAmount * amount;
                                    if (this.HasAmount(user.Data, item, amount))
                                    {
                                        this.SubtractAmount(user.Data, item, amount);
                                        currency.AddAmount(user.Data, totalcost);
                                        command = this.ItemsSoldCommand;
                                    }
                                    else
                                    {
                                        await ChannelSession.Services.Chat.SendMessage(string.Format("You do not have the required {0} {1} to sell", amount, item.Name));
                                    }
                                }
                                else
                                {
                                    await ChannelSession.Services.Chat.SendMessage("This item is not available for selling");
                                }
                            }
                            else
                            {
                                await ChannelSession.Services.Chat.SendMessage("You must specify either \"buy\" & \"sell\"");
                            }

                            if (command != null)
                            {
                                Dictionary <string, string> specialIdentifiers = new Dictionary <string, string>();
                                specialIdentifiers["itemtotal"]    = amount.ToString();
                                specialIdentifiers["itemname"]     = item.Name;
                                specialIdentifiers["itemcost"]     = totalcost.ToString();
                                specialIdentifiers["currencyname"] = currency.Name;
                                await command.Perform(user, arguments : arguments, extraSpecialIdentifiers : specialIdentifiers);
                            }
                            return;
                        }
                        else
                        {
                            UserInventoryItemModel item = this.GetItem(string.Join(" ", arguments));
                            if (item != null)
                            {
                                if (item.HasBuyAmount || item.HasSellAmount)
                                {
                                    StringBuilder itemInfo = new StringBuilder();
                                    itemInfo.Append(item.Name + ": ");
                                    if (item.HasBuyAmount)
                                    {
                                        itemInfo.Append(string.Format("Buy = {0} {1}", item.BuyAmount, currency.Name));
                                    }
                                    if (item.HasBuyAmount && item.HasSellAmount)
                                    {
                                        itemInfo.Append(string.Format(", "));
                                    }
                                    if (item.HasSellAmount)
                                    {
                                        itemInfo.Append(string.Format("Sell = {0} {1}", item.SellAmount, currency.Name));
                                    }

                                    await ChannelSession.Services.Chat.SendMessage(itemInfo.ToString());
                                }
                                else
                                {
                                    await ChannelSession.Services.Chat.SendMessage("This item is not available to buy/sell");
                                }
                            }
                            else
                            {
                                await ChannelSession.Services.Chat.SendMessage("The item you specified does not exist");
                            }
                            return;
                        }
                    }

                    StringBuilder storeHelp = new StringBuilder();
                    storeHelp.Append(this.ShopCommand + " list = Lists all the items available for buying/selling ** ");
                    storeHelp.Append(this.ShopCommand + " <ITEM NAME> = Lists the buying/selling price for the item ** ");
                    storeHelp.Append(this.ShopCommand + " buy <ITEM NAME> [AMOUNT] = Buys 1 or the amount specified of the item ** ");
                    storeHelp.Append(this.ShopCommand + " sell <ITEM NAME> [AMOUNT] = Sells 1 or the amount specified of the item");
                    await ChannelSession.Services.Chat.SendMessage(storeHelp.ToString());
                }
            }
            catch (Exception ex) { Logger.Log(ex); }
        }
Пример #9
0
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            if (ChannelSession.Services.Chat != null)
            {
                CurrencyModel currency = null;

                InventoryModel     inventory = null;
                InventoryItemModel item      = null;

                StreamPassModel streamPass = null;

                string systemName = null;

                if (this.CurrencyID != Guid.Empty)
                {
                    if (!ChannelSession.Settings.Currency.ContainsKey(this.CurrencyID))
                    {
                        return;
                    }
                    currency   = ChannelSession.Settings.Currency[this.CurrencyID];
                    systemName = currency.Name;
                }

                if (this.InventoryID != Guid.Empty)
                {
                    if (!ChannelSession.Settings.Inventory.ContainsKey(this.InventoryID))
                    {
                        return;
                    }
                    inventory  = ChannelSession.Settings.Inventory[this.InventoryID];
                    systemName = inventory.Name;

                    if (!string.IsNullOrEmpty(this.ItemName))
                    {
                        string itemName = await this.ReplaceStringWithSpecialModifiers(this.ItemName, user, arguments);

                        item = inventory.GetItem(itemName);
                        if (item == null)
                        {
                            return;
                        }
                    }
                }

                if (this.StreamPassID != Guid.Empty)
                {
                    if (!ChannelSession.Settings.StreamPass.ContainsKey(this.StreamPassID))
                    {
                        return;
                    }
                    streamPass = ChannelSession.Settings.StreamPass[this.StreamPassID];
                    systemName = streamPass.Name;
                }

                if (this.CurrencyActionType == CurrencyActionTypeEnum.ResetForAllUsers)
                {
                    if (currency != null)
                    {
                        await currency.Reset();
                    }
                    else if (inventory != null)
                    {
                        await inventory.Reset();
                    }
                    else if (streamPass != null)
                    {
                        await streamPass.Reset();
                    }
                }
                else if (this.CurrencyActionType == CurrencyActionTypeEnum.ResetForUser)
                {
                    if (currency != null)
                    {
                        currency.ResetAmount(user.Data);
                    }
                    else if (inventory != null)
                    {
                        inventory.ResetAmount(user.Data);
                    }
                    else if (streamPass != null)
                    {
                        streamPass.ResetAmount(user.Data);
                    }
                }
                else
                {
                    string amountTextValue = await this.ReplaceStringWithSpecialModifiers(this.Amount, user, arguments);

                    if (!double.TryParse(amountTextValue, out double doubleAmount))
                    {
                        await ChannelSession.Services.Chat.SendMessage(string.Format("{0} is not a valid amount of {1}", amountTextValue, systemName));

                        return;
                    }

                    int amountValue = (int)Math.Ceiling(doubleAmount);
                    if (amountValue <= 0)
                    {
                        await ChannelSession.Services.Chat.SendMessage("The amount specified must be greater than 0");

                        return;
                    }

                    HashSet <UserDataModel> receiverUserData = new HashSet <UserDataModel>();
                    if (this.CurrencyActionType == CurrencyActionTypeEnum.AddToUser)
                    {
                        receiverUserData.Add(user.Data);
                    }
                    else if (this.CurrencyActionType == CurrencyActionTypeEnum.AddToSpecificUser || this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromSpecificUser)
                    {
                        if (!string.IsNullOrEmpty(this.Username))
                        {
                            string usernameString = await this.ReplaceStringWithSpecialModifiers(this.Username, user, arguments);

                            UserViewModel receivingUser = ChannelSession.Services.User.GetUserByUsername(usernameString, this.platform);
                            if (receivingUser != null)
                            {
                                receiverUserData.Add(receivingUser.Data);
                            }
                            else
                            {
                                await ChannelSession.Services.Chat.SendMessage("The user could not be found");

                                return;
                            }
                        }
                    }
                    else if (this.CurrencyActionType == CurrencyActionTypeEnum.AddToAllChatUsers || this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromAllChatUsers)
                    {
                        foreach (UserViewModel chatUser in ChannelSession.Services.User.GetAllWorkableUsers())
                        {
                            if (chatUser.HasPermissionsTo(this.RoleRequirement))
                            {
                                receiverUserData.Add(chatUser.Data);
                            }
                        }
                        receiverUserData.Add(ChannelSession.GetCurrentUser().Data);
                    }

                    if ((this.DeductFromUser && receiverUserData.Count > 0) || this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromUser)
                    {
                        if (currency != null)
                        {
                            if (!currency.HasAmount(user.Data, amountValue))
                            {
                                await ChannelSession.Services.Chat.SendMessage(string.Format("You do not have the required {0} {1} to do this", amountValue, systemName));

                                return;
                            }
                            currency.SubtractAmount(user.Data, amountValue);
                        }
                        else if (inventory != null)
                        {
                            if (!inventory.HasAmount(user.Data, item, amountValue))
                            {
                                await ChannelSession.Services.Chat.SendMessage(string.Format("You do not have the required {0} {1} to do this", amountValue, item));

                                return;
                            }
                            inventory.SubtractAmount(user.Data, item, amountValue);
                        }
                        else if (streamPass != null)
                        {
                            if (!streamPass.HasAmount(user.Data, amountValue))
                            {
                                await ChannelSession.Services.Chat.SendMessage(string.Format("You do not have the required {0} {1} to do this", amountValue, systemName));

                                return;
                            }
                            streamPass.SubtractAmount(user.Data, amountValue);
                        }
                    }

                    if (receiverUserData.Count > 0)
                    {
                        foreach (UserDataModel receiverUser in receiverUserData)
                        {
                            if (currency != null)
                            {
                                if (this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromSpecificUser || this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromAllChatUsers)
                                {
                                    currency.SubtractAmount(receiverUser, amountValue);
                                }
                                else
                                {
                                    currency.AddAmount(receiverUser, amountValue);
                                }
                            }
                            else if (inventory != null)
                            {
                                if (this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromSpecificUser || this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromAllChatUsers)
                                {
                                    inventory.SubtractAmount(receiverUser, item, amountValue);
                                }
                                else
                                {
                                    inventory.AddAmount(receiverUser, item, amountValue);
                                }
                            }
                            else if (streamPass != null)
                            {
                                if (this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromSpecificUser || this.CurrencyActionType == CurrencyActionTypeEnum.SubtractFromAllChatUsers)
                                {
                                    streamPass.SubtractAmount(receiverUser, amountValue);
                                }
                                else
                                {
                                    streamPass.AddAmount(receiverUser, amountValue);
                                }
                            }
                        }
                    }
                }
            }
        }