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

@@ -2,14 +2,17 @@ extends Node
var entities: Dictionary = {}
func register(entity: Node, base: EnemyStats) -> void:
func register(entity: Node, base: EnemyStats, scale: float = 1.0) -> void:
var max_hp: float = base.max_health * scale
var max_sh: float = base.max_shield * scale
entities[entity] = {
"base": base,
"health": base.max_health,
"max_health": base.max_health,
"health_regen": base.health_regen,
"shield": base.max_shield,
"max_shield": base.max_shield,
"scale": scale,
"health": max_hp,
"max_health": max_hp,
"health_regen": base.health_regen * scale,
"shield": max_sh,
"max_shield": max_sh,
"shield_regen_delay": base.shield_regen_delay,
"shield_regen_time": base.shield_regen_time,
"shield_regen_timer": 0.0,
@@ -24,6 +27,21 @@ func register(entity: Node, base: EnemyStats) -> void:
"attack_timer": 0.0,
}
func apply_scale(entity: Node, scale: float) -> void:
if entity not in entities:
return
var data: Dictionary = entities[entity]
var base: EnemyStats = data["base"]
data["scale"] = scale
data["max_health"] = base.max_health * scale
data["health"] = data["max_health"]
data["health_regen"] = base.health_regen * scale
data["max_shield"] = base.max_shield * scale
data["shield"] = data["max_shield"]
EventBus.health_changed.emit(entity, data["health"], data["max_health"])
if base.max_shield > 0:
EventBus.shield_changed.emit(entity, data["shield"], data["max_shield"])
func deregister(entity: Node) -> void:
entities.erase(entity)

View File

@@ -2,14 +2,17 @@ extends Node
var entities: Dictionary = {}
func register(entity: Node, base: EnemyStats) -> void:
func register(entity: Node, base: EnemyStats, scale: float = 1.0) -> void:
var max_hp: float = base.max_health * scale
var max_sh: float = base.max_shield * scale
entities[entity] = {
"base": base,
"health": base.max_health,
"max_health": base.max_health,
"health_regen": base.health_regen,
"shield": base.max_shield,
"max_shield": base.max_shield,
"scale": scale,
"health": max_hp,
"max_health": max_hp,
"health_regen": base.health_regen * scale,
"shield": max_sh,
"max_shield": max_sh,
"shield_regen_delay": base.shield_regen_delay,
"shield_regen_time": base.shield_regen_time,
"shield_regen_timer": 0.0,
@@ -24,6 +27,21 @@ func register(entity: Node, base: EnemyStats) -> void:
"attack_timer": 0.0,
}
func apply_scale(entity: Node, scale: float) -> void:
if entity not in entities:
return
var data: Dictionary = entities[entity]
var base: EnemyStats = data["base"]
data["scale"] = scale
data["max_health"] = base.max_health * scale
data["health"] = data["max_health"]
data["health_regen"] = base.health_regen * scale
data["max_shield"] = base.max_shield * scale
data["shield"] = data["max_shield"]
EventBus.health_changed.emit(entity, data["health"], data["max_health"])
if base.max_shield > 0:
EventBus.shield_changed.emit(entity, data["shield"], data["max_shield"])
func deregister(entity: Node) -> void:
entities.erase(entity)

View File

@@ -50,3 +50,24 @@ signal effect_expired(target, effect)
signal element_damage_dealt(attacker, target, amount, element)
signal element_applied(target, element)
signal element_reaction(target, element_a, element_b, reaction_name)
# Wave
signal run_started(wave_number)
signal wave_started(wave_number)
signal wave_timer_tick(seconds_remaining)
signal wave_ended(wave_number, success)
# XP / Level
signal xp_gained(player, amount)
signal level_up(player, new_level)
# Taverne
signal tavern_damaged(current, max_val)
signal tavern_destroyed()
# Invasion
signal invasion_started(enemies)
signal invasion_ended(success)
# Game-Over
signal game_over()

19
autoloads/game_state.gd Normal file
View File

@@ -0,0 +1,19 @@
extends Node
# Run-Zustand
var current_wave: int = 1
var wave_timer_remaining: float = 0.0
var run_initialized: bool = false
# Dungeon-Kontext (für XP-Zuordnung nach Clear)
var last_dungeon_variant: int = 0
# Flag für Forced Return (Timer läuft ab während Spieler im Dungeon)
var force_return_to_world: bool = false
func reset() -> void:
current_wave = 1
wave_timer_remaining = 0.0
run_initialized = false
last_dungeon_variant = 0
force_return_to_world = false

View File

@@ -0,0 +1 @@
uid://c3jq4raqs0onf

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)

38
autoloads/tavern_stats.gd Normal file
View File

@@ -0,0 +1,38 @@
extends Node
var entities: Dictionary = {}
func register(entity: Node, base: Resource) -> void:
entities[entity] = {
"base": base,
"health": base.max_health,
"max_health": base.max_health,
"alive": true,
}
func deregister(entity: Node) -> void:
entities.erase(entity)
func get_stat(entity: Node, key: String) -> Variant:
if entity in entities:
return entities[entity].get(key)
return null
func set_stat(entity: Node, key: String, value: Variant) -> void:
if entity in entities:
entities[entity][key] = value
func is_alive(entity: Node) -> bool:
if entity in entities:
return entities[entity]["alive"]
return false
func set_health(entity: Node, value: float) -> void:
if entity not in entities:
return
entities[entity]["health"] = value
var max_health: float = entities[entity]["max_health"]
EventBus.tavern_damaged.emit(value, max_health)
if value <= 0 and entities[entity]["alive"]:
entities[entity]["alive"] = false
EventBus.tavern_destroyed.emit()

View File

@@ -0,0 +1 @@
uid://822h8c1pur1a