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>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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})";
|
||||
}
|
||||
Reference in New Issue
Block a user