// priority: 111

//不想动脑子了，以后再写
const remove_persistentData = {
    //营养值上限
    'ying_yang': ''
}
PlayerEvents.inventoryClosed(event => {
    let player = event.player;
    if (!player) return;
    remove_attribute_and_persistentData(event)
});

//玩家登录事件
PlayerEvents.loggedIn(event => {
    let player = event.player;
    if (!player) return;
    remove_attribute_and_persistentData(event)
})

//清除之前的加成，防止叠加数值
function remove_attribute_and_persistentData(event) {
    let player = event.player
    //清除persistentData,目前只有营养值，就只写删营养值吧
    // 获取当前营养值上限
    let maxCount = player.persistentData.getInt(YingYangCountMax) ?? defaultYingYangCountMax;
    //获取存储的effect增加的营养值上限
    let amount = player.persistentData.getInt('ying_yang_effect_attribute') ?? 0
    //获取effect的值
    let effect = get_specific_effect(player, 'ying_yang').level || 0
    
    //更新营养值上限
    updateYingYangMaxCount(player, maxCount - amount + effect)
    //更新存储的effect增加的营养值上限
    player.persistentData.putInt('ying_yang_effect_attribute', effect)

}
