Beispiel #1
0
        public override void RunCommand([NotNull] ITwitchMessage message)
        {
            string code = CommandFilter.Parse(message.Message).Skip(1).FirstOrDefault();

            if (code.NullOrEmpty())
            {
                return;
            }

            if (!Data.ColorIndex.TryGetValue(code !.ToLowerInvariant(), out Color color) && !ColorUtility.TryParseHtmlString(code, out color))
            {
                MessageHelper.ReplyToUser(message.Username, "TKUtils.NotAColor".LocalizeKeyed(code));

                return;
            }

            if (!PurchaseHelper.TryGetPawn(message.Username, out Pawn pawn))
            {
                MessageHelper.ReplyToUser(message.Username, "TKUtils.NoPawn".Localize());

                return;
            }

            pawn.story.favoriteColor = new Color(color.r, color.g, color.b, 1f);
            message.Reply("TKUtils.FavoriteColor.Complete".Localize());
        }
Beispiel #2
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize());

                return;
            }

            if (pawn !.IsCaravanMember())
            {
                twitchMessage.Reply("TKUtils.Leave.Caravan".Localize());

                return;
            }

            var component = Current.Game.GetComponent <GameComponentPawns>();

            if (CompatRegistry.Magic?.IsUndead(pawn) ?? false)
            {
                twitchMessage.Reply("TKUtils.Leave.Undead".Localize());
                component?.pawnHistory.Remove(twitchMessage.Username);

                if (pawn.Name is NameTriple name)
                {
                    pawn.Name = new NameTriple(name.First ?? "", name.Last ?? "", name.Last ?? "");
                }

                return;
            }

            ForceLeave(twitchMessage, pawn);
            component.pawnHistory.Remove(twitchMessage.Username);
        }
Beispiel #3
0
        /// <inheritdoc/>
        protected override void ProcessAcceptInternal(string asker, string askee)
        {
            if (!PurchaseHelper.TryGetPawn(asker, out Pawn askerPawn))
            {
                MessageHelper.ReplyToUser(asker, "TKUtils.NoPawn".LocalizeKeyed(asker));

                return;
            }

            if (!PurchaseHelper.TryGetPawn(askee, out Pawn askeePawn))
            {
                MessageHelper.ReplyToUser(asker, "TKUtils.PawnNotFound".LocalizeKeyed(askee));

                return;
            }

            if (!GameHelper.CanPawnsMarry(askerPawn, askeePawn))
            {
                MessageHelper.ReplyToUser(asker, "TKUtils.Marriage.NoSlots".Localize());

                return;
            }

            TkUtils.Context.Post(c => PerformMarriage(askerPawn, askeePawn), null);
        }
Beispiel #4
0
        public override bool CanHappen(string msg, [NotNull] Viewer viewer)
        {
            if (!PurchaseHelper.TryGetPawn(viewer.username, out _pawn))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.NoPawn".Localize());

                return(false);
            }

            var worker = ArgWorker.CreateInstance(CommandFilter.Parse(msg).Skip(2));

            if (!worker.TryGetNextAsItem(out _item) || !_item.IsValid())
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.InvalidItemQuery".LocalizeKeyed(worker.GetLast()));

                return(false);
            }

            if (_item.TryGetError(out string error))
            {
                MessageHelper.ReplyToUser(viewer.username, error);

                return(false);
            }

            if (!(_item.Thing.Thing is { IsWeapon : true }) || _item.Thing.ItemData?.IsEquippable != true)
        public Response OrderData(string token, [FromBody] PurchaseRequest request)
        {
            Response response = new Response();

            if (string.IsNullOrEmpty(token) || !token.Equals(_token))
            {
                response.code = "404";
                response.message = "Invild token";
            }
            else
            {
                var data = PurchaseHelper.GetPurchaseOrderData(request);
                if (data == null)
                {
                    response.code = "500";
                    response.message = "No Data";
                }
                else
                {
                    response.code = "200";
                    response.content = data;
                }
            }
            return response;
        }
