45 lines
1.7 KiB
GDScript
45 lines
1.7 KiB
GDScript
extends RefCounted
|
|
const ACTIVE_IDS := ["general", "weapons", "hull", "shields"]
|
|
const BRANCHES := ["weapons", "hull", "shields"]
|
|
const TITLES := {"general":"Ogólna wiedza", "weapons":"Wiedza o broni", "hull":"Wiedza o kadłubie", "shields":"Wiedza o tarczach"}
|
|
|
|
static func parent(id: String) -> String:
|
|
if id == "general": return ""
|
|
return id.split("_")[0] if "_" in id else "general"
|
|
|
|
static func cost(id: String) -> int:
|
|
var depth := 2 if "_" in id else (0 if id == "general" else 1)
|
|
return 10 + depth * (depth + 3)
|
|
|
|
static func title(id: String) -> String:
|
|
return str(TITLES.get(id, "Pusty slot"))
|
|
|
|
static func description(id: String) -> String:
|
|
match id:
|
|
"general": return "Ujawnia paski HP i tarcz wrogów."
|
|
"weapons": return "Broń obcych zadaje o 10% mniej obrażeń."
|
|
"hull": return "Twoja broń zadaje o 10% więcej obrażeń kadłubom obcych."
|
|
"shields": return "Twoja broń zadaje o 10% więcej obrażeń tarczom obcych."
|
|
return "Miejsce na przyszłe badanie."
|
|
|
|
static func learned_count(progress: Resource) -> int:
|
|
var count := 0
|
|
for id in ACTIVE_IDS:
|
|
if progress.alien_skills.get(id, false): count += 1
|
|
return count
|
|
|
|
static func bonus(progress: Resource, branch: String) -> float:
|
|
var learned: Dictionary = progress.alien_skills
|
|
return 0.1 if branch in BRANCHES and learned.get(branch, false) else 0.0
|
|
|
|
static func purchase(progress: Resource, id: String) -> bool:
|
|
if id not in ACTIVE_IDS: return false
|
|
if progress.alien_skills.get(id, false): return false
|
|
var prerequisite := parent(id)
|
|
if prerequisite != "" and not progress.alien_skills.get(prerequisite, false): return false
|
|
if progress.analysis_samples < cost(id): return false
|
|
progress.analysis_samples -= cost(id)
|
|
progress.alien_skills[id] = true
|
|
progress.emit_changed()
|
|
return true
|