形象:解锁头像相框形象

This commit is contained in:
luying
2021-03-11 10:34:10 +08:00
parent e888ab916d
commit 95f4221217
13 changed files with 145 additions and 65 deletions

View File

@@ -28,6 +28,9 @@ export const CONSUME_TYPE = {
PIECE: 8, // 装备碎片
JEWEL: 9, //宝石
FRIEND_FAVOUR: 10, // 好友道具
HEAD: 11, // 头像
FRAME: 12, // 相框
SPINE: 13, // 形象
};
export enum ROLE_TERAPH {
@@ -127,7 +130,10 @@ const itid_array = [
{ id: 46, name: '礼器宝石', table: 'item', type: CONSUME_TYPE.JEWEL },
{ id: 47, name: '典籍宝石', table: 'item', type: CONSUME_TYPE.JEWEL },
{ id: 48, name: '灵玄石', table: 'item', type: CONSUME_TYPE.JEWEL },
{ id: 49, name: '玩家好感道具', table: 'item', type: CONSUME_TYPE.FRIEND_FAVOUR }
{ id: 49, name: '玩家好感道具', table: 'item', type: CONSUME_TYPE.FRIEND_FAVOUR },
{ id: 50, name: '形象', table: 'hero', type: CONSUME_TYPE.FRIEND_FAVOUR },
{ id: 51, name: '相框', table: 'hero', type: CONSUME_TYPE.FRIEND_FAVOUR },
{ id: 52, name: '玩家形象', table: 'hero', type: CONSUME_TYPE.FRIEND_FAVOUR }
];
export const ITID = new Map<number, {id: number, name: string, table: string, type?: number, isCurrency?: boolean, equipJewel?: number}>();
@@ -235,4 +241,11 @@ export function getDropItems() {
{ id:2008 ,count: 2 },{ id:2012 ,count: 2 },{ id:2208 ,count: 2 },{ id:2016 ,count: 2 },{ id:2120 ,count: 2 },{ id:2220 ,count: 2 },{ id:50031, count: 1000}
]
return items;
}
// 头像/相框 获取条件
export enum FIGURE_UNLOCK_CONDITION {
GET_HERO = 1, // 获取武将
HERO_FAVOR = 2, // 武将好感度达到
}

View File

