public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false) { if (!StoreIncidentMaker.CheckIfViewerHasEnoughCoins(viewer, this.storeIncident.cost, separateChannel)) { return(false); } if (Current.Game.GetComponent <GameComponentPawns>().HasUserBeenNamed(viewer.username)) { Toolkit.client.SendMessage($"@{viewer.username} you are already in the colony.", separateChannel); return(false); } this.separateChannel = separateChannel; this.viewer = viewer; IIncidentTarget target = Helper.AnyPlayerMap; parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, target); map = (Map)parms.target; bool cell = CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => map.reachability.CanReachColony(c) && !c.Fogged(map), map, CellFinder.EdgeRoadChance_Neutral, out loc); if (!cell) { return(false); } return(true); }
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); }
private static bool TryMakeIncident(StoreIncidentVariables incident, Viewer viewer, string message, out IncidentHelperVariables incidentHelper) { incidentHelper = StoreIncidentMaker.MakeIncidentVariables(incident); if (incidentHelper == null) { return(false); } incidentHelper.Viewer = viewer; incidentHelper.message = message; return(true); }
public static void ResolvePurchaseSimple(Viewer viewer, TwitchIRCMessage message, StoreIncidentSimple incident, bool separateChannel = false) { int cost = incident.cost; if (cost < 1) { return; } if (CheckIfViewerIsInVariableCommandList(viewer.username, separateChannel)) { return; } if (!CheckIfViewerHasEnoughCoins(viewer, cost, separateChannel)) { return; } if (CheckIfKarmaTypeIsMaxed(incident, viewer.username, separateChannel)) { return; } if (CheckIfIncidentIsOnCooldown(incident, viewer.username, separateChannel)) { return; } IncidentHelper helper = StoreIncidentMaker.MakeIncident(incident); if (helper == null) { Helper.Log("Missing helper for incident " + incident.defName); return; } if (!helper.IsPossible()) { Toolkit.client.SendMessage($"@{viewer.username} " + "TwitchToolkitEventNotPossible".Translate(), separateChannel); return; } if (!ToolkitSettings.UnlimitedCoins) { viewer.TakeViewerCoins(cost); } Store_Component component = Current.Game.GetComponent <Store_Component>(); helper.Viewer = viewer; helper.message = message.Message; Ticker.IncidentHelpers.Enqueue(helper); Store_Logger.LogPurchase(viewer.username, message.Message); component.LogIncident(incident); viewer.CalculateNewKarma(incident.karmaType, cost); if (ToolkitSettings.PurchaseConfirmations) { Toolkit.client.SendMessage( Helper.ReplacePlaceholder( "TwitchToolkitEventPurchaseConfirm".Translate(), first: incident.label.CapitalizeFirst(), viewer: viewer.username ), separateChannel ); } }
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); }