コード例 #1
0
        public static void ResolvePurchaseVariables(Viewer viewer, IRCMessage message, StoreIncidentVariables incident, bool separateChannel = false)
        {
            int cost = incident.cost;

            if (cost < 1 && incident.defName != "Item")
            {
                return;
            }

            if (CheckIfViewerIsInVariableCommandList(viewer.username, separateChannel))
            {
                return;
            }

            if (!CheckIfViewerHasEnoughCoins(viewer, cost, separateChannel))
            {
                return;
            }

            if (CheckIfKarmaTypeIsMaxed(incident.karmaType, viewer.username, separateChannel))
            {
                return;
            }

            if (CheckIfIncidentIsOnCooldown(incident, viewer.username, separateChannel))
            {
                return;
            }

            viewerNamesDoingVariableCommands.Add(viewer.username);

            IncidentHelperVariables helper = StoreIncidentMaker.MakeIncidentVariables(incident);

            if (helper == null)
            {
                Log.Warning("Missing helper for incident " + incident.defName);
                return;
            }

            if (!helper.IsPossible(message.Message, viewer, separateChannel))
            {
                if (viewerNamesDoingVariableCommands.Contains(viewer.username))
                {
                    viewerNamesDoingVariableCommands.Remove(viewer.username);
                }
                return;
            }

            Store_Component component = Current.Game.GetComponent <Store_Component>();

            QueuePlayerMessage(viewer, message.Message, incident.variables);

            Ticker.IncidentHelperVariables.Enqueue(helper);
            Store_Logger.LogPurchase(viewer.username, message.Message);
            component.LogIncident(incident);
        }
コード例 #2
0
        public static void ResolvePurchaseVariables(Viewer viewer, ITwitchMessage twitchMessage, StoreIncidentVariables incident, string formattedMessage, bool separateChannel = false)
        {
            int cost = incident.cost;

            if (cost < 1 && incident.defName != "Item")
            {
                return;
            }

            if (CheckIfViewerIsInVariableCommandList(viewer.username))
            {
                return;
            }

            if (!CheckIfViewerHasEnoughCoins(viewer, cost))
            {
                return;
            }

            if (incident != DefDatabase <StoreIncidentVariables> .GetNamed("Item"))
            {
                if (CheckIfKarmaTypeIsMaxed(incident, viewer.username))
                {
                    return;
                }
            }
            else
            {
                if (CheckIfCarePackageIsOnCooldown(viewer.username))
                {
                    return;
                }
            }

            if (CheckIfIncidentIsOnCooldown(incident, viewer.username))
            {
                return;
            }

            viewerNamesDoingVariableCommands.Add(viewer.username);

            IncidentHelperVariables helper = StoreIncidentMaker.MakeIncidentVariables(incident);

            if (helper == null)
            {
                Helper.Log("Missing helper for incident " + incident.defName);
                return;
            }

            if (!helper.IsPossible(formattedMessage, viewer))
            {
                if (viewerNamesDoingVariableCommands.Contains(viewer.username))
                {
                    viewerNamesDoingVariableCommands.Remove(viewer.username);
                }
                return;
            }

            Store_Component component = Current.Game.GetComponent <Store_Component>();

            helper.Viewer  = viewer;
            helper.message = formattedMessage;

            Ticker.IncidentHelperVariables.Enqueue(helper);
            Store_Logger.LogPurchase(viewer.username, twitchMessage.Message);
            component.LogIncident(incident);
        }