Beispiel #6
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize());

                return;
            }

            int totalKills     = pawn !.records.GetAsInt(RecordDefOf.Kills);
            int animalKills    = pawn.records.GetAsInt(RecordDefOf.KillsAnimals);
            int humanLikeKills = pawn.records.GetAsInt(RecordDefOf.KillsHumanlikes);
            int mechanoidKills = pawn.records.GetAsInt(RecordDefOf.KillsMechanoids);

            string container = ResponseHelper.JoinPair("TKUtils.PawnKills.Total".Localize().CapitalizeFirst(), totalKills.ToString("N0"));

            container += ResponseHelper.OuterGroupSeparator;

            container += string.Join(
                ", ",
                ResponseHelper.JoinPair("TKUtils.PawnKills.Humanlike".Localize().CapitalizeFirst(), humanLikeKills.ToString("N0")),
                ResponseHelper.JoinPair("TKUtils.PawnKills.Animals".Localize().CapitalizeFirst(), animalKills.ToString("N0")),
                ResponseHelper.JoinPair("TKUtils.PawnKills.Mechanoids".Localize().CapitalizeFirst(), mechanoidKills.ToString("N0"))
                );


            twitchMessage.Reply(container);
        }
Beispiel #7
0
        public override bool CanHappen(string msg, [NotNull] Viewer viewer)
        {
            if (!PurchaseHelper.TryGetPawn(viewer.username, out _pawn))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.NoPawn".Localize());

                return(false);
            }

            var worker = ArgWorker.CreateInstance(CommandFilter.Parse(msg).Skip(2));

            if (!worker.TryGetNextAsSkill(out SkillDef skillDef))
            {
                return(false);
            }

            _target = _pawn !.skills.skills.Where(s => !s.TotallyDisabled).FirstOrDefault(s => s.def.Equals(skillDef));

            if (_target == null)
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.InvalidSkillQuery".LocalizeKeyed(worker.GetLast()));

                return(false);
            }

            if ((int)_target.passion < 3)
            {
                return(true);
            }

            MessageHelper.ReplyToUser(viewer.username, "TKUtils.Passion.Full".Localize());

            return(false);
        }
        public Response WeeklySupplier(string token, [FromBody] PurchaseRequest request)
        {
            Response response = new Response();

            if (string.IsNullOrEmpty(token) || !token.Equals(_token))
            {
                response.code = "404";
                response.message = "Invild token";
            }
            else
            {
                var data = PurchaseHelper.GetSupplierList(request.companyGuid, request.langCode, request.orderDate, request.warehouseCode, request.costCenterCode, "pricelist");
                if (data == null)
                {
                    response.code = "500";
                    response.message = "No Data";
                }
                else
                {
                    response.code = "200";
                    response.content = data;
                }
            }
            return response;
        }
Beispiel #9
0
        private static void SpawnItem([NotNull] ArgWorker.ItemProxy item)
        {
            Map map = Current.Game.AnyPlayerHomeMap;

            if (map == null)
            {
                return;
            }

            Thing   thing    = PurchaseHelper.MakeThing(item.Thing.Thing, item.Stuff?.Thing, item.Quality);
            IntVec3 position = DropCellFinder.TradeDropSpot(map);

            if (item.Thing.Thing.Minifiable)
            {
                ThingDef minifiedDef   = item.Thing.Thing.minifiedDef;
                var      minifiedThing = (MinifiedThing)ThingMaker.MakeThing(minifiedDef);
                minifiedThing.InnerThing = thing;
                minifiedThing.stackCount = 1;
                PurchaseHelper.SpawnItem(position, map, minifiedThing);
            }
            else
            {
                thing.stackCount = 1;
                PurchaseHelper.SpawnItem(position, map, thing);
            }

            Find.LetterStack.ReceiveLetter("SirRandoo is here", @"SirRandoo has sent you a rare item! Enjoy!", LetterDefOf.PositiveEvent, thing);
        }
