fix: align loot feedback with pickup outcomes
This commit is contained in:
+10
-5
@@ -1274,9 +1274,9 @@ func _record_narrative_event(kind: StringName, event_id: StringName, payload: Di
|
||||
|
||||
func _process_ground_pickup() -> Array[TurnResult]:
|
||||
var pickup := run_state.inventory.pick_up_ground_item(game_state.floor_state, game_state.player.cell)
|
||||
var item: ItemInstance = pickup.item
|
||||
var item: ItemInstance = pickup.get("item", null)
|
||||
var result: TurnResult
|
||||
if bool(pickup.accepted):
|
||||
if bool(pickup.get("accepted", false)) and item != null:
|
||||
result = TurnResult.new(
|
||||
game_state.player.id,
|
||||
&"item_picked_up",
|
||||
@@ -1285,9 +1285,14 @@ func _process_ground_pickup() -> Array[TurnResult]:
|
||||
&"",
|
||||
0,
|
||||
"Picked up %s x%d." % [item.definition.name, item.quantity],
|
||||
{"item_id": item.definition.id, "instance_id": item.instance_id, "quantity": item.quantity, "stack_merged_into": pickup.stack_merged_into}
|
||||
{"item_id": item.definition.id, "instance_id": item.instance_id, "quantity": item.quantity, "stack_merged_into": pickup.get("stack_merged_into", &"")}
|
||||
)
|
||||
else:
|
||||
var reason := StringName(pickup.get("reason", &"no_ground_item"))
|
||||
var payload := {"reason": reason}
|
||||
if item != null:
|
||||
payload.merge({"item_id": item.definition.id, "instance_id": item.instance_id, "quantity": item.quantity}, true)
|
||||
var message := "Rien à ramasser." if reason == &"no_ground_item" else "Inventaire plein." if reason == &"capacity" else "Ramassage impossible."
|
||||
result = TurnResult.new(
|
||||
game_state.player.id,
|
||||
&"pickup_refused",
|
||||
@@ -1295,8 +1300,8 @@ func _process_ground_pickup() -> Array[TurnResult]:
|
||||
game_state.player.cell,
|
||||
&"",
|
||||
0,
|
||||
"Inventory is full.",
|
||||
{"item_id": item.definition.id, "instance_id": item.instance_id, "quantity": item.quantity, "reason": pickup.reason}
|
||||
message,
|
||||
payload
|
||||
)
|
||||
_resolve_player_action([result], false)
|
||||
return [result]
|
||||
|
||||
@@ -333,8 +333,13 @@ func _localized_loot_taken(payload: Dictionary) -> String:
|
||||
return message + "."
|
||||
|
||||
func _localized_pickup_refused(payload: Dictionary) -> String:
|
||||
var reason := StringName(payload.get("reason", ""))
|
||||
if reason == &"no_ground_item":
|
||||
return "Rien à ramasser."
|
||||
var item := _localized_item_quantity(payload)
|
||||
return "Inventaire plein : %s non ramassé." % item if not item.is_empty() else "Inventaire plein."
|
||||
if reason == &"capacity" or reason == &"inventory_full":
|
||||
return "Inventaire plein : %s non ramassé." % item if not item.is_empty() else "Inventaire plein."
|
||||
return "Ramassage impossible."
|
||||
|
||||
func _localized_reward_parts(payload: Dictionary) -> PackedStringArray:
|
||||
var parts := _localized_items(payload.get("items", []))
|
||||
|
||||
@@ -21,15 +21,17 @@ func get_last_feedback_state() -> Dictionary:
|
||||
|
||||
func begin(event: GameEvent, presentation_kind: StringName) -> void:
|
||||
var color := _color_for(presentation_kind)
|
||||
var feedback_label := label_for_event(event, presentation_kind)
|
||||
_last_feedback_state = {
|
||||
"kind": presentation_kind,
|
||||
"duration_ms": EFFECT_DURATION_MS,
|
||||
"color": color,
|
||||
"label": feedback_label,
|
||||
}
|
||||
if _test_mode:
|
||||
return
|
||||
var label := Label.new()
|
||||
label.text = _label_for(event, presentation_kind)
|
||||
label.text = feedback_label
|
||||
label.modulate = color
|
||||
label.position = Vector2(390, 80)
|
||||
label.z_index = 20
|
||||
@@ -47,9 +49,20 @@ func _color_for(presentation_kind: StringName) -> Color:
|
||||
&"quest": return QUEST_COLOR
|
||||
_: return LOOT_COLOR
|
||||
|
||||
func _label_for(event: GameEvent, presentation_kind: StringName) -> String:
|
||||
func label_for_event(event: GameEvent, presentation_kind: StringName) -> String:
|
||||
if presentation_kind == &"loot":
|
||||
match event.kind:
|
||||
&"loot_dropped": return "✦ BUTIN AU SOL"
|
||||
&"item_picked_up": return "✦ OBJET RAMASSÉ"
|
||||
&"loot_taken": return "✦ BUTIN RÉCUPÉRÉ"
|
||||
&"pickup_refused":
|
||||
var reason := StringName(event.payload.get("reason", ""))
|
||||
if reason == &"no_ground_item":
|
||||
return "! RIEN À RAMASSER"
|
||||
if reason == &"capacity" or reason == &"inventory_full":
|
||||
return "! INVENTAIRE PLEIN"
|
||||
return "! RAMASSAGE IMPOSSIBLE"
|
||||
match presentation_kind:
|
||||
&"loot": return "✦ BUTIN AU SOL"
|
||||
&"trap": return "! TRAP"
|
||||
&"quest": return "✦ QUEST UPDATED"
|
||||
_: return event.message
|
||||
|
||||
Reference in New Issue
Block a user