形象:作为物品获得
This commit is contained in:
@@ -8,7 +8,7 @@ import { calAllHeroCe } from './playerCeService';
|
|||||||
import { ItemModel } from '../db/Item';
|
import { ItemModel } from '../db/Item';
|
||||||
import { STATUS } from '../consts/statusCode';
|
import { STATUS } from '../consts/statusCode';
|
||||||
import { pinus } from 'pinus';
|
import { pinus } from 'pinus';
|
||||||
import { addEquips, addBags, addSkins } from '../pubUtils/itemUtils';
|
import { addEquips, addBags, addSkins, addFigure } from '../pubUtils/itemUtils';
|
||||||
import { EquipInter, ItemInter, BagInter } from '../pubUtils/interface';
|
import { EquipInter, ItemInter, BagInter } from '../pubUtils/interface';
|
||||||
import { gameData } from '../pubUtils/data';
|
import { gameData } from '../pubUtils/data';
|
||||||
import { uniq, indexOf, findIndex } from 'underscore';
|
import { uniq, indexOf, findIndex } from 'underscore';
|
||||||
@@ -146,6 +146,15 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
|||||||
if (!!bagInfos.length)
|
if (!!bagInfos.length)
|
||||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, {goods: bagInfos}), uids);
|
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, {goods: bagInfos}), uids);
|
||||||
|
|
||||||
|
|
||||||
|
let figureInfo = await addFigure(roleId, figures);
|
||||||
|
for (let id of figures) {//皮肤推送
|
||||||
|
showItems.push({id, count: 1});
|
||||||
|
}
|
||||||
|
if (!!figureInfo) {
|
||||||
|
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
|
||||||
|
}
|
||||||
|
|
||||||
let skinInfos = [];
|
let skinInfos = [];
|
||||||
let addSkinIds = [];
|
let addSkinIds = [];
|
||||||
for (let skinId of skins) {//皮肤推送
|
for (let skinId of skins) {//皮肤推送
|
||||||
@@ -207,7 +216,7 @@ function sortItems (goods: Array<ItemInter>, bags: Array<BagInter>, skins: Array
|
|||||||
currencysMap[curname] = (currencysMap[curname]||0 )+ good.count;
|
currencysMap[curname] = (currencysMap[curname]||0 )+ good.count;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (type == CONSUME_TYPE.SKIN) {
|
if (type == CONSUME_TYPE.HEAD || type == CONSUME_TYPE.FRAME || type == CONSUME_TYPE.SPINE ) {
|
||||||
let index = indexOf(figures, good.id);
|
let index = indexOf(figures, good.id);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
figures.push(good.id);
|
figures.push(good.id);
|
||||||
|
|||||||
@@ -42,52 +42,52 @@ module.exports = {
|
|||||||
'required uInt32 code': 2,
|
'required uInt32 code': 2,
|
||||||
'required Data data': 3
|
'required Data data': 3
|
||||||
},
|
},
|
||||||
'onHeroSkinChange': {
|
// 'onHeroSkinChange': {
|
||||||
'message Data': {
|
// 'message Data': {
|
||||||
"message SkinInfo": {
|
// "message SkinInfo": {
|
||||||
"message Skin": {
|
// "message Skin": {
|
||||||
'required uInt32 id': 1,
|
// 'required uInt32 id': 1,
|
||||||
'required boolean enable': 2
|
// 'required boolean enable': 2
|
||||||
},
|
// },
|
||||||
'repeated Skin skins': 1,
|
// 'repeated Skin skins': 1,
|
||||||
},
|
// },
|
||||||
'repeated SkinInfo skinInfos': 1
|
// 'repeated SkinInfo skinInfos': 1
|
||||||
},
|
// },
|
||||||
'required string msg': 1,
|
// 'required string msg': 1,
|
||||||
'required uInt32 code': 2,
|
// 'required uInt32 code': 2,
|
||||||
'required Data data': 3
|
// 'required Data data': 3
|
||||||
},
|
// },
|
||||||
'onEquipAdd': {
|
// 'onEquipAdd': {
|
||||||
'message Data': {
|
// 'message Data': {
|
||||||
"message EquipInfo": {
|
// "message EquipInfo": {
|
||||||
"message RandSe": {
|
// "message RandSe": {
|
||||||
'required uInt32 id': 1,
|
// 'required uInt32 id': 1,
|
||||||
'required uInt32 seid': 2,
|
// 'required uInt32 seid': 2,
|
||||||
'required int32 rand': 3,
|
// 'required int32 rand': 3,
|
||||||
'required boolean locked': 4
|
// 'required boolean locked': 4
|
||||||
},
|
// },
|
||||||
"message Hole": {
|
// "message Hole": {
|
||||||
'required uInt32 id': 1,
|
// 'required uInt32 id': 1,
|
||||||
'required boolean isOpen': 2,
|
// 'required boolean isOpen': 2,
|
||||||
'required uInt32 jewel': 3
|
// 'required uInt32 jewel': 3
|
||||||
},
|
// },
|
||||||
'repeated Hole holes': 1,
|
// 'repeated Hole holes': 1,
|
||||||
'repeated RandSe randSe': 2,
|
// 'repeated RandSe randSe': 2,
|
||||||
'required uInt32 seqId': 3,
|
// 'required uInt32 seqId': 3,
|
||||||
'required uInt32 id': 4,
|
// 'required uInt32 id': 4,
|
||||||
'required uInt32 hid': 6,
|
// 'required uInt32 hid': 6,
|
||||||
'required uInt32 count': 7,
|
// 'required uInt32 count': 7,
|
||||||
'required uInt32 quality': 8,
|
// 'required uInt32 quality': 8,
|
||||||
'required uInt32 ePlaceId': 9,
|
// 'required uInt32 ePlaceId': 9,
|
||||||
'required uInt32 suitId': 11,
|
// 'required uInt32 suitId': 11,
|
||||||
'required int32 randRange': 12
|
// 'required int32 randRange': 12
|
||||||
},
|
// },
|
||||||
'repeated EquipInfo equipInfos': 1
|
// 'repeated EquipInfo equipInfos': 1
|
||||||
},
|
// },
|
||||||
'required string msg': 1,
|
// 'required string msg': 1,
|
||||||
'required uInt32 code': 2,
|
// 'required uInt32 code': 2,
|
||||||
'required Data data': 3
|
// 'required Data data': 3
|
||||||
},
|
// },
|
||||||
'onEquipDel': {
|
'onEquipDel': {
|
||||||
'message Data': {
|
'message Data': {
|
||||||
'repeated uInt32 equips': 1
|
'repeated uInt32 equips': 1
|
||||||
@@ -95,5 +95,20 @@ module.exports = {
|
|||||||
'required string msg': 1,
|
'required string msg': 1,
|
||||||
'required uInt32 code': 2,
|
'required uInt32 code': 2,
|
||||||
'required Data data': 3
|
'required Data data': 3
|
||||||
}
|
},
|
||||||
|
// 'onHeadChange': {
|
||||||
|
// 'message Data': {
|
||||||
|
// "message FigureInfo": {
|
||||||
|
// 'required int32 id': 1,
|
||||||
|
// 'required bool enable': 2,
|
||||||
|
// 'optional int32 time': 3
|
||||||
|
// },
|
||||||
|
// 'repeated FigureInfo heads': 1,
|
||||||
|
// 'repeated FigureInfo frames': 2,
|
||||||
|
// 'repeated FigureInfo spines': 3
|
||||||
|
// },
|
||||||
|
// 'required string msg': 1,
|
||||||
|
// 'required uInt32 code': 2,
|
||||||
|
// 'required Data data': 3
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -132,17 +132,17 @@ export default class Role extends BaseModel {
|
|||||||
spines: Figure[]; // 拥有的形象
|
spines: Figure[]; // 拥有的形象
|
||||||
|
|
||||||
public get head () { // 虚拟字段head 当前头像
|
public get head () { // 虚拟字段head 当前头像
|
||||||
let curHead = this.heads?.find(cur => cur.enable && cur.time > nowSeconds());
|
let curHead = this.heads?.find(cur => cur.enable && (!cur.time || cur.time > nowSeconds()));
|
||||||
return curHead?curHead.id: EXTERIOR.EXTERIOR_FACE;
|
return curHead?curHead.id: EXTERIOR.EXTERIOR_FACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get frame () { // 虚拟字段frame 当前相框
|
public get frame () { // 虚拟字段frame 当前相框
|
||||||
let curFrame = this.frames?.find(cur => cur.enable && cur.time > nowSeconds());
|
let curFrame = this.frames?.find(cur => cur.enable && (!cur.time || cur.time > nowSeconds()));
|
||||||
return curFrame?curFrame.id: EXTERIOR.EXTERIOR_FACECASE;
|
return curFrame?curFrame.id: EXTERIOR.EXTERIOR_FACECASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get spine () { // 虚拟字段spine 当前形象
|
public get spine () { // 虚拟字段spine 当前形象
|
||||||
let curSpine = this.spines?.find(cur => cur.enable && cur.time > nowSeconds());
|
let curSpine = this.spines?.find(cur => cur.enable && (!cur.time || cur.time > nowSeconds()));
|
||||||
return curSpine?curSpine.id: EXTERIOR.EXTERIOR_APPEARANCE;
|
return curSpine?curSpine.id: EXTERIOR.EXTERIOR_APPEARANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ arr.forEach(o => {
|
|||||||
o.specialAttr = parseSpecialAttr(o.specialAttr);
|
o.specialAttr = parseSpecialAttr(o.specialAttr);
|
||||||
o.specialMaterial = parseSpecialMaterial(o.specialMaterial);
|
o.specialMaterial = parseSpecialMaterial(o.specialMaterial);
|
||||||
o.randomEffect = parseNumberList(o.randomEffect);
|
o.randomEffect = parseNumberList(o.randomEffect);
|
||||||
|
o.timeLimit = o.timelimit;
|
||||||
if (o.goodType == IT_TYPE.EQUIP_PIECE) {
|
if (o.goodType == IT_TYPE.EQUIP_PIECE) {
|
||||||
let good = findWhere(arr, { pieceId: o.good_id });
|
let good = findWhere(arr, { pieceId: o.good_id });
|
||||||
if (!!good)
|
if (!!good)
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ export async function unlockFigure(roleId: string, conditions: {type: number, nu
|
|||||||
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
||||||
}
|
}
|
||||||
let { heads, frames, spines } = role;
|
let { heads, frames, spines } = role;
|
||||||
|
let figureInfo = { heads: [], frames: [], spines: [] };
|
||||||
for(let {type, num} of conditions) {
|
for(let {type, num} of conditions) {
|
||||||
let canUnLockList = gameData.figureCondition.get(type);
|
let canUnLockList = gameData.figureCondition.get(type);
|
||||||
if(canUnLockList) {
|
if(canUnLockList) {
|
||||||
@@ -107,11 +108,14 @@ export async function unlockFigure(roleId: string, conditions: {type: number, nu
|
|||||||
if(!dicItid) continue;
|
if(!dicItid) continue;
|
||||||
|
|
||||||
if(dicItid.type == CONSUME_TYPE.HEAD) {
|
if(dicItid.type == CONSUME_TYPE.HEAD) {
|
||||||
unlockSingleFigure(heads, id, type);
|
let figure = unlockSingleFigure(heads, id, false, type);
|
||||||
|
if(figure && figure.unlocked) figureInfo.heads.push(figure);
|
||||||
} else if (dicItid.type == CONSUME_TYPE.FRAME) {
|
} else if (dicItid.type == CONSUME_TYPE.FRAME) {
|
||||||
unlockSingleFigure(frames, id, type);
|
let figure = unlockSingleFigure(frames, id, false, type);
|
||||||
|
if(figure && figure.unlocked) figureInfo.heads.push(figure);
|
||||||
} else if (dicItid.type == CONSUME_TYPE.SPINE) {
|
} else if (dicItid.type == CONSUME_TYPE.SPINE) {
|
||||||
unlockSingleFigure(spines, id, type);
|
let figure = unlockSingleFigure(spines, id, false, type);
|
||||||
|
if(figure && figure.unlocked) figureInfo.heads.push(figure);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -121,24 +125,62 @@ export async function unlockFigure(roleId: string, conditions: {type: number, nu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines });
|
role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines });
|
||||||
|
return figureInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlockSingleFigure(dbFigures: Figure[], id: number, type: number) {
|
|
||||||
|
// 直接获得形象/相框
|
||||||
|
export async function addFigure(roleId: string, ids: number[]) {
|
||||||
|
let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
||||||
|
|
||||||
|
if(!role) return false;
|
||||||
|
let { heads, frames, spines } = role;
|
||||||
|
|
||||||
|
let figureInfo = { heads: [], frames: [], spines: [] };
|
||||||
|
for(let id of ids) {
|
||||||
|
let dicGoods = gameData.goods.get(id);
|
||||||
|
if(!dicGoods) continue;
|
||||||
|
let dicItid = ITID.get(dicGoods.itid);
|
||||||
|
if(!dicItid) continue;
|
||||||
|
|
||||||
|
if(dicItid.type == CONSUME_TYPE.HEAD) {
|
||||||
|
let figure = unlockSingleFigure(heads, id, true);
|
||||||
|
if(figure && figure.unlocked) figureInfo.heads.push(figure);
|
||||||
|
} else if (dicItid.type == CONSUME_TYPE.FRAME) {
|
||||||
|
let figure = unlockSingleFigure(frames, id, true);
|
||||||
|
if(figure && figure.unlocked) figureInfo.frames.push(figure);
|
||||||
|
} else if (dicItid.type == CONSUME_TYPE.SPINE) {
|
||||||
|
let figure = unlockSingleFigure(spines, id, true);
|
||||||
|
if(figure && figure.unlocked) figureInfo.spines.push(figure);
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines });
|
||||||
|
return figureInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = false, type?: number) {
|
||||||
let figure = dbFigures.find(cur => cur.id == id);
|
let figure = dbFigures.find(cur => cur.id == id);
|
||||||
if(!figure) {
|
if(!figure) {
|
||||||
figure = new Figure(id, false);
|
figure = new Figure(id, false);
|
||||||
dbFigures.push(figure);
|
dbFigures.push(figure);
|
||||||
}
|
}
|
||||||
if(figure.unlocked) return; // 已解锁过
|
if(figure.unlocked) return; // 已解锁过
|
||||||
if(figure.unlockedType.includes(type)) return;
|
|
||||||
|
|
||||||
figure.unlockedType.push(type);
|
|
||||||
let dicGoods = gameData.goods.get(id);
|
let dicGoods = gameData.goods.get(id);
|
||||||
|
|
||||||
let hasUnlockedAll = true;
|
let hasUnlockedAll = true;
|
||||||
for(let {type} of dicGoods.condition) {
|
if(!unlockDirect) { // 不能直接获得,需要通过type解锁
|
||||||
if(!figure.unlockedType.includes(type)) {
|
if(figure.unlockedType.includes(type)) return;
|
||||||
hasUnlockedAll = false; break;
|
|
||||||
|
figure.unlockedType.push(type);
|
||||||
|
|
||||||
|
for(let {type} of dicGoods.condition) {
|
||||||
|
if(!figure.unlockedType.includes(type)) {
|
||||||
|
hasUnlockedAll = false; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(hasUnlockedAll) {
|
if(hasUnlockedAll) {
|
||||||
@@ -149,11 +191,5 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, type: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
return figure
|
||||||
|
|
||||||
// 直接获得形象/相框
|
|
||||||
export async function addFigure(roleId: string, id: number) {
|
|
||||||
let figure = new Figure(id, true, null, false);
|
|
||||||
let role = await RoleModel.addFigure(roleId, id, figure);
|
|
||||||
return role;
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
import { COUNTER, HERO_SYSTEM_TYPE, DEFAULT_LV, DEFAULT_ITEMS, ITID, DEFAULT_GOLD, DEFAULT_HERO_LV, DEFAULT_EQUIPS, DEFAULT_COIN, ADULT_AGE, GUEST_MAX_TIME, GUEST_DAY, FIGURE_UNLOCK_CONDITION } from '@consts';
|
import { COUNTER, HERO_SYSTEM_TYPE, DEFAULT_LV, DEFAULT_ITEMS, ITID, DEFAULT_GOLD, DEFAULT_HERO_LV, DEFAULT_EQUIPS, DEFAULT_COIN, ADULT_AGE, GUEST_MAX_TIME, FIGURE_UNLOCK_CONDITION } from '@consts';
|
||||||
import { DEFAULT_HEROES } from '@consts';
|
import { DEFAULT_HEROES } from '@consts';
|
||||||
import { HeroModel } from '@db/Hero';
|
import { HeroModel } from '@db/Hero';
|
||||||
import { RoleModel } from '@db/Role';
|
import { RoleModel } from '@db/Role';
|
||||||
|
|||||||
Reference in New Issue
Block a user