Argument for registering amount of bought items
@screen.trade(storeData {itemID,amount,price}{...},canBuy [bool],canSell [bool],currencyIndicator [str],shopIdentifier [str]) shopIdentifier is the value to register to (e.g. if the shopIdentifier = apple then it will register apple_110 if you bought item 110 (pearl) from that shop)
This commit is contained in:
parent
4de02d4b67
commit
2e26b2d0c8
|
@ -127,6 +127,7 @@ Public Class TradeScreen
|
||||||
Private CanBuyItems As Boolean = True
|
Private CanBuyItems As Boolean = True
|
||||||
Private CanSellItems As Boolean = True
|
Private CanSellItems As Boolean = True
|
||||||
Private Currency As Currencies = Currencies.Pokédollar
|
Private Currency As Currencies = Currencies.Pokédollar
|
||||||
|
Private ShopIdentifier As String = ""
|
||||||
|
|
||||||
Dim texture As Texture2D
|
Dim texture As Texture2D
|
||||||
Dim TileOffset As Integer = 0
|
Dim TileOffset As Integer = 0
|
||||||
|
@ -137,7 +138,7 @@ Public Class TradeScreen
|
||||||
''' </summary>
|
''' </summary>
|
||||||
''' <param name="currentScreen">The screen that is the current active screen.</param>
|
''' <param name="currentScreen">The screen that is the current active screen.</param>
|
||||||
''' <param name="storeString">The string defining what the store sells. Format: {ItemID|Amount|Price}</param>
|
''' <param name="storeString">The string defining what the store sells. Format: {ItemID|Amount|Price}</param>
|
||||||
Public Sub New(ByVal currentScreen As Screen, ByVal storeString As String, ByVal canBuy As Boolean, ByVal canSell As Boolean, ByVal currencyIndicator As String)
|
Public Sub New(ByVal currentScreen As Screen, ByVal storeString As String, ByVal canBuy As Boolean, ByVal canSell As Boolean, ByVal currencyIndicator As String, ByVal shopIdentifier As String)
|
||||||
Me.PreScreen = currentScreen
|
Me.PreScreen = currentScreen
|
||||||
|
|
||||||
Dim itemArr = storeString.Split({"}"}, StringSplitOptions.RemoveEmptyEntries)
|
Dim itemArr = storeString.Split({"}"}, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
@ -149,7 +150,25 @@ Public Class TradeScreen
|
||||||
|
|
||||||
Dim itemData = lItem.Split(CChar("|"))
|
Dim itemData = lItem.Split(CChar("|"))
|
||||||
|
|
||||||
|
If shopIdentifier <> "" Then
|
||||||
|
Me.ShopIdentifier = shopIdentifier
|
||||||
|
If ActionScript.IsRegistered(Me.ShopIdentifier & "_" & itemData(0)) = True Then
|
||||||
|
If ScriptConversion.ToInteger(itemData(1)) <> -1 Then
|
||||||
|
Dim registerContent() As Object = ActionScript.GetRegisterValue(shopIdentifier & "_" & itemData(0))
|
||||||
|
|
||||||
|
If CInt(registerContent(0)) < ScriptConversion.ToInteger(itemData(1)) Then
|
||||||
|
Dim ResultAmount As Integer = ScriptConversion.ToInteger(itemData(1))
|
||||||
|
If CInt(registerContent(0)) > 0 Then
|
||||||
|
ResultAmount = ScriptConversion.ToInteger(itemData(1)) - CInt(registerContent(0))
|
||||||
|
End If
|
||||||
|
Me.TradeItems.Add(New TradeItem(itemData(0), ResultAmount, ScriptConversion.ToInteger(itemData(2)), Me.Currency))
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Else
|
||||||
Me.TradeItems.Add(New TradeItem(itemData(0), ScriptConversion.ToInteger(itemData(1)), ScriptConversion.ToInteger(itemData(2)), Me.Currency))
|
Me.TradeItems.Add(New TradeItem(itemData(0), ScriptConversion.ToInteger(itemData(1)), ScriptConversion.ToInteger(itemData(2)), Me.Currency))
|
||||||
|
End If
|
||||||
|
|
||||||
Next
|
Next
|
||||||
|
|
||||||
Me.texture = TextureManager.GetTexture("GUI\Menus\General")
|
Me.texture = TextureManager.GetTexture("GUI\Menus\General")
|
||||||
|
@ -648,6 +667,15 @@ Public Class TradeScreen
|
||||||
If tradeItem.Amount > -1 Then
|
If tradeItem.Amount > -1 Then
|
||||||
For i = 0 To Me.TradeItems.Count - 1
|
For i = 0 To Me.TradeItems.Count - 1
|
||||||
If Me.TradeItems(i).ItemID = tradeItem.ItemID And tradeItem.Amount = Me.TradeItems(i).Amount Then
|
If Me.TradeItems(i).ItemID = tradeItem.ItemID And tradeItem.Amount = Me.TradeItems(i).Amount Then
|
||||||
|
If ShopIdentifier <> "" Then
|
||||||
|
If ActionScript.IsRegistered(Me.ShopIdentifier & "_" & tradeItem.ItemID) = False Then
|
||||||
|
ActionScript.RegisterID(Me.ShopIdentifier & "_" & tradeItem.ItemID, "int", "0")
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim registerContent() As Object = ActionScript.GetRegisterValue(ShopIdentifier & "_" & tradeItem.ItemID)
|
||||||
|
ActionScript.ChangeRegister(Me.ShopIdentifier & "_" & tradeItem.ItemID, CStr(CInt(registerContent(0)) + BuyItemsAmount))
|
||||||
|
End If
|
||||||
|
|
||||||
Dim t As TradeItem = Me.TradeItems(i)
|
Dim t As TradeItem = Me.TradeItems(i)
|
||||||
t.Amount -= Me.BuyItemsAmount
|
t.Amount -= Me.BuyItemsAmount
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,16 @@
|
||||||
Dim currencyIndicator As String = "P"
|
Dim currencyIndicator As String = "P"
|
||||||
|
|
||||||
If argument.CountSplits() > 3 Then
|
If argument.CountSplits() > 3 Then
|
||||||
|
If argument.GetSplit(3) <> "" Then
|
||||||
currencyIndicator = argument.GetSplit(3) ' p for PokéDollars, bp for Battle Points, c for coins.
|
currencyIndicator = argument.GetSplit(3) ' p for PokéDollars, bp for Battle Points, c for coins.
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
|
Dim shopIdentifier As String = ""
|
||||||
|
If argument.CountSplits() > 4 Then
|
||||||
|
shopIdentifier = argument.GetSplit(4) ' p for PokéDollars, bp for Battle Points, c for coins.
|
||||||
|
End If
|
||||||
|
|
||||||
Core.SetScreen(New TransitionScreen(Core.CurrentScreen, New TradeScreen(Core.CurrentScreen, storeData, canBuy, canSell, currencyIndicator), Color.Black, False))
|
Core.SetScreen(New TransitionScreen(Core.CurrentScreen, New TradeScreen(Core.CurrentScreen, storeData, canBuy, canSell, currencyIndicator, shopIdentifier), Color.Black, False))
|
||||||
|
|
||||||
IsReady = True
|
IsReady = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue