const std = @import("std"); const Store = @import("../store.zig"); const json_utils = @import("../json_utils.zig"); const json = std.json; const ItemId = Store.ItemId; const Cooldown = @import("./cooldown.zig"); const EquipRequest = @This(); cooldown: Cooldown, item: ItemId, pub fn parse(store: *Store, obj: json.ObjectMap) !EquipRequest { const cooldown = json_utils.getObject(obj, "cooldown") orelse return error.MissingProperty; const item = json_utils.getObject(obj, "item") orelse return error.MissingProperty; const item_code = json_utils.getString(item, "code") orelse return error.MissingProperty; const item_id = try store.getItemId(item_code); // TODO: Might as well save information about time, because full details about it are given return EquipRequest{ .cooldown = try Cooldown.parse(cooldown), .item = item_id }; }