• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Triple Triad Booster Pack

2
Posts
3
Years
    • Seen Nov 27, 2020
    Hello, FL. I've implemented your Triple Triad system into my game, and it works fine. However, when the player wins matches, the card given is random, making it difficult to collect them.
    Do you know a way in which the player could choose any card they want? That would make the game much better!
    Thank you so much again! Cheers :)
     

    FL

    Pokémon Island Creator
    2,454
    Posts
    13
    Years
    • Seen yesterday
    Hello, FL. I've implemented your Triple Triad system into my game, and it works fine. However, when the player wins matches, the card given is random, making it difficult to collect them.
    Do you know a way in which the player could choose any card they want? That would make the game much better!
    Thank you so much again! Cheers :)
    Yes. Edit this part:

    Code:
              # Gain 1 random card from opponent's deck
              card=originalOpponentCards[rand(originalOpponentCards.length)]
              if $PokemonGlobal.triads.pbStoreItem(card)
                cardname=PBSpecies.getName(card)
                @scene.pbDisplayPaused(_INTL("Got opponent's {1} card.",cardname))
              end
     
    61
    Posts
    4
    Years
    • Seen Sep 7, 2023
    Hey FL, I'm having some trouble with getting this to work in v19.1

    I added this to try to get PBSpecies and PBItems to be initialized but i don't really know how to make it work.
    Code:
    def getName(item)
      return GameData::Item.get(item).name
    end
    
    def PBSpecies(species)
      return GameData::Species.species
    end

    Can you help?
    Code:
    [Pokémon Essentials version 19.1]
    [EBDX v1.1.6]
    
    Exception: NameError
    Message: uninitialized constant PBSpecies
    
    Backtrace:
    387::89:in `block in getRandomTriadCard'
    387::86:in `loop'
    387::86:in `getRandomTriadCard'
    387::61:in `fillBoosterStock'
    387::68:in `getFirstBoosterAtStock'
    387::107:in `block in giveBoosterPack'
    387::104:in `each'
    387::104:in `giveBoosterPack'
    387::132:in `block in <main>'
    036:Event_Handlers:199:in `trigger'
     
    61
    Posts
    4
    Years
    • Seen Sep 7, 2023
    I got this working with help from GosilopodUser and ThatWelshOne_ on discord, here is the code.
    Code:
    #===============================================================================
    # * Triple Triad Booster Pack - by FL (Credits will be appreciated)
    #===============================================================================
    #
    # This script is for Pokémon Essentials. It's a booster pack item for 
    # Triple Triad minigame.
    #
    #===============================================================================
    #
    # To this script works, put it above main. Put an item into item.txt like:
    #
    # 712,BOOSTERPACK,Booster Pack,Booster Packs,1,500,An booster pack for Triple Triad game. Contains 3 cards ,2,0,0,
    #
    # You can set a BOOSTER_LIST lists. So, you can create several types of 
    # packs. For helping in making these lists, this script includes a 
    # method (getSpeciesOfType) that return the index of a pokémon type. An 
    # example: if you call the line 'p getSpeciesOfType(PBTypes::DRAGON)', you can
    # copy/paste the species array of all Dragon pokémon in pokemon.txt. If you
    # copy into the index 2 (remember that the first index is 0), all that you need
    # to do in the item script is:
    #
    # ItemHandlers::UseFromBag.add(:DRAGONPACK,proc{|item|
    #   giveBoosterPack(item,3,2)
    # })
    #
    # This script generates random cards, but generate some cards in order to a
    # player won't reset the game trying to get other cards. The variable
    # MIN_BOOSTER_STOCK defines how many cards are stocked in save. If the number
    # in this variable is 5, by example, and the values are initialized. Even if
    # the player saves and keep opening the packs and resetting, he gets the same
    # first 5 cards, since these cards are randomized only the 5 cards ahead. To
    # disable this feature, just make the variable value as 0.
    #
    # I suggest you to initialize this list after the professor lecture, for all 
    # packs. If, in your game, the last pack index that you use is 2, after
    # professor lecture add the script commands:
    #
    # $PokemonGlobal.fillBoosterStock(0)
    # $PokemonGlobal.fillBoosterStock(1)
    # $PokemonGlobal.fillBoosterStock(2)
    #
    #===============================================================================
    #
    MIN_BOOSTER_STOCK=15
    #
    #
    BOOSTER_LIST=[
      nil,
      # The below line is the booster of index 1
      [1,4,9,152,155,158,252,255,258,387,390,393,495,498,501],
      [16, 17, 18, 19, 20, 21, 22, 35, 36, 39, 40, 52, 53, 83, 84, 85, 108, 113,
        115, 128, 132, 133, 137, 143]
    ]
    
    
    if MIN_BOOSTER_STOCK>0
      class PokemonGlobalMetadata
        def fillBoosterStock(boosterIndex)
          @boosterStock=[]  if !@boosterStock
          @boosterStock[boosterIndex]=[] if @boosterStock.size<=boosterIndex
          while @boosterStock[boosterIndex].size<MIN_BOOSTER_STOCK
            randomCard = getRandomTriadCard(boosterIndex)
            @boosterStock[boosterIndex].push(randomCard)
          end
        end
        
        def getFirstBoosterAtStock(boosterIndex)
          # Called twice since the variable maybe isn't initialized
          fillBoosterStock(boosterIndex)
          newCard = @boosterStock[boosterIndex].shift
          fillBoosterStock(boosterIndex)
          return newCard
        end
      end
    end  
    
    def getName(item)
      return GameData::Item.get(item).name
    end
      
    def getRandomTriadCard(boosterIndex)
      overflowCount=0
      max=0
      arr = []
      GameData::Species.each { |s| arr.push(s.id) if s.form==0 && s.generation <6}
      loop do
        overflowCount+=1
        raise "Can't draw a random card!" if overflowCount>10000
        randomPokemon = arr[rand(arr.length)]
        cname = randomPokemon.to_s rescue nil
        next if !cname
        if (!BOOSTER_LIST[boosterIndex] || BOOSTER_LIST[boosterIndex].empty? || 
            BOOSTER_LIST[boosterIndex].include?(randomPokemon))
         return randomPokemon 
        end
      end 
    end  
    
    def giveBoosterPack(item,numberOfCards,boosterIndex=0)
      Kernel.pbMessage(_INTL("{1} opened the {2}.",
          $Trainer.name,getName(item)))
      cardEarned = 0
      overflowCount = 0
      for i in 0...numberOfCards
        card=-1
        if MIN_BOOSTER_STOCK>0
          card = $PokemonGlobal.getFirstBoosterAtStock(boosterIndex)
        else
          card = getRandomTriadCard(boosterIndex)
        end
        pbGiveTriadCard(card,1)
        Kernel.pbMessage(_INTL("{1} draws {2} card!",
            $Trainer.name,GameData::Species.get(card).id))
      end
      return 3
    end
    
    def getSpeciesOfType(type)
      ret = []
      dexdata=pbOpenDexData
      for species in 1..species_keys.length #NOT WORKING
        # Type
        pbDexDataOffset(dexdata,species,8)
        type1=dexdata.fgetb
        type2=dexdata.fgetb
        ret.push(species) if type==type1 || type==type2
      end
      return ret
    end  
    
    ItemHandlers::UseFromBag.add(:BOOSTERPACK,proc{|item|
      giveBoosterPack(item,3)
    })
     
    124
    Posts
    3
    Years
  • Nice, dude! Glad to have helped.
    I see that the getSpeciesOfType method at the end of the script isn't working? Funnily enough, I wrote something like this recently! The following bit of code returns a random species of the given type. You can get it to return an array of all species of the given type by changing the return line to just return ret.
    Code:
    def getRandomSpeciesFromType(type)
      ret = []
      GameData::Species.each { |s| ret.push(s.id) if s.form==0 && (s.type1==type || s.type2==type) }
      return ret[rand(ret.length)]
    end
     
    61
    Posts
    4
    Years
    • Seen Sep 7, 2023
    That works great Welsh thank you!

    I have a new problem though.
    Code:
    if MIN_BOOSTER_STOCK>0
      class PokemonGlobalMetadata
        def fillBoosterStock(boosterIndex)
          @boosterStock=[]  if !@boosterStock
          @boosterStock[boosterIndex]=[] if @boosterStock.size<=boosterIndex
          while @boosterStock[boosterIndex].size<MIN_BOOSTER_STOCK
            randomCard = getRandomTriadCard(boosterIndex)
            @boosterStock[boosterIndex].push(randomCard)
          end
        end
        
        def getFirstBoosterAtStock(boosterIndex)
          # Called twice since the variable maybe isn't initialized
          fillBoosterStock(boosterIndex)
          newCard = @boosterStock[boosterIndex].shift
          fillBoosterStock(boosterIndex)
          return newCard
        end
      end
    end
    Triple Triad Booster Pack
     
    124
    Posts
    3
    Years
  • Spoiler:


    Well, the error says that you're trying to call the method size on something that's nil. My guess would be that that something shouldn't be nil.
    I'm not sure why that would happen. Maybe FL can tell us.
     

    FL

    Pokémon Island Creator
    2,454
    Posts
    13
    Years
    • Seen yesterday
    Well, the error says that you're trying to call the method size on something that's nil. My guess would be that that something shouldn't be nil.
    I'm not sure why that would happen. Maybe FL can tell us.
    If getFirstBoosterAtStock is called twice, and the second time the parameter is a lower index, the game try to check size on nil and crashes. Just change:

    Code:
    @boosterStock[boosterIndex]=[] if @boosterStock.size<=boosterIndex
    to
    Code:
    @boosterStock[boosterIndex]=[] if @boosterStock.size<=boosterIndex || !@boosterStock[boosterIndex]

    I updated the thread.
     
    2
    Posts
    2
    Years
    • Seen Aug 24, 2022
    I realise it's been over a year since this thread was last used so please close if it breaks a necroposting rule of some kind.

    I've tried to implement the script in Essentials version 19.1 that everyone here has provided.
    I've tried to use it in two ways but encountered problems for both.

    Any help would be massively appreciated.

    Method 1 script:
    Spoiler:
    Problem with this method:
    Both the BOOSTERPACK and COLOSSEUMPACK produce 3 random cards.

    Method 2 script:
    Spoiler:
     

    FL

    Pokémon Island Creator
    2,454
    Posts
    13
    Years
    • Seen yesterday
    Method 2 script:
    Spoiler:
    Spoiler:
     
    2
    Posts
    2
    Years
    • Seen Aug 24, 2022
    Thank you, FL!
    It works beautifully now.

    Here's the whole script fully working if anyone else is interested:
    Spoiler:
     

    FL

    Pokémon Island Creator
    2,454
    Posts
    13
    Years
    • Seen yesterday
    I gonna make a better version.
    Done. Now works with old and new Essentials versions. It also uses symbols rather than numbers for species on pack list.
     

    FL

    Pokémon Island Creator
    2,454
    Posts
    13
    Years
    • Seen yesterday
    Yes. Edit this part:

    Code:
              # Gain 1 random card from opponent's deck
              card=originalOpponentCards[rand(originalOpponentCards.length)]
              if $PokemonGlobal.triads.pbStoreItem(card)
                cardname=PBSpecies.getName(card)
                @scene.pbDisplayPaused(_INTL("Got opponent's {1} card.",cardname))
              end
    I was asked how to do it. On PMinigame_TripleTriad, before 'def pbDisplay(text)' add:
    Code:
      def pbShowCommands(text, commands)
        return UIHelper.pbShowCommands(@sprites["helpwindow"],text,commands){ pbUpdate }
      end

    After 'card = originalOpponentCards[rand(originalOpponentCards.length)]' add:
    Code:
              cmd = -1
              while cmd==-1
                cmd = @scene.pbShowCommands(_INTL("Choose a card."),originalOpponentCards.map{|pkmn|
                  next PBSpecies.getName(pkmn)
                })
              end
              card = originalOpponentCards[cmd]
    Tested on Essentials v18.1.
     
    Last edited:
    Back
    Top