extends Resource class_name PlantMutation @export var level : int = 1 func _init(_level : int = 1): level = _level func get_icon() -> Texture: return preload("res://common/icons/dna.svg") func get_base_rarity() -> int: return 0 func get_mutation_name() -> String: printerr("Classe abstraite PlantMutation appelée") return "" func get_mutation_description() -> String: printerr("Classe abstraite PlantMutation appelée") return "" func mutate_score(_plant_state : Plant.State, _plant : Plant, score,) -> int: return score func mutate_grow_time(_plant : Plant, grow_time : int) -> int: return grow_time func mutate_plant(_plant : Plant): pass func get_level_for_rarity(rarity : int) -> int : return rarity - get_base_rarity() + 1 func get_rarity() -> int: return get_base_rarity() + level - 1 func card_section() -> CardSectionInfo: var section = CardSectionInfo.new( get_mutation_name() + (" %d" % level if level > 1 else ""), "[b]%s[/b] %s" % [tr(PlantMutation.get_rarity_text(get_rarity())), get_mutation_description()] ) section.title_color = PlantMutation.get_rarity_color(get_rarity()) section.title_colored = true section.title_icon = get_icon() return section static func get_rarity_text(rarity) -> String: var rarity_text : Array[String] = [ "COMMON", "RARE", "VERY_RARE", "IMPOSSIBLE", "ABSURD", ] if rarity < len(rarity_text): return rarity_text[rarity] else : return rarity_text[len(rarity_text) - 1] static func get_rarity_color(rarity : int) -> Color: var rarity_colors : Array[Color] = [ Color("25C147"), Color("8B2DFF"), Color("FF006E"), Color("FFA617"), ] return rarity_colors[min(rarity, len(rarity_colors) - 1)] static func random_mutation(except_mutations : Array[PlantMutation] = []) -> PlantMutation: var all_mutations = GameInfo.game_data.unlocked_plant_mutations.duplicate_deep() all_mutations = all_mutations.filter( func (f1 : PlantMutation): return except_mutations.find_custom( func (f2 : PlantMutation): return f2.get_mutation_name() == f1.get_mutation_name() ) == -1 ) if len(all_mutations): return all_mutations.pick_random() else : return null