prototype vibe

This commit is contained in:
Marek Lenczewski
2026-04-16 17:20:57 +02:00
parent cf5979803e
commit f21e30eb55
72 changed files with 1330 additions and 70 deletions

View File

@@ -28,6 +28,13 @@ var buff_damage := 1.0
var buff_heal := 1.0
var buff_shield := 1.0
# Level / XP
const XP_PER_LEVEL: int = 50
var level: int = 1
var xp: int = 0
var xp_to_next: int = XP_PER_LEVEL
var level_scale: float = 1.0
# Rolle
var current_role: int = Role.DAMAGE
var ability_set: AbilitySet = null
@@ -61,11 +68,11 @@ func init_from_resource(res: PlayerStats) -> void:
gcd_time = res.gcd_time
aa_cooldown = res.aa_cooldown
if _cache.is_empty():
health = res.max_health
max_health = res.max_health
health_regen = res.health_regen
shield = res.max_shield
max_shield = res.max_shield
max_health = res.max_health * level_scale
health = max_health
health_regen = res.health_regen * level_scale
max_shield = res.max_shield * level_scale
shield = max_shield
shield_regen_delay = res.shield_regen_delay
shield_regen_time = res.shield_regen_time
shield_regen_timer = 0.0
@@ -130,6 +137,49 @@ func clear_cache() -> void:
returning_from_dungeon = false
dungeon_cleared = false
func reset_run() -> void:
clear_cache()
level = 1
xp = 0
xp_to_next = XP_PER_LEVEL
level_scale = 1.0
func add_xp(amount: int) -> void:
xp += amount
EventBus.xp_gained.emit(self, amount)
while xp >= xp_to_next:
xp -= xp_to_next
level_up()
func level_up() -> void:
level += 1
level_scale = float(_fibonacci(level))
xp_to_next = XP_PER_LEVEL * _fibonacci(level)
if base:
max_health = base.max_health * level_scale
max_shield = base.max_shield * level_scale
else:
max_health = 100.0 * level_scale
max_shield = 50.0 * level_scale
health = max_health
shield = max_shield
EventBus.health_changed.emit(self, health, max_health)
EventBus.shield_changed.emit(self, shield, max_shield)
EventBus.level_up.emit(self, level)
func _fibonacci(n: int) -> int:
if n <= 1:
return 1
if n == 2:
return 2
var a := 1
var b := 2
for i in range(3, n + 1):
var c := a + b
a = b
b = c
return b
func _restore_cache() -> void:
health = _cache.get("health", max_health)
max_health = _cache.get("max_health", max_health)