Beispiel #10
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize());

                return;
            }

            var parts = new List <string>();
            List <SkillRecord> skills = pawn !.skills.skills;

            foreach (SkillRecord skill in skills)
            {
                var container = "";

                container += ResponseHelper.JoinPair(skill.def.LabelCap, skill.TotallyDisabled ? ResponseHelper.ForbiddenGlyph.AltText("-") : skill.levelInt.ToString());

                container += !Interests.Active
                    ? string.Concat(Enumerable.Repeat(ResponseHelper.FireGlyph.AltText("+"), (int)skill.passion))
                    : Interests.GetIconForPassion(skill);

                parts.Add(container);
            }

            twitchMessage.Reply(parts.SectionJoin().WithHeader("StatsReport_Skills".Localize()));
        }
Beispiel #11
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize());

                return;
            }

            List <string> queries = CommandFilter.Parse(twitchMessage.Message).Skip(1).Select(PurchaseHelper.ToToolkit).ToList();

            if (queries.Count <= 0)
            {
                queries.AddRange(DefaultStats);
            }

            List <StatDef> container = queries.Select(FindStat).Where(s => s != null).ToList();

            if (container.Count <= 0)
            {
                return;
            }

            CommandRouter.MainThreadCommands.Enqueue(
                () =>
            {
                MessageHelper.ReplyToUser(twitchMessage.Username, container.Select(s => FormatStat(pawn, s)).SectionJoin());
            }
                );
        }
Beispiel #12
0
        private void PerformAnimalLookup(string query, int quantity)
        {
            PawnKindDef kindDef = DefDatabase <PawnKindDef> .AllDefs.FirstOrDefault(
                i => i.RaceProps.Animal && (i.label.ToToolkit().EqualsIgnoreCase(query.ToToolkit()) || i.defName.ToToolkit().EqualsIgnoreCase(query.ToToolkit()))
                );

            if (kindDef == null)
            {
                return;
            }

            ThingItem item = Data.Items.FirstOrDefault(i => i.DefName.EqualsIgnoreCase(kindDef.defName));

            if (item == null || item.Cost <= 0)
            {
                return;
            }

            if (!PurchaseHelper.TryMultiply(item.Cost, quantity, out int result))
            {
                MessageHelper.ReplyToUser(_invoker, "TKUtils.Overflowed".Localize());

                return;
            }

            NotifyLookupComplete("TKUtils.Price.Limited".LocalizeKeyed(kindDef.defName.CapitalizeFirst(), result.ToString("N0")));
        }
Beispiel #13
0
        private void PerformItemLookup([NotNull] string query, int quantity)
        {
            var worker = ArgWorker.CreateInstance(query);

            if (!worker.TryGetNextAsItem(out ArgWorker.ItemProxy item) || !item.IsValid() || item.Thing?.Cost <= 0)
            {
                return;
            }

            if (item.TryGetError(out string error))
            {
                MessageHelper.ReplyToUser(_invoker, error);

                return;
            }

            int price = item.Quality.HasValue ? item.Thing !.GetItemPrice(item.Stuff, item.Quality.Value) : item.Thing !.GetItemPrice(item.Stuff);

            if (!PurchaseHelper.TryMultiply(price, quantity, out int total))
            {
                MessageHelper.ReplyToUser(_invoker, "TKUtils.Overflowed".Localize());

                return;
            }

            NotifyLookupComplete("TKUtils.Price.Limited".LocalizeKeyed(item.AsString().CapitalizeFirst(), total.ToString("N0")));
        }
Beispiel #14
0
        public override bool CanHappen(string msg, [NotNull] Viewer viewer)
        {
            if (!PurchaseHelper.TryGetPawn(viewer.username, out _pawn))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.NoPawn".Localize());

                return(false);
            }

            if (IncidentSettings.HealMe.FairFights && _pawn !.mindState.lastAttackTargetTick > 0 && Find.TickManager.TicksGame < _pawn.mindState.lastAttackTargetTick + 1800)
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.InCombat".Localize());

                return(false);
            }

            object result = HealHelper.GetPawnHealable(_pawn !);

            switch (result)
            {
            case Hediff hediff:
                _toHeal = hediff;

                break;

            case BodyPartRecord record:
                _toRestore = record;

                break;
            }

            return(_toHeal != null || _toRestore != null);
        }
