import { getArmyDevelopConsume } from '../pubUtils/data';
import { ScienceTree, GuildRefineModel } from '../db/GuildRefine';
/**
 * 开启符合条件的科技树
 * @param code 
 */
export async function openGuildRefine(code: string) {
    let developConsumes = getArmyDevelopConsume();
    let scienceTrees = new Array<ScienceTree>();
    developConsumes.forEach(developConsume=>{
        if (developConsume.fundConsume == 0 && developConsume.timeConsume == 0) {
            //无前置条件，无研发时间的科技树直接可以点亮
            let scienceTree = new ScienceTree();
            scienceTree.id = developConsume.id;
            scienceTree.endTime = 0
            scienceTree.assistRoleIds = [];
            scienceTrees.push(scienceTree);
        }
    });
    let guildRefine = await GuildRefineModel.createScienceTree(code, scienceTrees);
    return guildRefine;
}
