artificer/lib/task.zig

40 lines
941 B
Zig

const Api = @import("artifacts-api");
const Position = Api.Position;
pub const UntilCondition = union(enum) {
xp: u64,
item: Api.ItemIdQuantity,
};
pub const Task = union(enum) {
fight: struct {
at: Position,
until: UntilCondition,
progress: u64 = 0,
},
gather: struct {
at: Position,
until: UntilCondition,
progress: u64 = 0,
},
craft: struct {
at: Position,
target: Api.ItemIdQuantity,
progress: u64 = 0,
},
pub fn isComplete(self: Task) bool {
return switch (self) {
.fight => |args| {
return args.progress >= args.until.item.quantity;
},
.gather => |args| {
return args.progress >= args.until.item.quantity;
},
.craft => |args| {
return args.progress >= args.target.quantity;
}
};
}
};