Beispiel #15
0
        public override bool CanHappen(string msg, [NotNull] Viewer viewer)
        {
            if (!PurchaseHelper.TryGetPawn(viewer.username, out _pawn))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.NoPawn".Localize());

                return(false);
            }

            if (IncidentSettings.FullHeal.FairFights && _pawn !.mindState.lastAttackTargetTick > 0 &&
                Find.TickManager.TicksGame < _pawn.mindState.lastAttackTargetTick + 1800)
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.InCombat".Localize());

                return(false);
            }

            if (HealHelper.GetPawnHealable(_pawn !) != null)
            {
                return(true);
            }

            MessageHelper.ReplyToUser(viewer.username, "TKUtils.NotInjured".Localize());

            return(false);
        }
Beispiel #16
0
        public override bool CanHappen(string msg, [NotNull] Viewer viewer)
        {
            if (!PurchaseHelper.TryGetPawn(viewer.username, out _pawn))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.NoPawn".Localize());

                return(false);
            }

            var worker = ArgWorker.CreateInstance(CommandFilter.Parse(msg).Skip(2));

            if (!worker.TryGetNextAsTrait(out _thisShop) || !worker.TryGetNextAsTrait(out _thatShop))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.InvalidTraitQuery".LocalizeKeyed(worker.GetLast()));

                return(false);
            }

            if (!IsUsable(_thisShop, _thatShop))
            {
                MessageHelper.ReplyToUser(
                    viewer.username,
                    $"TKUtils.{(_thisShop.CanRemove ? "" : "Remove")}Trait.Disabled".LocalizeKeyed((_thisShop.CanRemove ? _thatShop : _thisShop).Name.CapitalizeFirst())
                    );

                return(false);
            }

            if (TraitHelper.GetTotalTraits(_pawn) >= AddTraitSettings.maxTraits && WouldExceedLimit())
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.ReplaceTrait.Violation".LocalizeKeyed(_thisShop.Name, _thatShop.Name));

                return(false);
            }

            if (!viewer.CanAfford(TotalPrice))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.InsufficientBalance".LocalizeKeyed(TotalPrice.ToString("N0"), viewer.GetViewerCoins().ToString("N0")));

                return(false);
            }

            if (!PassesCharacterCheck(viewer))
            {
                return(false);
            }

            if (!PassesModCheck(viewer))
            {
                return(false);
            }

            if (!PassesValidationCheck(viewer))
            {
                return(false);
            }

            return(true);
        }
 public static PurchaseHelper Instance()
 {
     if (m_instance == null)
     {
         m_instance = new PurchaseHelper();
     }
     return(m_instance);
 }
    void OnOrderRet(string strMsg)
    {
        int    nStatus      = -1;
        int    nTradeStatus = -1;
        string strSpsn      = new string('\0', 5);

        StrParse(strMsg, out nStatus, out nTradeStatus, out strSpsn);

        //TODO
        Debug.Log("------OnOrderRet strMsg=" + strMsg + " strSpsn=" + strSpsn);

        /*
         * //畅游支付,存单
         * {
         *  string strAccountid, strgpg;
         *  GlobalSave.GetCyouStoreLossGoodInfoTemp(out strAccountid, out strgpg);
         *  if( strAccountid != null &&
         *      strgpg  != null
         *      )
         *  {
         *      Debug.Log("pllog_Cyou_strAccountid:"+strAccountid);
         *      Debug.Log("pllog_Cyou_strgpg:"+strgpg);
         *
         *      int s32Accountid        = Convert.ToInt32(strAccountid);
         *      int s32SelfAccountid    = Convert.ToInt32(Obj_MyselfPlayer.GetMe().accountID);
         *
         *      if(s32Accountid == s32SelfAccountid)
         *      {
         *          string[] info_gid_pid_gprice = strgpg.Split('|');
         *          string gid = info_gid_pid_gprice[0];
         *          string pid = info_gid_pid_gprice[1];
         *          string gprice = info_gid_pid_gprice[2];
         *
         *          Debug.Log("pllog_Cyou_gid:"+gid);
         *          Debug.Log("pllog_Cyou_pid:"+pid);
         *          Debug.Log("pllog_Cyou_gprice:"+gprice);
         *
         *          JsonData cydata     = new JsonData();
         *          cydata["ACC"]       = Obj_MyselfPlayer.GetMe().accountID;
         *          cydata["OID"]       = strSpsn;//畅游渠道的订单号是由sdk自己生成的,在这里第一次从java中传出
         *          cydata["GID"]       = gid;
         *          cydata["PID"]       = pid;
         *          cydata["PPRICE"]    = gprice;
         *          cydata["PNAME"]     = "CYProduct";
         *
         *          WebMediator.SavePayLog(cydata.ToJson());
         *          Debug.Log("pllog_Cyou_SavePayLog:"+cydata.ToJson());
         *      }
         *
         *  }
         *  GlobalSave.SOrder order = PurchaseHelper.Instance().CheckOrder();
         * }
         */
        // 订单记录
        PurchaseHelper.Instance().AddCyouOrder(strSpsn);
        //GlobalSave.AddCyouStoreLossOrder(strSpsn, Obj_MyselfPlayer.GetMe().accountID); // 这里先行设置如果掉单,的单号
        GlobalSave.SetCyouStoreLossGoodInfoTempToReal(strSpsn, Obj_MyselfPlayer.GetMe().accountID); // 将保存的临时信息转成正式信息
    }
