artificer/api/schemas/skill_info_details.zig
2025-01-03 17:35:44 +02:00

24 lines
684 B
Zig

// zig fmt: off
const std = @import("std");
const json_utils = @import("../json_utils.zig");
const Resource = @import("./resource.zig");
const Store = @import("../store.zig");
const SimpleItem = @import("./simple_item.zig");
const SkillInfoDetails = @This();
pub const Items = SimpleItem.BoundedArray(Resource.max_drops);
xp: u64,
items: Items,
pub fn parse(store: *Store, obj: std.json.ObjectMap) !SkillInfoDetails {
const xp = try json_utils.getPositiveIntegerRequired(obj, "xp");
const items = json_utils.getArray(obj, "items") orelse return error.MissingProperty;
return SkillInfoDetails{
.xp = xp,
.items = try Items.parse(store, items)
};
}