武将初始装备栏
This commit is contained in:
@@ -83,10 +83,10 @@ export class EntryHandler {
|
|||||||
let equips = await EquipModel.findbyRole(role.roleId);
|
let equips = await EquipModel.findbyRole(role.roleId);
|
||||||
let items = await ItemModel.findbyRole(role.roleId);
|
let items = await ItemModel.findbyRole(role.roleId);
|
||||||
|
|
||||||
for(let hero of heros) {
|
for(let i of heros) {
|
||||||
let actor = new Actor();
|
for(let j of i.ePlace) {
|
||||||
actor.initHero(hero);
|
console.log(j.equip)
|
||||||
actor.calculateCE();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
role['heros'] = heros;
|
role['heros'] = heros;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class RoleHandler {
|
|||||||
type: 1
|
type: 1
|
||||||
}
|
}
|
||||||
const equip = await EquipModel.createEquip(equipInfo);
|
const equip = await EquipModel.createEquip(equipInfo);
|
||||||
await HeroModel.addEquip(roleId, 1, equip._id);
|
await HeroModel.addEquip(roleId, 12, equip._id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async initHeros(roleId: string, roleName: string) {
|
async initHeros(roleId: string, roleName: string) {
|
||||||
@@ -54,10 +54,10 @@ export class RoleHandler {
|
|||||||
await this.initHeros(roleId, roleName);
|
await this.initHeros(roleId, roleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
let equips = await EquipModel.findbyRole(roleId);
|
// let equips = await EquipModel.findbyRole(roleId);
|
||||||
if (!equips || equips.length === 0) {
|
// if (!equips || equips.length === 0) {
|
||||||
await this.initEquips(roleId, roleName);
|
await this.initEquips(roleId, roleName);
|
||||||
}
|
// }
|
||||||
|
|
||||||
console.log('initRole finish');
|
console.log('initRole finish');
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-6
@@ -3,7 +3,8 @@ import { CeAttr } from './generalField';
|
|||||||
import { index, getModelForClass, prop, Ref, mongoose, DocumentType } from '@typegoose/typegoose';
|
import { index, getModelForClass, prop, Ref, mongoose, DocumentType } from '@typegoose/typegoose';
|
||||||
import Equip from './Equip';
|
import Equip from './Equip';
|
||||||
import { CounterModel } from './Counter';
|
import { CounterModel } from './Counter';
|
||||||
import { COUNTER } from '../consts';
|
import { COUNTER, EQUIP_TYPE } from '../consts';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 英雄表
|
* 英雄表
|
||||||
@@ -22,7 +23,7 @@ class Skin {
|
|||||||
enable: boolean;
|
enable: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
class EPlace {
|
export class EPlace {
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
id: number;
|
id: number;
|
||||||
@prop({ ref: Equip, type: mongoose.Schema.Types.ObjectId })
|
@prop({ ref: Equip, type: mongoose.Schema.Types.ObjectId })
|
||||||
@@ -35,6 +36,22 @@ class EPlace {
|
|||||||
refineCount: number;
|
refineCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
function getInitialEplace() {
|
||||||
|
let ePlace = new Array<EPlace>();
|
||||||
|
for(let i = EQUIP_TYPE.START; i <= EQUIP_TYPE.END; i++) {
|
||||||
|
let p = new EPlace();
|
||||||
|
p.id = i;
|
||||||
|
p.equip = null;
|
||||||
|
p.lv = 1;
|
||||||
|
p.refineLv = 1;
|
||||||
|
p.refineCount = 0;
|
||||||
|
|
||||||
|
ePlace.push(p);
|
||||||
|
}
|
||||||
|
return ePlace;
|
||||||
|
}
|
||||||
|
|
||||||
interface heroUpdate {
|
interface heroUpdate {
|
||||||
exp?: number;
|
exp?: number;
|
||||||
lv?: number;
|
lv?: number;
|
||||||
@@ -108,11 +125,11 @@ export default class Hero extends BaseModel {
|
|||||||
@prop({ required: true, type: Skin, default: [] })
|
@prop({ required: true, type: Skin, default: [] })
|
||||||
skins: Skin[]; // 皮肤
|
skins: Skin[]; // 皮肤
|
||||||
|
|
||||||
@prop({ required: true, type: EPlace, default:[] })
|
@prop({ required: true, type: EPlace, default: getInitialEplace() })
|
||||||
ePlact: EPlace[]; // 武将装备引用数组
|
ePlace: EPlace[]; // 武将装备引用数组
|
||||||
|
|
||||||
public static async findByRole(roleId: string, lean = true) {
|
public static async findByRole(roleId: string, lean = true) {
|
||||||
const heros: HeroType[] = await HeroModel.find({ roleId }).populate('equips').lean(lean);
|
const heros: HeroType[] = await HeroModel.find({ roleId }).lean(lean);
|
||||||
return heros;
|
return heros;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +147,10 @@ export default class Hero extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async addEquip(roleId: string, hid: number, equipId: string, lean = true) {
|
public static async addEquip(roleId: string, hid: number, equipId: string, lean = true) {
|
||||||
const hero: HeroType = await HeroModel.findOneAndUpdate({ roleId, hid }, {$push: {equips: equipId}}, {new: true}).lean(lean);
|
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
||||||
|
{ roleId, hid, 'ePlace.id': 1 },
|
||||||
|
{$set: {'ePlace.$.equip': equipId}},
|
||||||
|
{new: true}).lean(lean);
|
||||||
if (hero) {
|
if (hero) {
|
||||||
await Equip.putOn(hero.hid, equipId);
|
await Equip.putOn(hero.hid, equipId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
import { HeroModel } from '../db/Hero';
|
import { HeroModel, EPlace } from '../db/Hero';
|
||||||
import { ItemModel } from '../db/Item';
|
import { ItemModel } from '../db/Item';
|
||||||
import { EquipModel } from './../db/Equip';
|
import { EquipModel } from './../db/Equip';
|
||||||
import { CounterModel } from './../db/Counter';
|
import { CounterModel } from './../db/Counter';
|
||||||
import { COUNTER } from './../consts/consts';
|
import { COUNTER } from './../consts/consts';
|
||||||
import { BagInter, EquipInter } from './interface';
|
import { BagInter, EquipInter } from './interface';
|
||||||
import { gameData } from './data';
|
import { gameData } from './data';
|
||||||
|
import { EQUIP_TYPE } from '../consts';
|
||||||
|
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
import { HERO_SYSTEM_TYPE } from '../consts';
|
import { HERO_SYSTEM_TYPE } from '../consts';
|
||||||
|
|
||||||
import { deepCopy } from '../pubUtils/util';
|
import { deepCopy } from './util';
|
||||||
import { HeroModel, HeroType } from '../db/Hero';
|
import { HeroModel, HeroType } from '../db/Hero';
|
||||||
import { RoleModel } from '../db/Role';
|
import { RoleModel } from '../db/Role';
|
||||||
import { CeAttrData, CeAttr } from '../db/generalField';
|
import { CeAttrData, CeAttr } from '../db/generalField';
|
||||||
import { getAttrNameByJobStage, getAttrCeRatio, getAtrrNameById, ABI_TYPE_TO_STAGE, ABI_STAGE, SEID_TYPE, HERO_ATTR} from '../consts';
|
import { getAttrNameByJobStage, getAttrCeRatio, getAtrrNameById, ABI_TYPE_TO_STAGE, ABI_STAGE, SEID_TYPE, HERO_ATTR} from '../consts';
|
||||||
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById } from '../pubUtils/data';
|
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById } from './data';
|
||||||
import { Attributes } from '../pubUtils/interface';
|
import { Attributes } from './interface';
|
||||||
import { DicSe } from '../pubUtils/dictionary/DicSe';
|
import { DicSe } from './dictionary/DicSe';
|
||||||
const HERO_CE_RATIO = 100;
|
const HERO_CE_RATIO = 100;
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
//战力计算TODO
|
//战力计算TODO
|
||||||
|
|||||||
Reference in New Issue
Block a user