Added a method that checks whether the player has enough Triple Triad cards to play

This commit is contained in:
Maruno17
2021-12-23 18:49:11 +00:00
parent 35126dfb6b
commit 4a6324389b

View File

@@ -970,6 +970,11 @@ end
#=============================================================================== #===============================================================================
# Start duel # Start duel
#=============================================================================== #===============================================================================
def pbCanTriadDuel?
card_count = $PokemonGlobal.triads.total_cards
return card_count >= PokemonGlobalMetadata::MINIMUM_TRIAD_CARDS
end
def pbTriadDuel(name, minLevel, maxLevel, rules = nil, oppdeck = nil, prize = nil) def pbTriadDuel(name, minLevel, maxLevel, rules = nil, oppdeck = nil, prize = nil)
ret = 0 ret = 0
pbFadeOutInWithMusic { pbFadeOutInWithMusic {
@@ -988,6 +993,8 @@ end
class PokemonGlobalMetadata class PokemonGlobalMetadata
attr_writer :triads attr_writer :triads
MINIMUM_TRIAD_CARDS = 5
def triads def triads
@triads = TriadStorage.new if !@triads @triads = TriadStorage.new if !@triads
return @triads return @triads
@@ -1051,6 +1058,12 @@ class TriadStorage
def remove(item, qty = 1) def remove(item, qty = 1)
return ItemStorageHelper.remove(@items, item, qty) return ItemStorageHelper.remove(@items, item, qty)
end end
def total_cards
ret = 0
@items.each { |itm| ret += itm[1] }
return ret
end
end end
@@ -1151,14 +1164,16 @@ def pbBuyTriads
end end
def pbSellTriads def pbSellTriads
total_cards = 0
commands = [] commands = []
$PokemonGlobal.triads.length.times do |i| $PokemonGlobal.triads.length.times do |i|
item = $PokemonGlobal.triads[i] item = $PokemonGlobal.triads[i]
speciesname = GameData::Species.get(item[0]).name speciesname = GameData::Species.get(item[0]).name
commands.push(_INTL("{1} x{2}", speciesname, item[1])) commands.push(_INTL("{1} x{2}", speciesname, item[1]))
total_cards += item[1]
end end
commands.push(_INTL("CANCEL")) commands.push(_INTL("CANCEL"))
if commands.length == 1 if total_cards == 0
pbMessage(_INTL("You have no cards.")) pbMessage(_INTL("You have no cards."))
return return
end end
@@ -1257,14 +1272,16 @@ def pbSellTriads
end end
def pbTriadList def pbTriadList
total_cards = 0
commands = [] commands = []
$PokemonGlobal.triads.length.times do |i| $PokemonGlobal.triads.length.times do |i|
item = $PokemonGlobal.triads[i] item = $PokemonGlobal.triads[i]
speciesname = GameData::Species.get(item[0]).name speciesname = GameData::Species.get(item[0]).name
commands.push(_INTL("{1} x{2}", speciesname, item[1])) commands.push(_INTL("{1} x{2}", speciesname, item[1]))
total_cards += item[1]
end end
commands.push(_INTL("CANCEL")) commands.push(_INTL("CANCEL"))
if commands.length == 1 if total_cards == 0
pbMessage(_INTL("You have no cards.")) pbMessage(_INTL("You have no cards."))
return return
end end