Example #1
0
        public override void TryExecute()
        {
            pawn.story.traits.GainTrait(trait);

            TraitDegreeData traitDegreeData = traitDef.DataAtDegree(buyableTrait.degree);

            if (traitDegreeData != null)
            {
                if (traitDegreeData.skillGains != null)
                {
                    foreach (KeyValuePair <SkillDef, int> pair in traitDegreeData.skillGains)
                    {
                        SkillRecord skill = pawn.skills.GetSkill(pair.Key);
                        int         num   = TraitHelpers.FinalLevelOfSkill(pawn, pair.Key);
                        skill.Level = num;
                    }
                }
            }

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);
            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} just added the trait " + trait.Label + " to " + pawn.Name + ".");
            string text = $"{Viewer.username} has purchased " + trait.LabelCap + " for " + pawn.Name + ".";

            Current.Game.letterStack.ReceiveLetter("Trait", text, LetterDefOf.PositiveEvent, pawn);
        }
Example #2
0
        public override void TryExecute()
        {
            Trait traitToRemove = pawn.story.traits.allTraits.Find(s => s.def.defName == buyableTrait.def.defName);

            if (traitToRemove != null)
            {
                pawn.story.traits.allTraits.Remove(traitToRemove);

                TraitDegreeData traitDegreeData = traitToRemove.def.DataAtDegree(buyableTrait.degree);

                if (traitDegreeData != null)
                {
                    if (traitDegreeData.skillGains != null)
                    {
                        foreach (KeyValuePair <SkillDef, int> pair in traitDegreeData.skillGains)
                        {
                            SkillRecord skill = pawn.skills.GetSkill(pair.Key);
                            skill.Level -= pair.Value;
                        }
                    }
                }
            }
            else
            {
                return;
            }
            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);
            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} just removed the trait " + buyableTrait.label.CapitalizeFirst() + " from " + pawn.Name + ".");
            string text = $"{Viewer.username} has purchased trait removal of " + buyableTrait.label.CapitalizeFirst() + " from " + pawn.Name + ".";

            Current.Game.letterStack.ReceiveLetter("Trait", text, LetterDefOf.PositiveEvent, pawn);
        }
        public override void TryExecute()
        {
            if (pawn.gender == Gender.Female)
            {
                pawn.gender = Gender.Male;
            }
            else
            {
                pawn.gender = Gender.Female;
            }

            pawn.story.hairColor = PawnHairColors.RandomHairColor(pawn.story.SkinColor, pawn.ageTracker.AgeBiologicalYears);
            pawn.story.hairDef   = PawnHairChooser.RandomHairDefFor(pawn, FactionDefOf.PlayerColony);

            if (pawn.story.adulthood != null)
            {
                pawn.story.bodyType = pawn.story.adulthood.BodyTypeFor(pawn.gender);
            }
            else if (Rand.Value < 0.5f)
            {
                pawn.story.bodyType = BodyTypeDefOf.Thin;
            }
            else
            {
                pawn.story.bodyType = ((pawn.gender != Gender.Female) ? BodyTypeDefOf.Male : BodyTypeDefOf.Female);
            }

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);
            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} has just swapped genders to " + pawn.gender.GetLabel() + ".");
            string text = $"{Viewer.username} has just swapped genders to " + pawn.gender.GetLabel() + ".";

            Current.Game.letterStack.ReceiveLetter("GenderSwap", text, LetterDefOf.PositiveEvent, pawn);
        }
        public override void TryExecute()
        {
            float customMultiplier = LevelPawnSettings.xpMultiplier > 0 ? LevelPawnSettings.xpMultiplier : 0.5f;
            float xpWon            = pawn.skills.GetSkill(skill).XpRequiredForLevelUp *customMultiplier *((float)Verse.Rand.Range(0.5f, 1.5f));

            xpWon = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, xpWon);

            pawn.skills.Learn(skill, xpWon, true);
            Viewer.TakeViewerCoins(pointsWager);
            Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);

            SkillRecord record       = pawn.skills.GetSkill(skill);
            string      increaseText = $" Level {record.levelInt}: {(int)record.xpSinceLastLevel} / {(int)record.XpRequiredForLevelUp}.";

            float   percent     = 35;
            string  passionPlus = "";
            Passion passion     = record.passion;

            if (passion == Passion.Minor)
            {
                percent     = 100;
                passionPlus = "+";
            }
            if (passion == Passion.Major)
            {
                percent     = 150;
                passionPlus = "++";
            }

            VariablesHelpers.SendPurchaseMessage($"Increasing skill {skill.LabelCap} for {pawn.LabelCap} with {pointsWager} coins wagered and ({(int)xpWon} * {percent}%){passionPlus} {(int)xpWon * (percent / 100f)} xp purchased by {Viewer.username}. {increaseText}");
            string text = Helper.ReplacePlaceholder("TwitchStoriesDescription55".Translate(), colonist: pawn.Name.ToString(), skill: skill.defName, first: Math.Round(xpWon).ToString());

            Current.Game.letterStack.ReceiveLetter("TwitchToolkitIncreaseSkill".Translate(), text, LetterDefOf.PositiveEvent, pawn);
        }
        public override void TryExecute()
        {
            worker.TryExecute(parms);

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} is being held prisoner at another faction.");
        }
