29 lines
883 B
Zig
29 lines
883 B
Zig
const std = @import("std");
|
|
const Server = @import("../server.zig");
|
|
const json_utils = @import("../json_utils.zig");
|
|
const json = std.json;
|
|
const ItemId = Server.ItemId;
|
|
|
|
const Cooldown = @import("./cooldown.zig");
|
|
|
|
const EquipRequest = @This();
|
|
|
|
cooldown: Cooldown,
|
|
item: ItemId,
|
|
|
|
pub fn parse(api: *Server, 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 api.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
|
|
};
|
|
}
|