Beispiel #19
0
 public void RefreshUI(bool bNeedMsgBox)
 {
     if (!PurchaseHelper.Instance().BeginCheckOrder(OnFinishCheckOrder))
     {
         RequestGoodsList(bNeedMsgBox);
     }
     //refreash top user info
     GameObject.FindWithTag("main_controller").SendMessage("updateUserInfo");
 }
Beispiel #20
0
        private static OPCH_Purchase SyncUpload(OPCH_Purchase purchase)
        {
            var result = WebApiClient.AddPurchase(purchase).Result;

            purchase.UpdateModelPropertiesFrom(result.Model);
            purchase.StateL = LocalStatus.Procesado;
            result.UpdateEntityVersion();
            PurchaseHelper.SaveTransaction(purchase);
            return(purchase);
        }
    private void pplog_update()
    {
        JsonData jd = GlobalSave.GetOrderTable();

        if (jd != null)
        {
            int num = jd.Count;
            Debug.Log("pllog_update num=" + num);
            Debug.Log("pllog_update begin LastSendIdx=" + LastSendIdx);

            if (LastSendIdx >= num)
            {
                LastSendIdx = 0;
            }
            for (int i = LastSendIdx; i < num; i++)
            {
                if (jd[i] != null)
                {
                    if (jd[i]["accountID"] != null)
                    {
                        string orderacc     = (string)jd[i]["accountID"];
                        int    orderaccint  = Convert.ToInt32(orderacc);
                        int    accountIDint = Convert.ToInt32(Obj_MyselfPlayer.GetMe().accountID);

                        if (orderaccint != accountIDint)
                        {
                            Debug.Log("pllog_Not_Self");
                            //不是自己的单
                            continue;
                        }
                        else
                        {
                            Debug.Log("pllog_Update_SendVarify :" + JsonMapper.ToJson(jd[i]));
                            // 补提订单.处理丢单情况
                            PurchaseHelper.Instance().VarifyJavaOrder((string)jd[i]["gid"],
                                                                      (string)jd[i]["pid"],
                                                                      (string)jd[i]["goodsPrice"],
                                                                      (string)jd[i]["orderId"]
                                                                      );
                            LastSendIdx++;
                            Debug.Log("pllog_update mid LastSendIdx=" + LastSendIdx);

                            if (LastSendIdx >= num)
                            {
                                LastSendIdx = 0;
                            }
                            Debug.Log("pllog_update end LastSendIdx=" + LastSendIdx);
                            //晕,一个逻辑帧只发一个包,在收到反馈包之前不能发第二个,所以发包不能太快。
                            break;
                        }
                    }
                }
            }
        }
    }
