Godot Version
4.2.1
Question
The project is a card game. Cards can be modified, in this case by their own effects. The card in question consumes a resource, and tracks how much it has consumed (Labeled “Faith”), and displays that in the card text. When it reaches a sum of 10, an ability triggers. I have encountered a bug where when I have two of this card, each displays the other’s total. Nothing odd occurs when only one is in the deck.
For example, one card displays “7 Faith” and the other displays “3 Faith”. I play the one labeled “3 Faith” with 3 resources to consume. I expect it to go to 6. But the debug command reads that 7 has gone to 10, and the ability triggers as if I had played the one labeled “7 Faith”. This occurs no matter if the other card is also in hand or not.
I am truly baffled how the cards are linked in this way, while still functioning as normal otherwise. The code in question:
func apply_effects() -> void:
Events.request_gamestate.emit()
var gamestate = await Events.gamestate
var money = gamestate[0]
var food = gamestate[1]
print_debug(money,food, faith)
faith += money + food
print_debug(money,food,faith)
Events.add_money.emit(-1 * money)
Events.add_food.emit(-1 * food)
rules_text = "Lose all Money\nand Food, gain\nthat Much Faith\n" + str(faith) + " Faith"
if faith >= 10:
some_function()
The cards are stored as resources, and are added to the deck by this code, if it is relevant. I checked, and they have different object IDs after being created:
func generate_starting_deck() -> void:
for i in 2:
deck.cards.append(farmer.duplicate(true))