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,49 @@
|
||||
using Theriapolis.Core.Data;
|
||||
using Theriapolis.Core.Rules.Stats;
|
||||
|
||||
namespace Theriapolis.Core.Items;
|
||||
|
||||
/// <summary>
|
||||
/// Body-size compatibility check for equipment. Per equipment.md:
|
||||
/// "Most equipment comes in Small, Medium, and Large variants. Using
|
||||
/// equipment not sized for your body imposes disadvantage on relevant
|
||||
/// checks unless it has the Adaptive property."
|
||||
///
|
||||
/// Returns <see cref="MatchResult.Match"/> when the item lists the wearer's
|
||||
/// size, <see cref="MatchResult.Adaptive"/> when not listed but the item has
|
||||
/// the "adaptive" property (no penalty), and
|
||||
/// <see cref="MatchResult.WrongSize"/> otherwise (wearer takes disadvantage).
|
||||
/// </summary>
|
||||
public static class SizeMatch
|
||||
{
|
||||
public enum MatchResult : byte
|
||||
{
|
||||
Match = 0, // item explicitly fits the wearer's size
|
||||
Adaptive = 1, // item is universally adaptive — no disadvantage
|
||||
WrongSize = 2, // wearer can equip it but suffers disadvantage
|
||||
}
|
||||
|
||||
public static MatchResult Check(ItemDef def, SizeCategory wearerSize)
|
||||
{
|
||||
string wearerKey = wearerSize switch
|
||||
{
|
||||
SizeCategory.Tiny => "tiny",
|
||||
SizeCategory.Small => "small",
|
||||
SizeCategory.Medium => "medium",
|
||||
SizeCategory.MediumLarge => "medium", // M-Large uses Medium-sized gear
|
||||
SizeCategory.Large => "large",
|
||||
SizeCategory.Huge => "large", // closest available
|
||||
_ => "medium",
|
||||
};
|
||||
|
||||
foreach (var s in def.Sizes)
|
||||
if (string.Equals(s, wearerKey, StringComparison.OrdinalIgnoreCase))
|
||||
return MatchResult.Match;
|
||||
|
||||
foreach (var p in def.Properties)
|
||||
if (string.Equals(p, "adaptive", StringComparison.OrdinalIgnoreCase))
|
||||
return MatchResult.Adaptive;
|
||||
|
||||
return MatchResult.WrongSize;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user