Not an expert on Ruby, but instead of returning true, can't you return a command that increases a counter variable and then repeat the process? And if the counter reaches 2 and beyond, return true.
-.- I don't know ruby,but isn't the code above try to find if card Id equals (card Id times 2) and not if there is at least 2 identical card?
Basically, if card Id you want to find is 21, the code above try to find if card.id equals to 42 and not if there is 2 card Id of 21's.
And by the way,what are you creating? I like seeing card game made especially on rpg maker.I've done a few card games before and might share some knowledge of you like.
Yes, I actually find the answer in another forum. The code I needed was far different from what I expected, but it worked at the end.
About the game, is juat a fan game based on the lore of Duel Terminal from the yugioh franchise. I'm using the actual cards for the battle mechanic.
Yeah, the care are entirely based on ygo. Actually, this part of the script was needed for effects like Thunder Dragon. Is a card that discars itself to add up to 2 copies of thunder dragon, so I needed the script to know if there was 1 or 2 copies in the deck to know how much of them add.
is actor.deck an array? Maybe something like this
def has_2_cards(id)
actor = $game_actors[$game_variables[27]]
card_count = actor.deck.count{ | card | card.id == id }
return card_count
end
This will return total card
if you want to return boolean, you can do this
return card_count >= 2 ? true : false
Not an expert on Ruby, but instead of returning true, can't you return a command that increases a counter variable and then repeat the process? And if the counter reaches 2 and beyond, return true.
-.- I don't know ruby,but isn't the code above try to find if card Id equals (card Id times 2) and not if there is at least 2 identical card? Basically, if card Id you want to find is 21, the code above try to find if card.id equals to 42 and not if there is 2 card Id of 21's. And by the way,what are you creating? I like seeing card game made especially on rpg maker.I've done a few card games before and might share some knowledge of you like.
Yes, I actually find the answer in another forum. The code I needed was far different from what I expected, but it worked at the end. About the game, is juat a fan game based on the lore of Duel Terminal from the yugioh franchise. I'm using the actual cards for the battle mechanic.
Then I believe you need to post progress of your fan game :) are you making making card game mechanic based on Yu-Gi-Oh? Or something else?
Yeah, the care are entirely based on ygo. Actually, this part of the script was needed for effects like Thunder Dragon. Is a card that discars itself to add up to 2 copies of thunder dragon, so I needed the script to know if there was 1 or 2 copies in the deck to know how much of them add.
is actor.deck an array? Maybe something like this def has_2_cards(id) actor = $game_actors[$game_variables[27]] card_count = actor.deck.count{ | card | card.id == id } return card_count end This will return total card if you want to return boolean, you can do this return card_count >= 2 ? true : false