34 lines
1.2 KiB
Zig
34 lines
1.2 KiB
Zig
// zig fmt: off
|
|
const std = @import("std");
|
|
const Store = @import("../store.zig");
|
|
const json_utils = @import("../json_utils.zig");
|
|
const Character = @import("./character.zig");
|
|
const Cooldown = @import("./cooldown.zig");
|
|
const SkillInfoDetails = @import("./skill_info_details.zig");
|
|
|
|
const SkillUsageResult = @This();
|
|
|
|
pub const Details = SkillInfoDetails;
|
|
|
|
cooldown: Cooldown,
|
|
details: Details,
|
|
character: Character,
|
|
|
|
fn parse(store: *Store, obj: std.json.ObjectMap) !SkillUsageResult {
|
|
const cooldown = json_utils.getObject(obj, "cooldown") orelse return error.MissingProperty;
|
|
const details = json_utils.getObject(obj, "details") orelse return error.MissingProperty;
|
|
const character = json_utils.getObject(obj, "character") orelse return error.MissingProperty;
|
|
|
|
return SkillUsageResult{
|
|
.character = try Character.parse(store, character),
|
|
.cooldown = try Cooldown.parse(store, cooldown),
|
|
.details = try SkillInfoDetails.parse(store, details)
|
|
};
|
|
}
|
|
|
|
pub fn parseAndUpdate(store: *Store, obj: std.json.ObjectMap) !SkillUsageResult {
|
|
const result = try parse(store, obj);
|
|
_ = try store.characters.appendOrUpdate(result.character);
|
|
return result;
|
|
}
|