Beispiel #22
0
        private static void GetPurchaseFromServer(LOG_CHANGES changeset)
        {
            var purchase = WebApiClient.GetPurchase(changeset.ListVal).Result;

            var db = ContextFactory.GetDBContext();

            var id = Convert.ToInt32(changeset.ListVal);

            var localId = db.OPCH_Purchase.Include(c => c.PCH1_PurchaseDetail)
                          .FirstOrDefault(c => c.IdPurchase == changeset.IdL.Value);

            var localDE = db.OPCH_Purchase.Include(c => c.PCH1_PurchaseDetail)
                          .FirstOrDefault(c => c.DocEntry == id);

            if (changeset.IdL.HasValue) // C1
            {
                if (localId == null)    // C3
                {
                    db.OPCH_Purchase.Add(purchase);
                    PurchaseHelper.SaveTransaction(purchase);
                }
                else
                {
                    if (localId.StateL == LocalStatus.Procesado)                     // C4
                    {
                        if (localDE == null || localDE.DocEntry != localId.DocEntry) // C5
                        {
                            db.OPCH_Purchase.Add(purchase);
                            PurchaseHelper.SaveTransaction(purchase);
                        }
                        else
                        {
                            localId.UpdateModelPropertiesFrom(purchase);
                        }
                    }
                    else
                    {
                        localId.UpdateModelPropertiesFrom(purchase);
                        PurchaseHelper.SaveTransaction(purchase);
                    }
                }
            }
            else //  C2 -- El Idl no contenia un valor
            {
                if (localDE == null)
                {
                    db.OPCH_Purchase.Add(purchase);
                    PurchaseHelper.SaveTransaction(purchase);
                }
            }

            // db.LOG_CHANGES.Add(changeset);
            changeset.AddChangeset();
        }
Beispiel #23
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize().WithHeader("TabGear".Localize()));

                return;
            }

            twitchMessage.Reply(GetPawnGear(pawn).WithHeader("TabGear".Localize()));
        }
Beispiel #24
0
        public string GetSkillDescription(string invoker, string query)
        {
            if (!PurchaseHelper.TryGetPawn(invoker, out Pawn pawn))
            {
                return("TKUtils.NoPawn".Localize());
            }

            var builder   = new StringBuilder();
            var userMagic = pawn.TryGetComp <CompAbilityUserMagic>();

            if (userMagic is { IsMagicUser : true } && TryGetMagicDescription(userMagic, query.ToToolkit(), out string description))
Beispiel #25
0
 public static OPCH_Purchase Synchronize(OPCH_Purchase model)
 {
     CheckForUpdates();// Actualizar cambios antes de subir y verificar si el objeto no fue ya procesado
     model = PurchaseHelper.Get(model.IdPurchase);
     if (model.StateL != LocalStatus.Procesado)
     {
         return(model.Upload(SyncUpload));
     }
     else
     {
         return(model);
     }
 }
        //-------------------------------------------------------------------------------------[]
        private void CreatePlayerAndShopmanAndOpenSecondScreen(RaceNameEnum raceName)
        {
            _chooseRaceComponent.enabled = false;

            _player = new Player(
                raceName,
                _gameSettingsComponent.PlayerGold,
                _gameSettingsComponent.PlayerLevel,
                _gameSettingsComponent.PlayerHasVipAccount);

            _shopman = new Shopman(GetCurrentItems());

            _purchaseHelper = new PurchaseHelper();

            _storeComponent.enabled = true;
        }
Beispiel #27
0
        public override bool CanHappen(string msg, [NotNull] Viewer viewer)
        {
            if (!PurchaseHelper.TryGetPawn(viewer.username, out _pawn))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.NoPawn".Localize());

                return(false);
            }

            if (!Immortals.Active)
            {
                return(false);
            }

            return(!_pawn !.health.hediffSet.HasHediff(Immortals.ImmortalHediffDef));
        }