@@ -1,7 +1,7 @@
export enum ROLE_SELECT {
// 初始登录数据
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topLineupCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild funcs eventStatus heads head frames frame spine guildCode frdCnt',
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topLineup topLineupCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild funcs eventStatus heads head frames frame spines spine guildCode frdCnt showLineup',
// 玩家列表显示基础数据
SHOW_SIMPLE = 'roleId roleName ce head frame spine lv title job quitTime vLv guildName serverId userInfo.serverType',
// 显示申请需要的信息
@@ -12,7 +12,7 @@ export enum ROLE_SELECT {
GET_ROLE_ID = 'roleId',
GET_MY_SERVER = 'lv serverId userInfo.serverType',
COM_BATTLE = 'lv head frame spine topLineupCe',
GET_HEADS = 'heads head frames frame spine'
GET_HEADS = 'heads head frames frame spines spine'
};
export enum HERO_SELECT {

View File

@@ -423,4 +423,4 @@ export enum DEFAULT_DEVICE_ID {
}
// 阵容人数限制
export const LINEUP_NUM = 6;
export const LINEUP_NUM = 6;

View File

@@ -278,8 +278,9 @@ export const STATUS = {
FRAME_NOT_FOUND: { code: 30805, simStr: '未找到相框' },
FRAME_IS_WEARING: { code: 30806, simStr: '相框已设置中' },
FRAME_IS_LOCKED: { code: 30807, simStr: '相框未解锁' },
SPINE_IS_WEARING: { code: 30808, simStr: '形象已设置中' },
SPINE_NOT_FOUND: { code: 30809, simStr: '形象未解锁' },
SPINE_NOT_FOUND: { code: 30808, simStr: '未找到形象' },
SPINE_IS_WEARING: { code: 30809, simStr: '形象已设置中' },
SPINE_IS_LOCKED: { code: 30810, simStr: '形象未解锁' },
// 社交相关状态 40000 - 49999
SYS_CHANNEL_AUTH_NOT_ENOUGH: {code: 40000, simStr: '无法在系统频道发送消息'},

View File

@@ -266,11 +266,6 @@ export default class Hero extends BaseModel {
const user: HeroType[] = await HeroModel.find(searchObj).lean(lean);
return user;
}
public static async checkSkin(roleId: string, skinId: number) {
let hero = await HeroModel.findOne({ roleId, 'skins.id': skinId }).lean();
return !!hero;
}
}
export const HeroModel = getModelForClass(Hero);

View File

@@ -124,12 +124,12 @@ export default class Role extends BaseModel {
@prop({ required: true, type: Number })
showLineup: number[]; // 展示阵容
@prop({ required: true, type: Figure, default: [] })
@prop({ required: true, type: Figure, default: [], _id: false })
heads: Figure[]; // 拥有头像列表
@prop({ required: true, type: Figure, default: [] })
@prop({ required: true, type: Figure, default: [], _id: false })
frames: Figure[]; // 拥有相框列表
@prop({ required: true, default: FIGURE.DEFAULT_SPINE })
spine: number; // 显示形象
@prop({ required: true, type: Figure, default: [], _id: false })
spines: Figure[]; // 拥有的形象
public get head () { // 虚拟字段head 当前头像
let curHead = this.heads?.find(cur => cur.enable && cur.time > nowSeconds());
@@ -141,6 +141,11 @@ export default class Role extends BaseModel {
return curFrame?curFrame.id: FIGURE.DEFAULT_FRAME;
}
public get spine () { // 虚拟字段spine 当前形象
let curSpine = this.spines?.find(cur => cur.enable && cur.time > nowSeconds());
return curSpine?curSpine.id: FIGURE.DEFAULT_SPINE;
}
@prop({ required: true, default: 0 })
exp: number; // 经验值
@prop({ required: true, default: 1 })

View File

@@ -208,46 +208,24 @@ export class Figure {
id: number; // 头像id
@prop({ required: true, default: false })
enable: boolean = false; // 是否启用
@prop({ required: false, default: 0 })
@prop({ required: false })
time?: number; // 到期时间
@prop({ required: true, default: [] })
unlockedType: number[] = []; // 当前已经解锁了的type
@prop({ required: true, default: false })
unlocked: boolean = false; // 是否已解锁
public get status () { // 虚拟字段status当前头像是否已经解锁
let dicGoods = gameData.goods.get(this.id);
if(!dicGoods) return false;
let hasUnlockedAll = true;
for(let {type} of dicGoods.condition) {
if(!this.unlockedType.includes(type)) {
hasUnlockedAll = false; break;
}
}
if(!hasUnlockedAll) return true;
if(dicGoods.timeLimit) { // 超时
if(this.time < nowSeconds()) return false;
}
if(!this.unlocked) return this.unlocked; // 未解锁
if(this.time && this.time < nowSeconds()) return false; // 已解锁过时
return true;
}
constructor(id: number, unlockedType?: number[]) {
let dicGoods = gameData.goods.get(id);
if(dicGoods) {
this.id = id;
if(!unlockedType) unlockedType = dicGoods.condition.map(cur => cur.type);
this.unlockedType = unlockedType;
let hasUnlockedAll = true;
for(let {type} of dicGoods.condition) {
if(!this.unlockedType.includes(type)) {
hasUnlockedAll = false; break;
}
}
if(hasUnlockedAll && dicGoods.timeLimit) {
this.time = getBeforeDaySeconds(-1 * dicGoods.timeLimit); // timeLimit天以后
}
}
constructor(id: number, unlocked: boolean, time?: number, enable = false) {
this.id = id;
this.unlocked = unlocked;
if(time) this.time = time;
this.enable = enable;
}
}

View File

@@ -11,6 +11,9 @@ export class RankParam {
spine: number = FIGURE.DEFAULT_SPINE;
title: number;
headHid: number = 19; // TODO 等客户端接完将这些删除
sHid: number = 19;
constructor(roleName: string, lv: number, vLv: number, head: number, frame: number, spine: number, title: number) {
this.roleName = roleName;
this.lv = lv;
@@ -34,6 +37,10 @@ export class GuildRankParam {
head: number;
frame: number;
spine: number;
headHid: number;
sHid: number;
}
constructor(icon: number, name: string, lv: number, leader: {roleName: string, title: number, lv: number, head: number, frame: number, spine: number}) {
@@ -53,6 +60,9 @@ export class GuildLeader {
frame: number;
spine: number;
headHid: number = 19;
sHid: number = 19;
constructor(leader: {roleName: string, title: number, lv: number, head: number, frame: number, spine: number}) {
this.roleName = leader.roleName;
this.title = leader.title;

View File

@@ -1,5 +1,5 @@
import { dicHero } from "./dictionary/DicHero";
import { dicGoods, blueprt, dicJewel } from "./dictionary/DicGoods";
import { dicGoods, blueprt, dicJewel, figureCondition } from "./dictionary/DicGoods";
import { dicBlueprtCompose } from "./dictionary/DicBlueprtCompose";
import { dicBlueprtPossibility } from "./dictionary/DicBlueprtPossibility";
import { dicDaily } from "./dictionary/DicDaily";
@@ -139,6 +139,7 @@ export const gameData = {
armyDonateBox: dicArmyDonate,
roleFriend: dicRoleFriend,
roleFriendLv: dicRoleFriendLv,
figureCondition: figureCondition
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据