Files
TheriapolisV3/Theriapolis.Core/Items/ItemInstance.cs
T
Christopher Wiebe b451f83174 Initial commit: Theriapolis baseline at port/godot branch point
Captures the pre-Godot-port state of the codebase. This is the rollback
anchor for the Godot port (M0 of theriapolis-rpg-implementation-plan-godot-port.md).
All Phase 0 through Phase 6.5 work is included; Phase 7 is in flight.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 20:40:51 -07:00

39 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Theriapolis.Core.Data;
namespace Theriapolis.Core.Items;
/// <summary>
/// One stack of items in an <see cref="Inventory"/>. Holds a reference to the
/// immutable <see cref="ItemDef"/> plus per-instance state: how many in the
/// stack, current condition, and (optionally) the slot the item is equipped
/// into.
///
/// Phase 5 ships condition as a no-op (always 100); it's reserved for damage,
/// repairs, and weapon breaking that arrive in Phase 5.5+.
/// </summary>
public sealed class ItemInstance
{
public ItemDef Def { get; }
public int Qty { get; set; }
/// <summary>Condition, 0..100. 100 = pristine. Phase 5 always uses 100.</summary>
public int Condition { get; set; } = 100;
/// <summary>Null while in the inventory bag; set when the item is equipped.</summary>
public EquipSlot? EquippedAt { get; set; }
public ItemInstance(ItemDef def, int qty = 1)
{
Def = def ?? throw new ArgumentNullException(nameof(def));
if (qty < 1) throw new ArgumentOutOfRangeException(nameof(qty), "qty must be ≥ 1");
Qty = qty;
}
public float TotalWeightLb => Def.WeightLb * Qty;
public override string ToString() =>
EquippedAt is null
? $"{Def.Name}{(Qty > 1 ? $" ×{Qty}" : "")}"
: $"{Def.Name} (equipped: {EquippedAt})";
}