85 lines
2.8 KiB
Python
85 lines
2.8 KiB
Python
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
FILES = {
|
|
"InventoryDataModel.md": ROOT / "Docs" / "InventoryDataModel.md",
|
|
"AgrarianTypes.h": ROOT / "Source" / "AgrarianGame" / "AgrarianTypes.h",
|
|
"AgrarianInventoryComponent.h": ROOT / "Source" / "AgrarianGame" / "AgrarianInventoryComponent.h",
|
|
"AgrarianInventoryComponent.cpp": ROOT / "Source" / "AgrarianGame" / "AgrarianInventoryComponent.cpp",
|
|
"AgrarianItemDefinitionAsset.h": ROOT / "Source" / "AgrarianGame" / "AgrarianItemDefinitionAsset.h",
|
|
"AGRARIAN_DEVELOPMENT_ROADMAP.md": ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md",
|
|
}
|
|
|
|
EXPECTED = {
|
|
"InventoryDataModel.md": [
|
|
"server authoritative",
|
|
"`FAgrarianItemDefinition`",
|
|
"`UAgrarianItemDefinitionAsset`",
|
|
"`FAgrarianItemStack`",
|
|
"`UAgrarianInventoryComponent`",
|
|
"`ItemId` is the stable key",
|
|
"Pickup:",
|
|
"Drop:",
|
|
"Stack splitting:",
|
|
"Item use:",
|
|
"Equipment:",
|
|
"Carry capacity:",
|
|
"Persistence",
|
|
],
|
|
"AgrarianTypes.h": [
|
|
"struct FAgrarianItemStack",
|
|
"FName ItemId = NAME_None;",
|
|
"int32 Quantity = 0;",
|
|
"float UnitWeight = 0.0f;",
|
|
"bool IsValidStack() const",
|
|
"enum class EAgrarianItemType",
|
|
"struct FAgrarianItemDefinition",
|
|
"int32 MaxStackSize = 99;",
|
|
],
|
|
"AgrarianInventoryComponent.h": [
|
|
"TArray<FAgrarianItemStack> Items;",
|
|
"int32 MaxSlots = 24;",
|
|
"bool HasItem(FName ItemId, int32 Quantity) const;",
|
|
"int32 GetItemCount(FName ItemId) const;",
|
|
"float GetTotalWeight() const;",
|
|
"void ServerAddItem(const FAgrarianItemStack& Stack);",
|
|
"void ServerRemoveItem(FName ItemId, int32 Quantity);",
|
|
"OnRep_Items",
|
|
],
|
|
"AgrarianInventoryComponent.cpp": [
|
|
"SetIsReplicatedByDefault(true);",
|
|
"DOREPLIFETIME(UAgrarianInventoryComponent, Items);",
|
|
"GetOwner()->HasAuthority()",
|
|
"Existing.ItemId == Stack.ItemId",
|
|
"Items.Num() >= MaxSlots",
|
|
"OnInventoryChanged.Broadcast();",
|
|
],
|
|
"AgrarianItemDefinitionAsset.h": [
|
|
"class UAgrarianItemDefinitionAsset",
|
|
"FAgrarianItemDefinition Definition;",
|
|
"FAgrarianItemStack MakeStack(int32 Quantity) const;",
|
|
],
|
|
"AGRARIAN_DEVELOPMENT_ROADMAP.md": [
|
|
"[x] Design inventory data model.",
|
|
],
|
|
}
|
|
|
|
|
|
def main():
|
|
missing = []
|
|
for label, path in FILES.items():
|
|
text = path.read_text(encoding="utf-8")
|
|
for snippet in EXPECTED[label]:
|
|
if snippet not in text:
|
|
missing.append(f"{label}: {snippet}")
|
|
|
|
if missing:
|
|
raise RuntimeError("Inventory data model verification failed: " + "; ".join(missing))
|
|
|
|
print("Agrarian inventory data model verification complete.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|