const std = @import("std");
const protocol = @import("protocol");
const Session = @import("../Session.zig");
const Packet = @import("../Packet.zig");
const Config = @import("../services/config.zig");
const Data = @import("../data.zig");

const UidGenerator = @import("../services/item.zig").UidGenerator;
const ArrayList = std.ArrayList;
const Allocator = std.mem.Allocator;
const CmdID = protocol.CmdID;

pub const LineupManager = struct {
    allocator: std.mem.Allocator,
    pub fn init(allocator: std.mem.Allocator) LineupManager {
        return LineupManager{ .allocator = allocator };
    }
    pub fn createLineup(self: *LineupManager) !protocol.LineupInfo {
        const config = try Config.loadGameConfig(self.allocator, "config.json");

        var lineup = protocol.LineupInfo.init(self.allocator);
        lineup.mp = 5;
        lineup.max_mp = 5;
        lineup.name = .{ .Const = "CastoriceSR" };

        for (config.avatar_config.items, 0..) |avatarConf, idx| {
            var avatar = protocol.LineupAvatar.init(self.allocator);
            avatar.id = avatarConf.id;
            avatar.slot = @intCast(idx);
            avatar.satiety = 0;
            avatar.hp = avatarConf.hp * 100;
            avatar.sp_bar = .{ .sp_cur = avatarConf.sp * 100, .sp_max = 10000 };
            avatar.avatar_type = protocol.AvatarType.AVATAR_FORMAL_TYPE;
            try lineup.avatar_list.append(avatar);
        }

        return lineup;
    }
};
