✨ feat(宝物): 宝物seqId修改
This commit is contained in:
@@ -201,15 +201,15 @@ export class ArtifactHandler {
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
let taskCount = 0;
|
||||
const batchCode = genCode(10), delSeqIds: number[] = [];
|
||||
const batchCode = genCode(10), delSeqIds: (number|string)[] = [];
|
||||
for(let [_, { quality, canComposeAll }] of gameData.artifactQualityById) {
|
||||
if(!canComposeAll) continue;
|
||||
|
||||
let artifacts = await ArtifactModel.findByQuality(roleId, quality);
|
||||
let used: number[] = [], materials: ItemInter[] = [], target: ArtifactModelUpdate[] = [];
|
||||
let used: (number|string)[] = [], materials: ItemInter[] = [], target: ArtifactModelUpdate[] = [];
|
||||
for(let artifact of artifacts) {
|
||||
if(used.indexOf(artifact.seqId) > -1) continue;
|
||||
let tmpUsed: number[] = [artifact.seqId];
|
||||
let tmpUsed: (number|string)[] = [artifact.seqId];
|
||||
let dicNextArtifact = getNextArtifact(artifact.artifactId);
|
||||
if(!dicNextArtifact) continue;
|
||||
|
||||
@@ -336,7 +336,7 @@ export class ArtifactHandler {
|
||||
let artifacts = await ArtifactModel.findbySeqIds(roleId, seqIds);
|
||||
if (artifacts.length < seqIds.length) return resResult(STATUS.ARTIFACT_IS_NOT_FIND);
|
||||
|
||||
let cost: ItemInter[] = [], add: ItemInter[] = [], delSeqIds: number[] = [];
|
||||
let cost: ItemInter[] = [], add: ItemInter[] = [], delSeqIds: (number|string)[] = [];
|
||||
for(let artifact of artifacts) {
|
||||
if(artifact.hid > 0 || hasArtifactStrength(artifact)) return resResult(STATUS.ARTIFACT_CANNOT_DECOMPOSE);
|
||||
let dicArtifact = getArtifactWithQuality(artifact.artifactId);
|
||||
|
||||
@@ -28,7 +28,7 @@ import { isNumber } from 'underscore';
|
||||
*/
|
||||
export async function useGiftPackage(roleId: string, roleName: string, sid: string, serverId: number, guildCode: string, giftID: number, selected: Array<number> = [], giftCount: number) {
|
||||
console.log("bbbbbbbb", giftID, selected)
|
||||
let result: { goods: {id: number, count: number, seqId?: number, isBag?: boolean}[], addHeros: any[]} = { goods: [], addHeros: [] }
|
||||
let result: { goods: {id: number, count: number, seqId?: number|string, isBag?: boolean}[], addHeros: any[]} = { goods: [], addHeros: [] }
|
||||
let giftPackageData = gameData.giftPackage.get(giftID);
|
||||
if (!giftPackageData) {
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
|
||||
@@ -1680,23 +1680,24 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
}
|
||||
case "role.artifactHandler.putOn":
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.seqId, msg.hid)) return false;
|
||||
if(!checkSeqId(msg.seqId)) return false;
|
||||
if(!checkNaturalNumbers(msg.hid)) return false;
|
||||
break;
|
||||
}
|
||||
case "role.artifactHandler.putOff":
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.seqId)) return false;
|
||||
if(!checkSeqId(msg.seqId)) return false;
|
||||
break;
|
||||
}
|
||||
case "role.artifactHandler.lvUp":
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.seqId)) return false;
|
||||
if(!checkSeqId(msg.seqId)) return false;
|
||||
if(!checkBoolean(msg.isOneClick)) return false;
|
||||
break;
|
||||
}
|
||||
case "role.artifactHandler.compose":
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.seqId)) return false;
|
||||
if(!checkSeqId(msg.seqId)) return false;
|
||||
if(!checkNumberArray(msg.material)) return false;
|
||||
if(!checkArrayCanEmpty(msg.generalItems)) return false;
|
||||
for(let { id, count } of msg.generalItems) {
|
||||
@@ -1706,14 +1707,15 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
}
|
||||
case "role.artifactHandler.transfer":
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.seqId, msg.type)) return false;
|
||||
if(!checkSeqId(msg.seqId)) return false;
|
||||
if(!checkNaturalNumbers(msg.type)) return false;
|
||||
break;
|
||||
}
|
||||
case "role.artifactHandler.previewRebuild":
|
||||
case "role.artifactHandler.rebuild":
|
||||
case "role.artifactHandler.decompose":
|
||||
{
|
||||
if(!checkNumberArray(msg.seqIds)) return false;
|
||||
if(!checkSeqId(msg.seqIds)) return false;
|
||||
break;
|
||||
}
|
||||
case "role.friendHandler.searchUser":
|
||||
@@ -2197,4 +2199,8 @@ function checkMailType(mailType: any) {
|
||||
if(!checkNaturalNumbers(mailType)) return false;
|
||||
if(!checkIsInEnum(GM_MAIL_TYPE, mailType)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkSeqId(...seqIds: (number|string)[]) {
|
||||
return checkNaturalNumbers(...<number[]>seqIds)||checkNaturalStrings(...<string[]>seqIds);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
export async function addItems(roleId: string, roleName: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
|
||||
goods = filterGoods(goods, obj => obj.id, roleId, reason);
|
||||
let { items, jewels, gold, coin, ap, skins, figures, artifacts, activityItems } = sortItems(goods, HANDLE_REWARD_TYPE.RECEIVE);
|
||||
let showItems: { id: number, seqId?: number, count: number, isBag?: boolean, expireTime?: number }[] = [];
|
||||
let showItems: { id: number, seqId?: number|string, count: number, isBag?: boolean, expireTime?: number }[] = [];
|
||||
let role = await RoleModel.findByRoleId(roleId, '-warCount -topLineup');
|
||||
// 1. 装备处理
|
||||
if(jewels.length > 0) {
|
||||
@@ -266,7 +266,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
|
||||
if(artifacts.length > 0) {
|
||||
let { artifactCount = 0 } = role;
|
||||
let incArtifacts = artifacts, mailArtifacts: { id?: number, seqId?: number }[] = [];
|
||||
let incArtifacts = artifacts, mailArtifacts: { id?: number, seqId?: number|string }[] = [];
|
||||
if(artifacts.length + artifactCount > BAG.BAG_ARTIFACT_UPLIMITED) { // 装备上限
|
||||
let inc = BAG.BAG_ARTIFACT_UPLIMITED - artifactCount;
|
||||
if(inc < 0) inc = 0;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { errlogger } from '../../util/logger';
|
||||
export function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) {
|
||||
let items: { id: number, count: number }[] = []; // 可叠加道具
|
||||
let jewels: { seqId?: number, id?: number, hid?: number }[] = []; // 不可叠加装备
|
||||
let artifacts: { seqId?: number, id?: number }[] = []; // 不可叠加宝物
|
||||
let artifacts: { seqId?: number|string, id?: number }[] = []; // 不可叠加宝物
|
||||
let gold: { count: number, isPay: boolean }[] = []; // 金币
|
||||
let coin: number[] = [];
|
||||
let ap: number = 0;
|
||||
@@ -34,7 +34,7 @@ export function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) {
|
||||
}
|
||||
} else {
|
||||
if(!!good.seqId) {
|
||||
jewels.push({ seqId: good.seqId });
|
||||
jewels.push({ seqId: <number>good.seqId });
|
||||
}
|
||||
}
|
||||
} else if (table == ITEM_TABLE.ITEM) { // 可叠加道具
|
||||
@@ -112,8 +112,8 @@ export function getCoinEventProperties(inc: number, count: number, reason: ITEM_
|
||||
return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason }
|
||||
}
|
||||
|
||||
export function combineItems(items: { id?: number, count?: number, seqId?: number, isBag?: boolean }[]) {
|
||||
let result: { id: number, count: number, seqId?: number, isBag?: boolean }[] = [];
|
||||
export function combineItems(items: { id?: number, count?: number, seqId?: number|string, isBag?: boolean }[]) {
|
||||
let result: { id: number, count: number, seqId?: number|string, isBag?: boolean }[] = [];
|
||||
for(let { id, count = 1, seqId, isBag } of items) {
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
let dicItid = ITID.get(dicGoods.itid);
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { CounterModel } from './Counter';
|
||||
import { COUNTER } from '../consts';
|
||||
import { RoleModel } from './Role';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
|
||||
/**
|
||||
* 宝物
|
||||
*/
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
@index({ roleId: 1, seqId: 1, id: 1 })
|
||||
@index({ seqId: 1 })
|
||||
@index({ roleId: 1, quality: 1 })
|
||||
@index({ batchCode: 1 })
|
||||
@index({ status: 1 })
|
||||
@@ -18,7 +16,7 @@ export default class Artifact extends BaseModel {
|
||||
|
||||
// 主键: artifact,不同形态的宝物分开词条
|
||||
@prop({ required: true })
|
||||
seqId: number; // 唯一id
|
||||
seqId: number|string; // 唯一id
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 玩家id
|
||||
@@ -50,12 +48,12 @@ export default class Artifact extends BaseModel {
|
||||
@prop({ required: true, default: 1 })
|
||||
status: number; // 装备 1-生成 0-被合成删除
|
||||
|
||||
public static async findbySeqIds(roleId: string, seqIds: number[], select?: string) {
|
||||
public static async findbySeqIds(roleId: string, seqIds: (number|string)[], select?: string) {
|
||||
const result: ArtifactModelType[] = await ArtifactModel.find({ roleId, seqId: { $in: seqIds }, status: 1 }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findbySeqId(roleId: string, seqId: number, select?: string) {
|
||||
public static async findbySeqId(roleId: string, seqId: number|string, select?: string) {
|
||||
const result: ArtifactModelType = await ArtifactModel.findOne({ roleId, seqId, status: 1 }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
@@ -67,7 +65,7 @@ export default class Artifact extends BaseModel {
|
||||
}
|
||||
|
||||
public static async createArtifact(artifactInfo: ArtifactModelUpdate) {
|
||||
const seqId = await CounterModel.getNewCounter(COUNTER.ARTIFACT_ID);
|
||||
const seqId = genCode(10);
|
||||
|
||||
const doc = new ArtifactModel();
|
||||
const artifact = Object.assign(doc.toJSON(), {seqId}, artifactInfo);
|
||||
@@ -85,21 +83,21 @@ export default class Artifact extends BaseModel {
|
||||
return insertInfo;
|
||||
}
|
||||
|
||||
public static async putOnOrOff(roleId: string, seqId: number, hid: number, lv?: number) {
|
||||
public static async putOnOrOff(roleId: string, seqId: number|string, hid: number, lv?: number) {
|
||||
let update: ArtifactModelUpdate = { hid };
|
||||
if(lv != undefined) update.lv = lv;
|
||||
let rec: ArtifactModelType = await ArtifactModel.findOneAndUpdate({ roleId, seqId }, { $set: update }, { new: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async deleteBySeqIds(roleId: string, seqIds: number[]) {
|
||||
public static async deleteBySeqIds(roleId: string, seqIds: (number|string)[]) {
|
||||
let result: ArtifactModelType[] = await ArtifactModel.findbySeqIds(roleId, seqIds);
|
||||
let delResult: { n: number, nModified: number, ok: number } = await ArtifactModel.updateMany({ roleId, seqId: { $in: seqIds } }, { $set: { status: 0 } });
|
||||
await RoleModel.increaseArtifact(roleId, -1 * delResult.nModified);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateInfoBySeqId(roleId: string, seqId: number, update: ArtifactModelUpdate) {
|
||||
public static async updateInfoBySeqId(roleId: string, seqId: number|string, update: ArtifactModelUpdate) {
|
||||
let rec: ArtifactModelType = await ArtifactModel.findOneAndUpdate({ roleId, seqId }, { $set: update }, { new: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ export default class Hero extends BaseModel {
|
||||
consumes: Reward[]; // 消耗
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
artifact: number; // 宝物
|
||||
artifact: number|string; // 宝物
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
subHid: number; // 副将
|
||||
|
||||
@@ -61,7 +61,7 @@ export class HeroParam {
|
||||
skins: HeroSKinParam[] = []; // 皮肤
|
||||
ePlace: EPlace[]; // 武将装备引用数组
|
||||
|
||||
artifact: number = 0;
|
||||
artifact: number|string = 0;
|
||||
subHid: number = 0;
|
||||
subActorId: number = 0;
|
||||
talent: Talent[] = [];
|
||||
@@ -133,7 +133,7 @@ export class JewelParam {
|
||||
}
|
||||
|
||||
export class ArtifactParam {
|
||||
seqId: number; // 唯一id
|
||||
seqId: number|string; // 唯一id
|
||||
artifactId: number; // 宝物id
|
||||
id: number; // 物品id
|
||||
lv: number; // 强化等级
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface RewardInter {
|
||||
export interface ItemInter {
|
||||
id: number;
|
||||
count?: number;
|
||||
seqId?: number;
|
||||
seqId?: number|string;
|
||||
type?: number;
|
||||
isPay?: boolean;
|
||||
hid?: number;
|
||||
|
||||
@@ -746,7 +746,7 @@ export function addToMap<T>(map: Map<T, number>, id: T, value: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export function arrToMap<T>(arr: T[], getKey: (obj: T) => number): Map<number, T> {
|
||||
export function arrToMap<T>(arr: T[], getKey: (obj: T) => number|string): Map<number, T> {
|
||||
let map = new Map();
|
||||
for(let obj of arr) {
|
||||
let key = getKey(obj);
|
||||
|
||||
Reference in New Issue
Block a user