形象:修改字典表
This commit is contained in:
@@ -90,73 +90,3 @@ export function addUserToChannel(channel: Channel, user: ChannelUser) {
|
||||
channel.add(uid, sid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解锁头像/相框
|
||||
* @param type 解锁类型(获得武将/好感达到)
|
||||
* @param num 参数(武将id/好感等级)
|
||||
*/
|
||||
export async function unlockFigure(roleId: string, type: number, num: number, role?: RoleType) {
|
||||
if(!role || !role.heads || !role.frames) {
|
||||
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
||||
}
|
||||
let { heads, frames, spines } = role;
|
||||
let canUnLockList = gameData.figureCondition.get(type);
|
||||
if(canUnLockList) {
|
||||
for(let {id, param} of canUnLockList) {
|
||||
let flag = false; // 是否达成条件
|
||||
if(type == FIGURE_UNLOCK_CONDITION.GET_HERO) {
|
||||
if(num == param) flag = true;
|
||||
} else if (type == FIGURE_UNLOCK_CONDITION.HERO_FAVOR) {
|
||||
if(num >= param) flag = true;
|
||||
}
|
||||
if(!flag) continue;
|
||||
|
||||
let dicGood = gameData.goods.get(id);
|
||||
if(!dicGood) continue;
|
||||
let dicItid = ITID.get(dicGood.itid);
|
||||
if(!dicItid) continue;
|
||||
|
||||
if(dicItid.type == CONSUME_TYPE.HEAD) {
|
||||
unlockSingleFigure(heads, id, type);
|
||||
} else if (dicItid.type == CONSUME_TYPE.FRAME) {
|
||||
unlockSingleFigure(frames, id, type);
|
||||
} else if (dicItid.type == CONSUME_TYPE.SPINE) {
|
||||
unlockSingleFigure(spines, id, type);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines });
|
||||
}
|
||||
}
|
||||
|
||||
function unlockSingleFigure(dbFigures: Figure[], id: number, type: number) {
|
||||
let figure = dbFigures.find(cur => cur.id == id);
|
||||
if(!figure) {
|
||||
figure = new Figure(id, false);
|
||||
dbFigures.push(figure);
|
||||
}
|
||||
if(figure.unlocked) return; // 已解锁过
|
||||
if(figure.unlockedType.includes(type)) return;
|
||||
|
||||
figure.unlockedType.push(type);
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
|
||||
let hasUnlockedAll = true;
|
||||
for(let {type} of dicGoods.condition) {
|
||||
if(!figure.unlockedType.includes(type)) {
|
||||
hasUnlockedAll = false; break;
|
||||
}
|
||||
}
|
||||
if(hasUnlockedAll) {
|
||||
figure.unlocked = true;
|
||||
|
||||
if(dicGoods.timeLimit) {
|
||||
figure.time = getBeforeDaySeconds(-1 * dicGoods.timeLimit); // timeLimit天以后
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user