extends Node

## Enum & Match Demo: Type-safe fruit identification

enum FruitType { APPLE, BANANA, ORANGE, WATERMELON }

var current_fruit: FruitType = FruitType.APPLE
var fruit_colors = {
	FruitType.APPLE: Color.RED,
	FruitType.BANANA: Color.YELLOW,
	FruitType.ORANGE: Color.ORANGE,
	FruitType.WATERMELON: Color.GREEN,
}

func _ready():
	$Button.pressed.connect(cycle_fruit)
	update_display()

func cycle_fruit():
	current_fruit = (current_fruit + 1) % FruitType.size()
	update_display()

func update_display():
	var fruit_name: String
	match current_fruit:
		FruitType.APPLE:
			fruit_name = "Apple (RED)"
		FruitType.BANANA:
			fruit_name = "Banana (YELLOW)"
		FruitType.ORANGE:
			fruit_name = "Orange (ORANGE)"
		FruitType.WATERMELON:
			fruit_name = "Watermelon (GREEN)"
		_:
			fruit_name = "Unknown"
	
	$Label.text = fruit_name
	$ColorRect.color = fruit_colors[current_fruit]