Example #6
0
        public static void Charge([NotNull] this Viewer viewer, [NotNull] StoreIncident incident, float weight)
        {
            if (!ToolkitSettings.UnlimitedCoins)
            {
                viewer.TakeViewerCoins(incident.cost);
            }

            viewer.CalculateNewKarma(incident.karmaType, Mathf.CeilToInt(incident.cost * weight));
        }
Example #7
0
        public static void Charge([NotNull] this Viewer viewer, [NotNull] StoreIncident incident)
        {
            if (!ToolkitSettings.UnlimitedCoins)
            {
                viewer.TakeViewerCoins(incident.cost);
            }

            viewer.CalculateNewKarma(incident.karmaType, incident.cost);
        }
Example #8
0
        public static void Charge([NotNull] this Viewer viewer, int cost, KarmaType karmaType)
        {
            if (!ToolkitSettings.UnlimitedCoins)
            {
                viewer.TakeViewerCoins(cost);
            }

            viewer.CalculateNewKarma(karmaType, cost);
        }
        public override void TryExecute()
        {
            worker.TryExecute(parms);

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} has escaped from maximum security space prison.");
        }
        public override void TryExecute()
        {
            worker.TryExecute(parms);

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} is visiting the colony.");
        }
Example #11
0
        public static void Charge([NotNull] this Viewer viewer, int cost, float weight, KarmaType karmaType)
        {
            if (!ToolkitSettings.UnlimitedCoins)
            {
                viewer.TakeViewerCoins(cost);
            }

            viewer.CalculateNewKarma(karmaType, Mathf.CeilToInt(cost * weight));
        }
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         Viewer.TakeViewerCoins(pointsWager);
         Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Starting predator pack with {pointsWager} points wagered and {(int)parms.points} raid points purchased by {Viewer.username}");
         return;
     }
     TwitchWrapper.SendChatMessage($"@{Viewer.username} could not generate parms for manhunter pack.");
 }
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         Viewer.TakeViewerCoins(pointsWager);
         Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Starting {worker.def.LabelCap} with {pointsWager} points wagered and {(int)parms.points} disease points purchased by {Viewer.username}", separateChannel);
         return;
     }
     Toolkit.client.SendMessage($"@{Viewer.username} not enough points spent for diseases.", separateChannel);
 }
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         Viewer.TakeViewerCoins(pointsWager);
         Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Spawning animal {pawnKind.LabelCap} with {pointsWager} coins wagered and {(int)parms.points} animal points purchased by {Viewer.username}");
         return;
     }
     TwitchWrapper.SendChatMessage($"@{Viewer.username} not enough points spent for diseases.");
 }
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         Viewer.TakeViewerCoins(pointsWager);
         Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Starting raid with {pointsWager} points wagered and {(int)parms.points} raid points purchased by {Viewer.username}", separateChannel);
         return;
     }
     Toolkit.client.SendMessage($"@{Viewer.username} could not generate parms for raid.", separateChannel);
 }
        public override void TryExecute()
        {
            // take actions for incident
            List <Pawn> pawns = Helper.AnyPlayerMap.mapPawns.FreeColonistsSpawned.ToList();

            pawns.Shuffle();

            bool           successfulInspiration = false;
            InspirationDef randomAvailableInspirationDef;

            foreach (Pawn pawn in pawns)
            {
                if (pawn.Inspired)
                {
                    continue;
                }

                randomAvailableInspirationDef = (
                    from x in DefDatabase <InspirationDef> .AllDefsListForReading
                    where true
                    select x).RandomElementByWeightWithFallback((InspirationDef x) => x.Worker.CommonalityFor(pawn), null
                                                                );

                if (randomAvailableInspirationDef != null)
                {
                    successfulInspiration = pawn.mindState.inspirationHandler.TryStartInspiration(randomAvailableInspirationDef);
                    if (successfulInspiration)
                    {
                        break;
                    }
                }
            }

            if (successfulInspiration)
            {
                Viewer.TakeViewerCoins(storeIncident.cost);

                // calculate new karma if needed
                Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

                // send a purchase confirmation message
                VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} purchased a random inspiration.");
            }
            else
            {
                VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} attempted to inspired a pawn, but none were successful.");
            }
        }
