Show combat merit progress in reports
This commit is contained in:
@@ -3759,8 +3759,9 @@ func _resolve_combat(attacker: Dictionary, target: Dictionary) -> void:
|
||||
var attack_exp := EXP_ATTACK if bool(attack_result.get("hit", false)) else EXP_MISS
|
||||
if bool(attack_result.get("defeated", false)) or battle_status != STATUS_ACTIVE:
|
||||
var final_attack_exp := attack_exp + (EXP_DEFEAT_BONUS if bool(attack_result.get("defeated", false)) else 0)
|
||||
_grant_experience(attacker, final_attack_exp)
|
||||
report["attacker_merit"] = final_attack_exp
|
||||
var final_attack_progress := _grant_experience(attacker, final_attack_exp)
|
||||
report["attacker_merit"] = int(final_attack_progress.get("amount", 0))
|
||||
report["attacker_progress"] = final_attack_progress
|
||||
combat_result_reported.emit(report)
|
||||
return
|
||||
|
||||
@@ -3770,10 +3771,12 @@ func _resolve_combat(attacker: Dictionary, target: Dictionary) -> void:
|
||||
(report["entries"] as Array).append(counter_result)
|
||||
counter_exp = (EXP_COUNTER if bool(counter_result.get("hit", false)) else EXP_MISS) + (EXP_DEFEAT_BONUS if bool(counter_result.get("defeated", false)) else 0)
|
||||
|
||||
_grant_experience(attacker, attack_exp)
|
||||
report["attacker_merit"] = attack_exp
|
||||
_grant_experience(target, counter_exp)
|
||||
report["counter_merit"] = counter_exp
|
||||
var attack_progress := _grant_experience(attacker, attack_exp)
|
||||
report["attacker_merit"] = int(attack_progress.get("amount", 0))
|
||||
report["attacker_progress"] = attack_progress
|
||||
var counter_progress := _grant_experience(target, counter_exp)
|
||||
report["counter_merit"] = int(counter_progress.get("amount", 0))
|
||||
report["counter_progress"] = counter_progress
|
||||
combat_result_reported.emit(report)
|
||||
|
||||
|
||||
@@ -3785,6 +3788,8 @@ func _make_combat_result_report(attacker: Dictionary, target: Dictionary) -> Dic
|
||||
"target_name": str(target.get("name", "")),
|
||||
"attacker_merit": 0,
|
||||
"counter_merit": 0,
|
||||
"attacker_progress": {},
|
||||
"counter_progress": {},
|
||||
"entries": []
|
||||
}
|
||||
|
||||
@@ -3920,15 +3925,36 @@ func _resolve_skill_heal(caster: Dictionary, target: Dictionary, skill: Dictiona
|
||||
return healed
|
||||
|
||||
|
||||
func _grant_experience(unit: Dictionary, amount: int) -> void:
|
||||
func _grant_experience(unit: Dictionary, amount: int) -> Dictionary:
|
||||
var progress := {
|
||||
"unit_id": str(unit.get("id", "")),
|
||||
"name": str(unit.get("name", "부대")),
|
||||
"amount": 0,
|
||||
"exp_before": int(unit.get("exp", 0)),
|
||||
"exp_after": int(unit.get("exp", 0)),
|
||||
"level_before": int(unit.get("level", 1)),
|
||||
"level_after": int(unit.get("level", 1)),
|
||||
"class_before": str(unit.get("class", "")),
|
||||
"class_after": str(unit.get("class", "")),
|
||||
"leveled": false,
|
||||
"promoted": false
|
||||
}
|
||||
if unit.is_empty() or not unit.get("alive", false) or amount <= 0:
|
||||
return
|
||||
return progress
|
||||
var class_id_before := str(unit.get("class_id", ""))
|
||||
unit["exp"] = int(unit.get("exp", 0)) + amount
|
||||
progress["amount"] = amount
|
||||
_emit_log("%s 공적 +%d." % [unit["name"], amount])
|
||||
_emit_combat_feedback(unit, "공적 +%d" % amount, "progress")
|
||||
while int(unit["exp"]) >= EXP_LEVEL:
|
||||
unit["exp"] = int(unit["exp"]) - EXP_LEVEL
|
||||
_level_up(unit)
|
||||
progress["exp_after"] = int(unit.get("exp", 0))
|
||||
progress["level_after"] = int(unit.get("level", progress["level_before"]))
|
||||
progress["class_after"] = str(unit.get("class", progress["class_before"]))
|
||||
progress["leveled"] = int(progress["level_after"]) > int(progress["level_before"])
|
||||
progress["promoted"] = str(unit.get("class_id", "")) != class_id_before
|
||||
return progress
|
||||
|
||||
|
||||
func _level_up(unit: Dictionary) -> void:
|
||||
|
||||
Reference in New Issue
Block a user