修改hero相关返回数据, 增加trial字段
This commit is contained in:
parent
0e80dc5bf1
commit
2390751a0f
13
docs/api.md
13
docs/api.md
@ -35,8 +35,10 @@
|
|||||||
usetype: 1, // 赛季专属, 0: 通用, 1: 赛季排位专用, 2: 匹配专用
|
usetype: 1, // 赛季专属, 0: 通用, 1: 赛季排位专用, 2: 匹配专用
|
||||||
level: number, // 等级
|
level: number, // 等级
|
||||||
exp: number, // 当前的经验值
|
exp: number, // 当前的经验值
|
||||||
|
ban: false, // 是否被禁用
|
||||||
free: false, // 是否免费
|
free: false, // 是否免费
|
||||||
free_expire: 1609919293, // 免费到期时间, 0: 说明是永久免费
|
trial: false, // 是否是试用
|
||||||
|
trial_expire: 1609919293, // 试用到期时间, 0: 说明是永久
|
||||||
}],
|
}],
|
||||||
moneys: {
|
moneys: {
|
||||||
'coin': 0, // 金币
|
'coin': 0, // 金币
|
||||||
@ -101,8 +103,10 @@
|
|||||||
owned: true, // 是否已拥有
|
owned: true, // 是否已拥有
|
||||||
ban: false, // 是否被禁用
|
ban: false, // 是否被禁用
|
||||||
usetype: 1, // 赛季专属, 0: 通用, 1: 赛季排位专用, 2: 匹配专用
|
usetype: 1, // 赛季专属, 0: 通用, 1: 赛季排位专用, 2: 匹配专用
|
||||||
|
ban: false, // 是否被禁用
|
||||||
free: false, // 是否免费
|
free: false, // 是否免费
|
||||||
free_expire: 1609919293 // 免费到期时间, 0: 说明是永久免费
|
trial: false, // 是否试用
|
||||||
|
trial_expire: 1609919293 // 试用到期时间, 0: 说明是永久
|
||||||
level: 1, // 等级
|
level: 1, // 等级
|
||||||
exp: 0, // 当前的经验值
|
exp: 0, // 当前的经验值
|
||||||
}]
|
}]
|
||||||
@ -203,7 +207,8 @@
|
|||||||
ban: false, // 是否被禁用
|
ban: false, // 是否被禁用
|
||||||
usetype: 1, // 赛季专属, 0: 通用, 1: 赛季排位专用, 2: 匹配专用
|
usetype: 1, // 赛季专属, 0: 通用, 1: 赛季排位专用, 2: 匹配专用
|
||||||
free: false, // 是否免费
|
free: false, // 是否免费
|
||||||
free_expire: 1609919293 // 免费到期时间, 0: 说明是永久免费
|
trial: false, // 是否是试用
|
||||||
|
trial_expire: 1609919293 // 试用到期时间, 0: 说明是永久
|
||||||
level: 1, // 等级
|
level: 1, // 等级
|
||||||
exp: 0, // 当前的经验值
|
exp: 0, // 当前的经验值
|
||||||
}]
|
}]
|
||||||
@ -311,4 +316,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
```
|
```
|
@ -19,15 +19,13 @@ export class MoneyTypeConst {
|
|||||||
* card_scroll: 抽卡卷轴
|
* card_scroll: 抽卡卷轴
|
||||||
*/
|
*/
|
||||||
public static readonly CARD_SCROLL = 'card_scroll';
|
public static readonly CARD_SCROLL = 'card_scroll';
|
||||||
private static readonly HERO_SHARD_HEROID = 'hero_shard_';
|
|
||||||
private static readonly HERO_EXP_HEROID = 'hero_exp_';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 英雄专用碎片
|
* 英雄专用碎片
|
||||||
* @param heroId
|
* @param heroId
|
||||||
*/
|
*/
|
||||||
public static getHeroShard(heroId: number): string {
|
public static getHeroShard(heroId: number): string {
|
||||||
return `${this.HERO_SHARD_HEROID}_${heroId}`;
|
return `${this.HERO_SHARD}_${heroId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,6 +33,6 @@ export class MoneyTypeConst {
|
|||||||
* @param heroId
|
* @param heroId
|
||||||
*/
|
*/
|
||||||
public static getHeroExp(heroId: number): string {
|
public static getHeroExp(heroId: number): string {
|
||||||
return `${this.HERO_EXP_HEROID}_${heroId}`;
|
return `${this.HERO_EXP}_${heroId}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,15 +11,7 @@ export default class HeroController extends BaseController {
|
|||||||
let account = req.user;
|
let account = req.user;
|
||||||
let heros: any[] = [];
|
let heros: any[] = [];
|
||||||
for(let [key, hero] of account.heros) {
|
for(let [key, hero] of account.heros) {
|
||||||
heros.push({
|
heros.push(hero.toJson());
|
||||||
heroid: hero.heroid,
|
|
||||||
owned: true,
|
|
||||||
usetype: 0,
|
|
||||||
level: hero.level,
|
|
||||||
exp: hero.exp,
|
|
||||||
free: hero.free,
|
|
||||||
free_expire: 0
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
//TODO:: 添加限免英雄和免费英雄
|
//TODO:: 添加限免英雄和免费英雄
|
||||||
return heros;
|
return heros;
|
||||||
@ -37,18 +29,12 @@ export default class HeroController extends BaseController {
|
|||||||
if (!type) {
|
if (!type) {
|
||||||
hero = await account.unlockHero(heroid);
|
hero = await account.unlockHero(heroid);
|
||||||
await account.save();
|
await account.save();
|
||||||
hero.owned = true;
|
|
||||||
hero.ban = false;
|
|
||||||
hero.usetype = 0;
|
|
||||||
} else {
|
} else {
|
||||||
hero = await account.tryHero(heroid);
|
hero = await account.tryHero(heroid);
|
||||||
await account.save();
|
await account.save();
|
||||||
hero.owned = false;
|
|
||||||
hero.ban = false;
|
|
||||||
hero.usetype = 0;
|
|
||||||
hero.free_expire = 0;
|
|
||||||
}
|
}
|
||||||
return hero;
|
return hero.toJson();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
@ -66,6 +52,8 @@ export default class HeroController extends BaseController {
|
|||||||
if (!account.heros.has(heroid + '')) {
|
if (!account.heros.has(heroid + '')) {
|
||||||
throw new ZError(102, '你未解锁该英雄');
|
throw new ZError(102, '你未解锁该英雄');
|
||||||
}
|
}
|
||||||
|
let hero = account.heros.get(heroid + '');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@router('post /api/:accountid/hero/toexp/:heroid')
|
@router('post /api/:accountid/hero/toexp/:heroid')
|
||||||
|
@ -119,7 +119,9 @@ class UserClass extends FindOrCreate{
|
|||||||
let hero = new Hero();
|
let hero = new Hero();
|
||||||
hero.heroid = heroid;
|
hero.heroid = heroid;
|
||||||
hero.free = false;
|
hero.free = false;
|
||||||
|
hero.trial = false;
|
||||||
hero.level = 1;
|
hero.level = 1;
|
||||||
|
hero.trial_expire = 0;
|
||||||
hero.exp = 0;
|
hero.exp = 0;
|
||||||
this.heros.set(heroid + '', hero);
|
this.heros.set(heroid + '', hero);
|
||||||
return hero;
|
return hero;
|
||||||
@ -132,8 +134,10 @@ class UserClass extends FindOrCreate{
|
|||||||
//TODO:: 根据配置查看该英雄是否可使用
|
//TODO:: 根据配置查看该英雄是否可使用
|
||||||
let hero = new Hero();
|
let hero = new Hero();
|
||||||
hero.heroid = heroid;
|
hero.heroid = heroid;
|
||||||
hero.free = true;
|
hero.free = false;
|
||||||
|
hero.trial = true;
|
||||||
hero.level = 1;
|
hero.level = 1;
|
||||||
|
hero.trial_expire = 0;
|
||||||
hero.exp = 0;
|
hero.exp = 0;
|
||||||
this.heros.set(heroid+'', hero);
|
this.heros.set(heroid+'', hero);
|
||||||
return hero;
|
return hero;
|
||||||
|
@ -8,8 +8,37 @@ export class Hero {
|
|||||||
*/
|
*/
|
||||||
@prop({default: false})
|
@prop({default: false})
|
||||||
public free: boolean;
|
public free: boolean;
|
||||||
|
/**
|
||||||
|
* 是否是试用
|
||||||
|
*/
|
||||||
|
@prop({default: false})
|
||||||
|
public trial: boolean;
|
||||||
|
|
||||||
|
@prop({default: 0})
|
||||||
|
public trial_expire: number;
|
||||||
|
/**
|
||||||
|
* 等级
|
||||||
|
*/
|
||||||
@prop({default: 1})
|
@prop({default: 1})
|
||||||
public level: number;
|
public level: number;
|
||||||
|
/**
|
||||||
|
* 该等级下的经验值
|
||||||
|
*/
|
||||||
@prop({default: 0})
|
@prop({default: 0})
|
||||||
public exp: number;
|
public exp: number;
|
||||||
|
|
||||||
|
public toJson() {
|
||||||
|
let data: any = {
|
||||||
|
heroid: this.heroid,
|
||||||
|
usetype: 0,
|
||||||
|
level: this.level,
|
||||||
|
exp: this.exp,
|
||||||
|
free: this.free,
|
||||||
|
trial: this.trial,
|
||||||
|
trial_expire: this.trial_expire,
|
||||||
|
ban: false,
|
||||||
|
};
|
||||||
|
data.owned = !this.trial;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user