extends Resource class_name Modifier # One modifier definition: title + description + texture + scoring rule. # Create instances of this as .tres files in the editor (right-click in # FileSystem -> New Resource -> Modifier), OR build them in code in the catalog. # # Because a texture always maps to the same modifier, the texture lives HERE. # A stable unique id (e.g. "stars_x5"). Useful for saving which modifiers are # applied to which segments, and for lookups. Keep it unique across the catalog. @export var id: String = "" # Shown to the player when offered the piece. @export var title: String = "" @export_multiline var description: String = "" # The texture painted onto the segment when this modifier is applied. @export var texture: Texture2D # --- Scoring rule --- # Simple, data-only rules cover most cases without writing code per modifier. # value = (base_value * mult + add) for the affected segment. @export var score_mult: float = 1.0 @export var score_add: int = 0 # Optional: rarity weight for random selection (higher = more common). @export var weight: float = 1.0 # Apply this modifier's rule to a segment's base value. func apply_score(base_value: int) -> int: return int(round(base_value * score_mult)) + score_add # A short human-readable summary of the effect, for tooltips/UI. func effect_text() -> String: var parts: Array[String] = [] if score_mult != 1.0: parts.append("x%s" % str(score_mult)) if score_add != 0: parts.append(("+%d" % score_add) if score_add > 0 else str(score_add)) return " ".join(parts) if parts.size() > 0 else "no change"