extends Node3D
class_name PlantInfoScreen

const CHANGED_COLOR = Color('#FFA617')

func _ready():
    update_plant_info()

func update_plant_info():
    var plant_info : RunDataPlantInfo = GameInfo.game_data.current_run.plant_info

    %ScoreLabel.text = "%d" % plant_info.get_base_score()
    %ScoreStat.modulate = Color.WHITE if plant_info.get_base_score() == plant_info.DEFAULT_BASE_SCORE else CHANGED_COLOR

    %LifetimeLabel.text = "%d" % plant_info.get_lifetime()
    %LifetimeStat.modulate = Color.WHITE if plant_info.get_lifetime() == plant_info.DEFAULT_LIFETIME else CHANGED_COLOR

    %GrowingLabel.text = "%d" % plant_info.get_growing_time()
    %GrowingStat.modulate = Color.WHITE if plant_info.get_growing_time() == plant_info.DEFAULT_GROWING_TIME else CHANGED_COLOR
    
    %SeedLabel.text = str(plant_info.get_seed_number())

    %SeedStat.modulate = Color.WHITE if (
        plant_info.get_seed_number() == plant_info.DEFAULT_SEED_NUMBER
        and plant_info.get_seed_random_loose() == plant_info.DEFAULT_SEED_RANDOM_LOOSE
    ) else CHANGED_COLOR

    %PlantMaxMutationLabel.text = tr("PLANTS_CAN_HAVE_UP_TO_X_MUTATION") % plant_info.get_mutation_max_number()
    %PlantMaxMutationLabel.modulate = Color.WHITE if plant_info.get_mutation_max_number() == plant_info.DEFAULT_MUTATION_MAX_NUMBER else CHANGED_COLOR

    %PlantMutationProbability.text = tr("PLANTS_MUTATION_CHANCE_IS_X_PERCENT").format({
        "mutation_chance": roundi(plant_info.get_mutation_probability() * 100)
    })
    %PlantMutationProbability.modulate = Color.WHITE if plant_info.get_mutation_probability() == plant_info.DEFAULT_MUTATION_PROBABILITY else CHANGED_COLOR
