示例#1
0
        public async Task SellItem(List <string> items, bool sellAll, Requirement requirement)
        {
            var body = new SellFleaItemRequest
            {
                data = new List <SellItemRequest>
                {
                    new SellItemRequest
                    {
                        Action         = "RagFairAddOffer",
                        sellInOnePiece = sellAll,
                        items          = items,
                        requirements   = new List <SellRequirement> {
                            new SellRequirement
                            {
                                _tpl           = requirement._tpl,
                                count          = requirement.count,
                                level          = 0,
                                side           = 0,
                                onlyFunctional = false
                            }
                        }
                    }
                },
                tm = 2
            };
            string response = await PostJson <string>($"{PROD_ENDPOINT}/client/game/profile/items/moving", JsonConvert.SerializeObject(body));

            Logger.Log($"Sell:\n {response}", LoggingLevel.Verbose);
        }
示例#2
0
        public async Task <SellStatus> SellItem(List <string> items, bool sellAll, Requirement requirement)
        {
            var body = new SellFleaItemRequest
            {
                data = new List <SellItemRequest>
                {
                    new SellItemRequest
                    {
                        Action         = "RagFairAddOffer",
                        sellInOnePiece = sellAll,
                        items          = items,
                        requirements   = new List <SellRequirement> {
                            new SellRequirement
                            {
                                _tpl           = requirement._tpl,
                                count          = requirement.count,
                                level          = 0,
                                side           = 0,
                                onlyFunctional = false
                            }
                        }
                    }
                },
                tm = 2
            };
            var response = await PostJson <Response>($"{PROD_ENDPOINT}/client/game/profile/items/moving", JsonConvert.SerializeObject(body));

            if (response == default(Response))
            {
                return(SellStatus.BackendError);
            }
            if (response.err != 0)
            {
                Logger.Log($"[SELL] error {response.errmsg}", LoggingLevel.Verbose);
                if (response.errmsg.Contains("max offer"))
                {
                    return(SellStatus.NoAvailableOffer);
                }
                if (response.errmsg.Contains("pay the tax"))
                {
                    return(SellStatus.NoMoneyForTax);
                }
                return(SellStatus.OtherErr);
            }
            else
            {
                Logger.Log($"[SELL]:\n {response.data.ToString()}", LoggingLevel.Verbose);
                return(SellStatus.Success);
            }
        }