Example #17
0
        public override void TryExecute()
        {
            Map map = Helper.AnyPlayerMap;
            StorytellerComp_HodlBot storytellerComp = new StorytellerComp_HodlBot();

            storytellerComp.forced = true;
            foreach (FiringIncident incident in storytellerComp.MakeIntervalIncidents(map))
            {
                Ticker.FiringIncidents.Enqueue(incident);
                break;
            }

            Viewer.TakeViewerCoins(storeIncident.cost);

            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} purchased a HodlBot Vote.");
        }
Example #18
0
        public override void Execute()
        {
            if (_worker.TryExecute(_params))
            {
                Viewer.TakeViewerCoins(_data.UseStoryteller ? storeIncident.cost : _wager);
                Viewer.CalculateNewKarma(storeIncident.karmaType, _wager);

                string name   = storeIncident.label ?? storeIncident.abbreviation;
                var    points = _params.points.ToString("N3");

                MessageHelper.ReplyToUser(
                    Viewer.username,
                    _data.UseStoryteller
                        ? "TKUtils.Wagered.Storyteller".LocalizeKeyed(name, points)
                        : "TKUtils.Wagered.Complete".LocalizeKeyed(name, _wager.ToString("N0"), points)
                    );

                return;
            }

            MessageHelper.ReplyToUser(Viewer.username, "TKUtils.FailedParms".LocalizeKeyed(storeIncident.label ?? storeIncident.abbreviation));
        }
        public override void TryExecute()
        {
            PawnKindDef           pawnKind = PawnKindDefOf.Colonist;
            Faction               ofPlayer = Faction.OfPlayer;
            bool                  pawnMustBeCapableOfViolence = true;
            PawnGenerationRequest request = new PawnGenerationRequest(pawnKind, ofPlayer, PawnGenerationContext.NonPlayer, map.Tile, false, false, false, false, true, pawnMustBeCapableOfViolence, 1f, false, true, true, true, false, false, false, false, 0f, null, 1f, null, null, null, null, null, null, null, null, null, null, null, null);
            Pawn                  pawn    = PawnGenerator.GeneratePawn(request);
            NameTriple            old     = pawn.Name as NameTriple;

            pawn.Name = new NameTriple(old.First, Viewer.username, old.Last);
            GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
            TaggedString label = "Viewer Joins";
            TaggedString text  = $"A new pawn has been purchased by {Viewer.username}, let's welcome them to the colony.";

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.PositiveEvent, pawn, null, null);

            Current.Game.GetComponent <GameComponentPawns>().AssignUserToPawn(Viewer.username, pawn);
            Viewer.TakeViewerCoins(this.storeIncident.cost);
            Viewer.CalculateNewKarma(this.storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} has purchased a pawn and is joining the colony.");
        }
Example #20
0
        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
                    );
            }
        }
 private void EndCarePackage()
 {
     Viewer.TakeViewerCoins(price);
     Viewer.CalculateNewKarma(storeIncident.karmaType, price);
     VariablesHelpers.SendPurchaseMessage(Helper.ReplacePlaceholder("TwitchToolkitItemPurchaseConfirm".Translate(), amount: quantity.ToString(), item: item.abr, viewer: Viewer.username));
 }