Merge branch 'master' of http://git.kingsome.cn/node/card_info_svr
This commit is contained in:
commit
d628879431
@ -7,7 +7,7 @@ import { BaseConst } from '../constants/BaseConst'
|
|||||||
import { Hero } from '../models/subdoc/Hero'
|
import { Hero } from '../models/subdoc/Hero'
|
||||||
import { CardGroup } from '../models/CardGroup'
|
import { CardGroup } from '../models/CardGroup'
|
||||||
import { BagItem, ItemType } from '../models/BagItem'
|
import { BagItem, ItemType } from '../models/BagItem'
|
||||||
import ItemCtrl from 'logic/ItemCtrl'
|
import ItemCtrl from '../logic/ItemCtrl'
|
||||||
|
|
||||||
export default class AccountController extends BaseController {
|
export default class AccountController extends BaseController {
|
||||||
@role('anon')
|
@role('anon')
|
||||||
@ -23,9 +23,9 @@ export default class AccountController extends BaseController {
|
|||||||
if (account.season_score == -1) {
|
if (account.season_score == -1) {
|
||||||
account.season_score = formulaCfg.get(70003).number
|
account.season_score = formulaCfg.get(70003).number
|
||||||
}
|
}
|
||||||
let cardSet = new Set(account.cards)
|
let cardMap = account.cardMap
|
||||||
for (let [, cfg] of global.$cfg.get(BaseConst.HERO)) {
|
for (let [, cfg] of global.$cfg.get(BaseConst.HERO)) {
|
||||||
if (cfg.id <= 30100) {
|
if (cfg.org_gift == 1) {
|
||||||
let hero = new Hero()
|
let hero = new Hero()
|
||||||
hero.heroid = cfg.id
|
hero.heroid = cfg.id
|
||||||
hero.free = true
|
hero.free = true
|
||||||
@ -37,15 +37,20 @@ export default class AccountController extends BaseController {
|
|||||||
let cardgroup = new CardGroup({})
|
let cardgroup = new CardGroup({})
|
||||||
let cards: Card[] = []
|
let cards: Card[] = []
|
||||||
for (let i = 1; i <= 4; i++) {
|
for (let i = 1; i <= 4; i++) {
|
||||||
|
const cardid = cfg[`follower${ i }id`]
|
||||||
|
if (cardMap.has(cardid + '')) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
let card = new Card()
|
let card = new Card()
|
||||||
card.cardid = cfg[`follower${ i }id`]
|
card.cardid = cardid
|
||||||
card.owned = false
|
card.owned = true
|
||||||
card.ban = false
|
card.ban = false
|
||||||
card.usetype = 0
|
card.usetype = 0
|
||||||
card.free = true
|
card.free = true
|
||||||
card.free_expire = 0
|
card.free_expire = 0
|
||||||
|
card.time = Date.now()
|
||||||
cards.push(card)
|
cards.push(card)
|
||||||
cardSet.add(card.cardid)
|
cardMap.set(cardid + '', card)
|
||||||
}
|
}
|
||||||
cardgroup.accountid = account.id
|
cardgroup.accountid = account.id
|
||||||
cardgroup.heroid = cfg.id
|
cardgroup.heroid = cfg.id
|
||||||
@ -56,8 +61,7 @@ export default class AccountController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
account.cards = [...cardSet]
|
result.cards = [...account.cardMap.values()].map(o => o.toJson())
|
||||||
result.cards = account.cards
|
|
||||||
let heros: any[] = []
|
let heros: any[] = []
|
||||||
for (let [key, hero] of account.heros) {
|
for (let [key, hero] of account.heros) {
|
||||||
heros.push(hero.toJson())
|
heros.push(hero.toJson())
|
||||||
@ -89,16 +93,7 @@ export default class AccountController extends BaseController {
|
|||||||
@router('post /api/:accountid/cards')
|
@router('post /api/:accountid/cards')
|
||||||
async cardlist(req: any) {
|
async cardlist(req: any) {
|
||||||
let account = req.user
|
let account = req.user
|
||||||
let result: Card[] = []
|
let result: Card[] = [...account.cardMap.values()].map(o => o.toJson())
|
||||||
for (let cardid of account.cards) {
|
|
||||||
let card = new Card()
|
|
||||||
card.cardid = cardid
|
|
||||||
card.owned = true
|
|
||||||
card.ban = false
|
|
||||||
card.usetype = 0
|
|
||||||
card.free = false
|
|
||||||
result.push(card)
|
|
||||||
}
|
|
||||||
//TODO:: 添加限免英雄和免费英雄
|
//TODO:: 添加限免英雄和免费英雄
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -113,7 +108,11 @@ export default class AccountController extends BaseController {
|
|||||||
@router('post /api/:accountid/useitem')
|
@router('post /api/:accountid/useitem')
|
||||||
async userItem(req: any) {
|
async userItem(req: any) {
|
||||||
let { accountid, itemid, count } = req.params
|
let { accountid, itemid, count } = req.params
|
||||||
let record = await BagItem.findOne({accountid, itemid, itemtype: ItemType.UNKNOW})
|
let record = await BagItem.findOne({
|
||||||
|
accountid,
|
||||||
|
itemid,
|
||||||
|
itemtype: ItemType.UNKNOW
|
||||||
|
})
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new ZError(11, 'item not found')
|
throw new ZError(11, 'item not found')
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import { ZError } from '../common/ZError'
|
|||||||
import { MoneyTypeConst } from '../constants/MoneyTypeConst'
|
import { MoneyTypeConst } from '../constants/MoneyTypeConst'
|
||||||
import { timeBeforeDay } from '../utils/time.util'
|
import { timeBeforeDay } from '../utils/time.util'
|
||||||
import { BaseConst } from '../constants/BaseConst'
|
import { BaseConst } from '../constants/BaseConst'
|
||||||
|
import { Card } from './subdoc/Card'
|
||||||
|
|
||||||
export class RecordInfo {
|
export class RecordInfo {
|
||||||
@prop()
|
@prop()
|
||||||
@ -60,6 +61,11 @@ class UserClass extends FindOrCreate {
|
|||||||
*/
|
*/
|
||||||
@prop({ type: () => [Number] })
|
@prop({ type: () => [Number] })
|
||||||
public cards: number[]
|
public cards: number[]
|
||||||
|
/**
|
||||||
|
* 已获得卡牌信息, 20210121添加
|
||||||
|
*/
|
||||||
|
@prop({ type: Card, default: new Map() })
|
||||||
|
public cardMap: Map<string, Card>
|
||||||
/**
|
/**
|
||||||
* 已解锁英雄信息
|
* 已解锁英雄信息
|
||||||
*/
|
*/
|
||||||
|
@ -1,37 +1,43 @@
|
|||||||
import {prop} from "@typegoose/typegoose";
|
import { prop } from '@typegoose/typegoose'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卡牌信息
|
* 卡牌信息
|
||||||
*/
|
*/
|
||||||
export class Card {
|
export class Card {
|
||||||
@prop()
|
@prop()
|
||||||
public cardid: number;
|
public cardid: number
|
||||||
/**
|
/**
|
||||||
* 是否已拥有
|
* 是否已拥有
|
||||||
*/
|
*/
|
||||||
@prop()
|
@prop()
|
||||||
public owned: boolean;
|
public owned: boolean
|
||||||
/**
|
/**
|
||||||
* 是否被禁
|
* 是否被禁
|
||||||
*/
|
*/
|
||||||
@prop({ default: false })
|
@prop({ default: false })
|
||||||
public ban: boolean;
|
public ban: boolean
|
||||||
/**
|
/**
|
||||||
* 赛季类型
|
* 赛季类型
|
||||||
* 0: 通用, 1: 赛季排位专用, 2: 匹配专用
|
* 0: 通用, 1: 赛季排位专用, 2: 匹配专用
|
||||||
*/
|
*/
|
||||||
@prop({ default: 0 })
|
@prop({ default: 0 })
|
||||||
public usetype: number;
|
public usetype: number
|
||||||
/**
|
/**
|
||||||
* 是否是限免卡牌
|
* 是否是限免卡牌
|
||||||
*/
|
*/
|
||||||
@prop({ default: false })
|
@prop({ default: false })
|
||||||
public free: boolean;
|
public free: boolean
|
||||||
/**
|
/**
|
||||||
* 限免过期时间
|
* 限免过期时间
|
||||||
*/
|
*/
|
||||||
@prop()
|
@prop()
|
||||||
public free_expire: number;
|
public free_expire: number
|
||||||
|
/**
|
||||||
|
* 添加时间
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
@prop()
|
||||||
|
public time: number
|
||||||
|
|
||||||
public toJson() {
|
public toJson() {
|
||||||
return {
|
return {
|
||||||
@ -40,7 +46,8 @@ export class Card {
|
|||||||
ban: this.ban,
|
ban: this.ban,
|
||||||
usetype: this.usetype,
|
usetype: this.usetype,
|
||||||
free: this.free,
|
free: this.free,
|
||||||
free_expire: this.free_expire
|
free_expire: this.free_expire,
|
||||||
|
time: this.time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,34 @@
|
|||||||
import {prop} from "@typegoose/typegoose";
|
import { prop } from '@typegoose/typegoose'
|
||||||
|
|
||||||
export class Hero {
|
export class Hero {
|
||||||
@prop()
|
@prop()
|
||||||
public heroid: number;
|
public heroid: number
|
||||||
/**
|
/**
|
||||||
* 是否是免费英雄
|
* 是否是免费英雄
|
||||||
*/
|
*/
|
||||||
@prop({ default: false })
|
@prop({ default: false })
|
||||||
public free: boolean;
|
public free: boolean
|
||||||
/**
|
/**
|
||||||
* 是否是试用
|
* 是否是试用
|
||||||
*/
|
*/
|
||||||
@prop({ default: false })
|
@prop({ default: false })
|
||||||
public trial: boolean;
|
public trial: boolean
|
||||||
|
|
||||||
@prop({ default: 0 })
|
@prop({ default: 0 })
|
||||||
public trial_expire: number;
|
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
|
||||||
|
|
||||||
|
@prop()
|
||||||
|
public time: number
|
||||||
|
|
||||||
public toJson() {
|
public toJson() {
|
||||||
let data: any = {
|
let data: any = {
|
||||||
@ -36,9 +39,9 @@ export class Hero {
|
|||||||
free: this.free,
|
free: this.free,
|
||||||
trial: this.trial,
|
trial: this.trial,
|
||||||
trial_expire: this.trial_expire,
|
trial_expire: this.trial_expire,
|
||||||
ban: false,
|
ban: false
|
||||||
};
|
}
|
||||||
data.owned = !this.trial;
|
data.owned = !this.trial
|
||||||
return data;
|
return data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user