Godot Version
4.7
Question
Hello,
I am new to programming, and am learning by making a card game, one goal I have is to have the ability "When specific card is played - draw another card of specific type"
All of my cards are Objects under class names, and their types are from an Enum list.
I have tried several things, such as using a mix of for loops and matches, to several other functions meant for Arrays - I’ll spare the details, but would love if someone can point me in the right direction.
Each ability lives in three functions:
Firstly, one that calls the needed function within the player manager:
func ability_manager(card: Card):
var wildcard_number = int(card.wildcard_number)
var wildcard = card.wildcard
var wildcard_variable
match card.ability_category:
###CARD ABILITY HANDLED HERE###
Card.AbilityCategory.DRAW:
draw_cards(wildcard_number)
Card.AbilityCategory.DISCARD_REDRAW:
discard_cards()
await(3.0)
draw_cards(wildcard_number)
Card.AbilityCategory.DRAW_SPECIFIC:
for i in range(wildcard_number):
draw_specific_card(wildcard)
Card.AbilityCategory.HAND_VALUE_MANIPULATION:
update_value(wildcard_number)
Bolded is the function for this ability.
This calls the actual abilities function, within the player:
func draw_variable_card(card: Card) -> void:
#THIS IS NOT WORKING AS INTENDED
if !character.draw_pile.cards.is_empty():
hand.add_card(character.draw_pile.draw_variable_card(card))
print("character.draw_pile.draw_variable_card(card_type)")
#if character.mana == 0:
#hand.disable_hand()
#else:
#pass
This is setting the card needed to draw, and calling the Deck’s draw card function - which is:
func draw_card() -> void:
var tween = create_tween()
if !character.draw_pile.cards.is_empty():
hand.add_card(character.draw_pile.draw_card())
if character.mana == 0:
hand.disable_hand()
if hand.get_child_count() >= 6:
hand.add_theme_constant_override('separation', 800 / hand.get_child_count())
And here is a version I have been trying to type up - but where I am lost (within the deck)
func draw_variable_card(card: Card) -> Card:
if cards.has(card):
cards.erase(card)
card_pile_size_changed.emit(cards.size())
return card
else:
return null
This is my first time posting on anything like this, so please let me know if you need more info.
Would love help, or just to be pointed to a function that may do exactly what I am looking for.
Thank you again.