artificer/api/schemas/character_fight.zig

28 lines
974 B
Zig

const std = @import("std");
const Store = @import("../store.zig");
const json_utils = @import("../json_utils.zig");
const json = std.json;
const Allocator = std.mem.Allocator;
const Cooldown = @import("./cooldown.zig");
const Fight = @import("./fight.zig");
const Character = @import("./character.zig");
const CharacterFight = @This();
cooldown: Cooldown,
fight: Fight,
character: Character,
pub fn parse(store: *Store, obj: json.ObjectMap, allocator: Allocator) !CharacterFight {
const cooldown = json_utils.getObject(obj, "cooldown") orelse return error.MissingProperty;
const fight = json_utils.getObject(obj, "fight") orelse return error.MissingProperty;
const character = json_utils.getObject(obj, "character") orelse return error.MissingProperty;
return CharacterFight{
.cooldown = try Cooldown.parse(cooldown),
.fight = try Fight.parse(store, fight),
.character = try Character.parse(store, character, allocator)
};
}