106 lines
2.4 KiB
GDScript
106 lines
2.4 KiB
GDScript
extends Resource
|
|
class_name PlantMutation
|
|
|
|
@export var level: int = 1
|
|
|
|
var id: String: get = get_mutation_id
|
|
var name: String: get = get_mutation_name
|
|
|
|
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_id() -> String:
|
|
printerr("Classe abstraite PlantMutation appelée")
|
|
return ""
|
|
|
|
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_plant_data(_plant_data: PlantData):
|
|
pass
|
|
|
|
func mutate_score(_plant_data: PlantData, score: int) -> int:
|
|
return score
|
|
|
|
func mutate_score_multiplier(_plant_data: PlantData, multiplier: int) -> int:
|
|
return multiplier
|
|
|
|
func mutate_lifetime(_plant_data: PlantData, lifetime: int) -> int:
|
|
return lifetime
|
|
|
|
func mutate_growing_time(_plant_data: PlantData, growing_time: int) -> int:
|
|
return growing_time
|
|
|
|
func mutate_seed_number(_plant_data: PlantData, seed_number: int):
|
|
return seed_number
|
|
|
|
func mutate_seed_random_loose(_plant_data: PlantData, seed_random_loose):
|
|
return seed_random_loose
|
|
|
|
func _start_planted_effect(_plant: Plant):
|
|
pass
|
|
|
|
func _start_day_effect(_plant: Plant):
|
|
pass
|
|
|
|
func _start_maturation_effect(_plant: Plant):
|
|
pass
|
|
|
|
func _start_dead_effect(_plant: Plant):
|
|
pass
|
|
|
|
func _start_harvested_effect(_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.color = PlantMutation.get_rarity_color(get_rarity())
|
|
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)]
|