Beispiel #28
0
        public override bool CanHappen(string msg, [NotNull] Viewer viewer)
        {
            if (!PurchaseHelper.TryGetPawn(viewer.username, out _pawn))
            {
                MessageHelper.ReplyToUser(viewer.username, "TKUtils.NoPawn".Localize());

                return(false);
            }

            _backstory = BackstoryDatabase.allBackstories.Values.Where(b => b.slot == BackstorySlot.Adulthood)
                         .Where(b => !WouldBeViolation(b))
                         .InRandomOrder()
                         .FirstOrDefault();

            return(_backstory != null);
        }
Beispiel #29
0
        private void SpawnItem()
        {
            ThingDef result = Proxy.Stuff?.Thing;

            if (!Proxy.Thing.Thing.CanBeStuff(Proxy.Stuff?.Thing))
            {
                var stuffs = new List <ThingDef>();

                foreach (ThingDef possible in GenStuff.AllowedStuffsFor(Proxy.Thing.Thing))
                {
                    if (!Data.ItemData.TryGetValue(possible.defName, out ItemData data) || !data.IsStuffAllowed)
                    {
                        continue;
                    }

                    stuffs.Add(possible);
                }

                result = !stuffs.TryRandomElementByWeight(s => s.stuffProps.commonality, out ThingDef stuff)
                    ? GenStuff.RandomStuffByCommonalityFor(Proxy.Thing.Thing)
                    : stuff;
            }

            Thing   thing    = PurchaseHelper.MakeThing(Proxy.Thing.Thing, result, Proxy.Quality);
            IntVec3 position = DropCellFinder.TradeDropSpot(Map);

            if (Proxy.Thing.Thing.Minifiable)
            {
                ThingDef minifiedDef   = Proxy.Thing.Thing.minifiedDef;
                var      minifiedThing = (MinifiedThing)ThingMaker.MakeThing(minifiedDef);
                minifiedThing.InnerThing = thing;
                minifiedThing.stackCount = Quantity;
                PurchaseHelper.SpawnItem(position, Map, minifiedThing);
            }
            else
            {
                thing.stackCount = Quantity;
                PurchaseHelper.SpawnItem(position, Map, thing);
            }

            Find.LetterStack.ReceiveLetter(
                (Quantity > 1 ? Proxy.Thing.Name.Pluralize() : Proxy.Thing.Name).Truncate(15, true).CapitalizeFirst(),
                "TKUtils.ItemLetter.ItemDescription".LocalizeKeyed(Quantity.ToString("N0"), Proxy.AsString(Quantity > 1), Purchaser.username),
                ItemHelper.GetLetterFromValue(Price),
                thing
                );
        }
Beispiel #30
0
        public override void RunCommand([NotNull] ITwitchMessage twitchMessage)
        {
            if (!PurchaseHelper.TryGetPawn(twitchMessage.Username, out Pawn pawn))
            {
                twitchMessage.Reply("TKUtils.NoPawn".Localize().WithHeader("TKUtils.PawnWork.Header".Localize()));

                return;
            }

            if (pawn !.workSettings?.EverWork == false)
            {
                twitchMessage.Reply("TKUtils.PawnWork.None".Localize().WithHeader("TKUtils.PawnWork.Header".Localize()));

                return;
            }

            List <KeyValuePair <string, string> > newPriorities = CommandParser.ParseKeyed(twitchMessage.Message);

            if (!newPriorities.NullOrEmpty())
            {
                var builder = new StringBuilder();

                foreach (string change in ProcessChangeRequests(pawn, newPriorities))
                {
                    builder.Append(change);
                    builder.Append(", ");
                }

                if (builder.Length > 0)
                {
                    builder.Remove(builder.Length - 2, 2);
                    twitchMessage.Reply("TKUtils.PawnWork.Changed".LocalizeKeyed(builder.ToString()));

                    return;
                }
            }

            string summary = GetWorkPrioritySummary(pawn);

            if (summary.NullOrEmpty())
            {
                return;
            }

            twitchMessage.Reply(summary.WithHeader("TKUtils.PawnWork.Header".Localize()));
        }