use std::collections::HashMap;

use crate::logic::BuddyTeamType;

use super::{EquippedBuddyDataItem, InLevelAvatarDataItem};

pub struct TeamDataItem {
    pub avatar_member_list: Vec<InLevelAvatarDataItem>,
    pub equipped_buddy_list: Vec<EquippedBuddyDataItem>,
}

impl TeamDataItem {
    pub fn new(avatars: &[u32], buddy_id: u32) -> Self {
        Self {
            avatar_member_list: avatars
                .iter()
                .map(|id| InLevelAvatarDataItem {
                    avatar_id: *id,
                    mp_property_override: HashMap::new(),
                })
                .collect(),
            equipped_buddy_list: (buddy_id != 0)
                .then_some(vec![EquippedBuddyDataItem {
                    buddy_id,
                    buddy_team: BuddyTeamType::Assisting,
                    override_property_map: HashMap::new(),
                }])
                .unwrap_or_default(),
        }
    }
}
