Let panacea cleanse stat debuffs
This commit is contained in:
@@ -836,6 +836,7 @@ func get_item_preview(user_id: String, item_id: String, target_cell: Vector2i) -
|
||||
var hp_heal_amount := _item_hp_heal_amount(target, item)
|
||||
var mp_heal_amount := _item_mp_heal_amount(target, item)
|
||||
var cured_statuses := _item_curable_status_names(target, item)
|
||||
cured_statuses.append_array(_item_cleansable_debuff_names(target, item))
|
||||
preview["heal"] = hp_heal_amount
|
||||
preview["mp_heal"] = mp_heal_amount
|
||||
preview["cure_statuses"] = cured_statuses
|
||||
@@ -2400,6 +2401,12 @@ func _apply_item_effects(user: Dictionary, target: Dictionary, item: Dictionary)
|
||||
applied = true
|
||||
_emit_log("%s is cured of %s." % [target["name"], _join_strings(cured_statuses, ", ")])
|
||||
_emit_combat_feedback(target, "CURE", "support")
|
||||
elif effect_type == "cleanse_debuffs":
|
||||
var cleansed_debuffs := _apply_item_debuff_cleanse(target)
|
||||
if not cleansed_debuffs.is_empty():
|
||||
applied = true
|
||||
_emit_log("%s is cleansed of %s." % [target["name"], _join_strings(cleansed_debuffs, ", ")])
|
||||
_emit_combat_feedback(target, "CLEANSE", "support")
|
||||
if not applied:
|
||||
_emit_log("%s has no effect on %s." % [item.get("name", "Item"), target["name"]])
|
||||
return applied
|
||||
@@ -2442,6 +2449,22 @@ func _apply_item_status_cure(target: Dictionary, status: String) -> Array:
|
||||
return cured_statuses
|
||||
|
||||
|
||||
func _apply_item_debuff_cleanse(target: Dictionary) -> Array:
|
||||
var cleansed_debuffs := []
|
||||
if typeof(target.get("status_effects", [])) != TYPE_ARRAY:
|
||||
return cleansed_debuffs
|
||||
var kept_effects := []
|
||||
for effect in _active_status_effects(target):
|
||||
if _is_negative_stat_bonus_effect(effect):
|
||||
var display_name := _stat_debuff_display_name(effect)
|
||||
if not cleansed_debuffs.has(display_name):
|
||||
cleansed_debuffs.append(display_name)
|
||||
continue
|
||||
kept_effects.append(effect)
|
||||
target["status_effects"] = kept_effects
|
||||
return cleansed_debuffs
|
||||
|
||||
|
||||
func _item_hp_heal_amount(target: Dictionary, item: Dictionary) -> int:
|
||||
var total := 0
|
||||
for effect in item.get("effects", []):
|
||||
@@ -2486,6 +2509,40 @@ func _item_curable_status_names(target: Dictionary, item: Dictionary) -> Array:
|
||||
return result
|
||||
|
||||
|
||||
func _item_cleansable_debuff_names(target: Dictionary, item: Dictionary) -> Array:
|
||||
var result := []
|
||||
if target.is_empty() or not _item_has_effect_type(item, "cleanse_debuffs"):
|
||||
return result
|
||||
for active_effect in _active_status_effects(target):
|
||||
if not _is_negative_stat_bonus_effect(active_effect):
|
||||
continue
|
||||
var display_name := _stat_debuff_display_name(active_effect)
|
||||
if not result.has(display_name):
|
||||
result.append(display_name)
|
||||
return result
|
||||
|
||||
|
||||
func _item_has_effect_type(item: Dictionary, effect_type: String) -> bool:
|
||||
for effect in item.get("effects", []):
|
||||
if typeof(effect) == TYPE_DICTIONARY and str(effect.get("type", "")) == effect_type:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _is_negative_stat_bonus_effect(effect: Dictionary) -> bool:
|
||||
if str(effect.get("type", "")) != "stat_bonus":
|
||||
return false
|
||||
var stat := str(effect.get("stat", ""))
|
||||
return _is_supported_status_stat(stat) and int(effect.get("amount", 0)) < 0
|
||||
|
||||
|
||||
func _stat_debuff_display_name(effect: Dictionary) -> String:
|
||||
var stat := str(effect.get("stat", "stat"))
|
||||
if not _is_supported_status_stat(stat):
|
||||
return "Debuff"
|
||||
return "%s down" % stat.to_upper()
|
||||
|
||||
|
||||
func _equipment_slot_for_item(item: Dictionary) -> String:
|
||||
var kind := str(item.get("kind", ""))
|
||||
if kind == "weapon" or kind == "armor" or kind == "accessory":
|
||||
|
||||
Reference in New Issue
Block a user