Godot Version
4.6.3
Question
extends Node2D
class_name Card
@export var cost: int
@export var click_value_change: int = 0
@export var graphic: Texture2D
@export var guh_value_change: int = 0
@export var double_guh: bool = false
var coverage: bool
func _ready() → void:
$Sprite2D.texture = graphic
func _on_area_2d_input_event(viewport: Node, event: InputEvent, shape_idx: int) → void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
if coverage == true:
if event.pressed:
if Wallet.money >= cost:
purchase_card()
update_cost()
card_removal()
func _on_area_2d_mouse_entered() → void:
coverage = true
func _on_area_2d_mouse_exited() → void:
coverage = false
func card_removal() → void:
queue_free()
Carddealer.card_count -= 1
func purchase_card() → void:
Wallet.money -= cost
if double_guh == true:
Wallet.click_value *= 2
Wallet.click_value += click_value_change
Wallet.guh_value += guh_value_change
func update_cost() → void:
cost *= 2
So basically I have this script that other cards in my game just inherit from, the cost variable is an export variable, and my idea is that I want the cost of the cards to double everytime they are purchased, so next time the player has to spend more money. But it doesnt seem to be working, im not getting an error or anything, its just simply not changing the cost at all.