ajout du déblocage/évolutions des plantes (#89) et fix divers
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
extends Resource
|
||||
class_name PlantEffect
|
||||
|
||||
const HARVEST_EFFECT_ICON = preload("res://common/icons/shovel.svg")
|
||||
const MATURE_EFFECT_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
const CYCLIC_EFFECT_ICON = preload("res://common/icons/rotate-rectangle.svg")
|
||||
|
||||
@export var level : int
|
||||
|
||||
func _init(_level : int = 1):
|
||||
@@ -15,7 +19,7 @@ func get_effect_description() -> String:
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
return ""
|
||||
|
||||
func effect(plant):
|
||||
func effect(_plant):
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
|
||||
func get_styled_effect_name():
|
||||
@@ -31,4 +35,42 @@ func get_styled_effect_name():
|
||||
if level == 1:
|
||||
return levels_bbcode[0] % get_effect_name()
|
||||
else :
|
||||
return levels_bbcode[min(level - 1, len(levels_bbcode) - 1)] % [get_effect_name(), level]
|
||||
return levels_bbcode[min(level - 1, len(levels_bbcode) - 1)] % [get_effect_name(), level]
|
||||
|
||||
static func card_effect_sections(
|
||||
mature_effects : Array[PlantEffect],
|
||||
harvest_effects : Array[PlantEffect],
|
||||
cyclic_effects : Array[PlantEffect]
|
||||
) -> Array[CardSectionInfo]:
|
||||
var sections : Array[CardSectionInfo] = []
|
||||
var effects_category = [
|
||||
mature_effects,
|
||||
harvest_effects,
|
||||
cyclic_effects
|
||||
]
|
||||
var effects_category_labels : Array[String] = [
|
||||
"On mature",
|
||||
"When harvested",
|
||||
"Each day when mature",
|
||||
]
|
||||
var effects_category_icon : Array[Texture] = [
|
||||
MATURE_EFFECT_ICON,
|
||||
HARVEST_EFFECT_ICON,
|
||||
CYCLIC_EFFECT_ICON,
|
||||
]
|
||||
|
||||
for i in range(len(effects_category)):
|
||||
var effects = effects_category[i]
|
||||
|
||||
if len(effects) > 0:
|
||||
var section = CardSectionInfo.new(
|
||||
effects_category_labels[i]
|
||||
)
|
||||
section.title_icon = effects_category_icon[i]
|
||||
var effects_text : Array = effects.map(
|
||||
func (e : PlantEffect): return "[b]%s[/b] %s" % [e.get_styled_effect_name() , e.get_effect_description()]
|
||||
)
|
||||
section.text = "\n".join(effects_text)
|
||||
sections.append(section)
|
||||
|
||||
return sections
|
||||
Reference in New Issue
Block a user