Пример #1
0
        private static uint CreateMerchantObject(string sellerPlayerId, PlayerStore dbPlayerStore)
        {
            const string StoreResref = "player_store";
            var          merchant    = CreateObject(ObjectType.Store, StoreResref, GetLocation(OBJECT_SELF));

            SetLocalString(merchant, "SELLER_PLAYER_ID", sellerPlayerId);

            foreach (var item in dbPlayerStore.ItemsForSale)
            {
                if (item.Value.Price <= 0)
                {
                    continue;
                }

                var deserialized = Object.Deserialize(item.Value.Data);
                Object.AcquireItem(merchant, deserialized);

                var originalBaseGPValue       = Core.NWNX.Item.GetBaseGoldPieceValue(deserialized);
                var originalAdditionalGPValue = Core.NWNX.Item.GetAddGoldPieceValue(deserialized);

                SetLocalInt(deserialized, "ORIGINAL_BASE_GP_VALUE", originalBaseGPValue);
                SetLocalInt(deserialized, "ORIGINAL_ADDITIONAL_GP_VALUE", originalAdditionalGPValue);

                Core.NWNX.Item.SetBaseGoldPieceValue(deserialized, item.Value.Price);
                Core.NWNX.Item.SetAddGoldPieceValue(deserialized, 0);
            }

            return(merchant);
        }
Пример #2
0
        private void ListingInit(DialogPage page)
        {
            var player        = GetPC();
            var playerId      = GetObjectUUID(player);
            var dbPlayerStore = DB.Get <PlayerStore>(playerId);
            var model         = GetDataModel <Model>();
            var item          = dbPlayerStore.ItemsForSale[model.SelectedItemId];

            void AdjustPrice(int amount)
            {
                item.Price += amount;

                if (item.Price <= 0)
                {
                    item.Price = 1;
                }
                else if (item.Price > 999999)
                {
                    item.Price = 999999;
                }

                DB.Set(playerId, dbPlayerStore);
                PlayerMarket.UpdateCacheEntry(playerId, dbPlayerStore);
            }

            page.Header = ColorToken.Green("Item: ") + item.StackSize + "x " + item.Name + "\n" +
                          ColorToken.Green("Price: ") + item.Price + "\n\n" +
                          "Please select an option.";

            if (model.IsConfirmingRemoveItem)
            {
                page.AddResponse(ColorToken.Red("CONFIRM REMOVE ITEM"), () =>
                {
                    var inWorldItem = Object.Deserialize(item.Data);
                    Object.AcquireItem(player, inWorldItem);
                    dbPlayerStore.ItemsForSale.Remove(model.SelectedItemId);

                    DB.Set(playerId, dbPlayerStore);
                    PlayerMarket.UpdateCacheEntry(playerId, dbPlayerStore);

                    ChangePage(EditItemListPageId, false);
                    model.IsConfirmingRemoveItem = false;
                });
            }
            else
            {
                page.AddResponse(ColorToken.Red("Remove Item"), () =>
                {
                    model.IsConfirmingRemoveItem = true;
                });
            }

            page.AddResponse("Increase by 10,000 gil", () =>
            {
                AdjustPrice(10000);
            });
            page.AddResponse("Increase by 1,000 gil", () =>
            {
                AdjustPrice(1000);
            });
            page.AddResponse("Increase by 100 gil", () =>
            {
                AdjustPrice(100);
            });
            page.AddResponse("Increase by 10 gil", () =>
            {
                AdjustPrice(10);
            });
            page.AddResponse("Increase by 1 gil", () =>
            {
                AdjustPrice(1);
            });

            page.AddResponse("Decrease by 10,000 gil", () =>
            {
                AdjustPrice(-10000);
            });
            page.AddResponse("Decrease by 1,000 gil", () =>
            {
                AdjustPrice(-1000);
            });
            page.AddResponse("Decrease by 100 gil", () =>
            {
                AdjustPrice(-100);
            });
            page.AddResponse("Decrease by 10 gil", () =>
            {
                AdjustPrice(-10);
            });
            page.AddResponse("Decrease by 1 gil", () =>
            {
                AdjustPrice(-1);
            });
        }