添加主线关卡和每日关卡
This commit is contained in:
@@ -13,3 +13,24 @@ export const COUNTER = {
|
||||
API: 'api',
|
||||
GM_GROUP: 'gmgroup'
|
||||
};
|
||||
|
||||
export const ACTION_POIN = {
|
||||
MAX: 100,
|
||||
PER: 6 * 60 * 1000
|
||||
};
|
||||
|
||||
export const BATTLE_REWARD_TYPE = {
|
||||
FIX_REWARD: 1,
|
||||
CONDITION_REWARD: 2,
|
||||
RANDOM_REWARD: 3
|
||||
};
|
||||
|
||||
export const GOOD_TYPE = {
|
||||
EQUIP: 1,
|
||||
ITEM: 2
|
||||
};
|
||||
|
||||
export const WAR_TYPE = {
|
||||
NORMAL: 1,
|
||||
DAILY: 2
|
||||
};
|
||||
32
shared/db/ActionPoint.ts
Normal file
32
shared/db/ActionPoint.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 体力系统
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class ActionPoint extends BaseModel {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色 id
|
||||
|
||||
@prop({ required: true })
|
||||
refTime: number; // 刷新时间,时间戳
|
||||
@prop({ required: true })
|
||||
ap: number; // 当前体力
|
||||
|
||||
public static async getAp(roleId: string, lean = true) {
|
||||
let result = await ActionPointModel.findOne({roleId}).select('ap refTime').lean(lean);
|
||||
if(!result) {
|
||||
result = await ActionPointModel.findOneAndUpdate({roleId}, { ap: 0, refTime: 0 }, {new: true, upsert: true}).lean(lean)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async saveAp(roleId: string, ap: number, refTime: number, lean = true) {
|
||||
let result = await ActionPointModel.findOneAndUpdate({roleId}, { ap, refTime }, {upsert: true, new: true}).lean(lean);
|
||||
return result||{};
|
||||
}
|
||||
}
|
||||
|
||||
export const ActionPointModel = getModelForClass(ActionPoint);
|
||||
38
shared/db/BattleDrop.ts
Normal file
38
shared/db/BattleDrop.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 战斗记录接口
|
||||
*/
|
||||
@index({ roleId: 1, battleId: 1 })
|
||||
|
||||
export default class BattleDrop extends BaseModel {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色 id
|
||||
@prop({ required: true })
|
||||
battleId: number; // 关卡 id
|
||||
@prop({ required: true })
|
||||
gid: number; // 关卡 id
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
getNum: number; // 获取次数,当allNum超过配置次数重置
|
||||
@prop({ required: true, default: 0 })
|
||||
allNum: number; // 全部次数,当超过配置次数重置
|
||||
@prop({ required: true, default: 0 })
|
||||
getSum: number; // 获取道具的全部次数
|
||||
@prop({ required: true, default: 0 })
|
||||
allSum: number; // 全部全部次数,不重置
|
||||
|
||||
|
||||
public static async findByGid(roleId: string, battleId: number, gid: number, lean = true) {
|
||||
const result = await BattleDropModel.findOneAndUpdate({ roleId, battleId, gid}, {}, {new: true, upsert: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateByGid(roleId: string, battleId: number, gid: number, params: {getNum: number, allNum: number, getSum: number, allSum: number}, lean = true) {
|
||||
const result = await BattleDropModel.findOneAndUpdate({roleId, battleId, gid}, {$set: params}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const BattleDropModel = getModelForClass(BattleDrop);
|
||||
@@ -21,24 +21,57 @@ export default class BattleRecord extends BaseModel {
|
||||
warName: string; // 关卡 名
|
||||
@prop({ required: true })
|
||||
warType: number; // 关卡 类型
|
||||
@prop({ required: true })
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
status: number; // 关卡状态 0-挑战中 1-挑战成功 2-挑战失败
|
||||
@prop({ required: true, default: 0 })
|
||||
star: number; // 关卡状态 0-挑战中 1-挑战成功 2-挑战失败
|
||||
@prop({ required: true })
|
||||
record: { // 使用的武将等记录
|
||||
heroes: Array <number>; // 武将id
|
||||
};
|
||||
|
||||
|
||||
public static async getBattleRecordByCode(battleCode: string, lean = true) {
|
||||
const result = await BattleRecordModel.findOne({ battleCode }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getBattleRecordByIdAndStatus(roleId: string, battleId: number, status: number, lean = true) {
|
||||
const result = await BattleRecordModel.findOne({ roleId, battleId, status }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getBattleRecordByIdAndStar(roleId: string, battleId: number, star: number, lean = true) {
|
||||
const result = await BattleRecordModel.findOne({ roleId, battleId, star: {$lte: star} }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateBattleRecordByCode( battleCode: string, params: object, lean = true) {
|
||||
const result = await BattleRecordModel.findOneAndUpdate({ battleCode }, params, {new: true, upsert: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getBattleList( roleId: string, warType: number, lean = true) {
|
||||
const searchObj = { roleId, warType, status: 1 };
|
||||
const count = await BattleRecordModel.countDocuments(searchObj);
|
||||
console.log(roleId, warType, count);
|
||||
const limit = 1000;
|
||||
const page = Math.ceil(count/limit);
|
||||
let result = new Array();
|
||||
for(let i = 0; i < page; i++) {
|
||||
const battleRecords = await BattleRecordModel.find(searchObj)
|
||||
.select('battleId battleCode warType star status')
|
||||
.limit(1000)
|
||||
.skip(1000 * i)
|
||||
.sort({battleId: 1, star: -1, createdAt: -1})
|
||||
.lean(lean);
|
||||
for(let battleRecord of battleRecords) {
|
||||
result.push(battleRecord);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const BattleRecordModel = getModelForClass(BattleRecord);
|
||||
|
||||
32
shared/db/BattleSweepRecord.ts
Normal file
32
shared/db/BattleSweepRecord.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 战斗记录接口
|
||||
*/
|
||||
@index({ roleId: 1, battleId: 1 })
|
||||
|
||||
export default class BattleSweepRecord extends BaseModel {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色 id
|
||||
@prop({ required: true })
|
||||
roleName: string; // 角色名称
|
||||
|
||||
@prop({ required: true })
|
||||
battleId: number; // 关卡 id
|
||||
@prop({ required: true })
|
||||
warName: string; // 关卡 名
|
||||
@prop({ required: true })
|
||||
warType: number; // 关卡 类型
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
count: number; // 扫荡次数
|
||||
|
||||
public static async saveBattleSweepRecordById(roleId: string, battleId: number, params: any, lean = true) {
|
||||
const result = await BattleSweepRecordModel.findOneAndUpdate({ roleId, battleId }, params, {new: true, upsert: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const BattleSweepRecordModel = getModelForClass(BattleSweepRecord);
|
||||
43
shared/db/DailyRecord.ts
Normal file
43
shared/db/DailyRecord.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 战斗记录接口
|
||||
*/
|
||||
@index({ roleId: 1, type: 1 })
|
||||
|
||||
export default class DailyRecord extends BaseModel {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色 id
|
||||
@prop({ required: true })
|
||||
type: number; // 每日类型
|
||||
@prop({ required: true, default: 0 })
|
||||
count: number; // 挑战次数
|
||||
@prop({ required: true, default: 0 })
|
||||
refTime: number; // 刷新时间
|
||||
|
||||
public static async getDailyRecordById(roleId: string, type: number, lean = true) {
|
||||
const result = await DailyRecordModel.findOneAndUpdate({ roleId, type }, {}, {new: true, upsert: true}).select('count refTime').lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async refreshRecord(roleId: string, type: number, lean = true) {
|
||||
const dailyRecord = await DailyRecordModel.findOne({ roleId, type }).lean(lean);
|
||||
let {count = 0, refTime = 0} = dailyRecord||{};
|
||||
let now = new Date();
|
||||
let today = now.setHours(0, 0, 0, 0);
|
||||
if(today > refTime) {
|
||||
refTime = today;
|
||||
count = 0;
|
||||
}
|
||||
let result = await DailyRecordModel.findOneAndUpdate({roleId, type}, {$set: {refTime, count}}, {new: true, upsert: true});
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async increseDailyCount(roleId: string, type: number, count: number, lean = true) {
|
||||
const result = await DailyRecordModel.findOneAndUpdate({ roleId, type }, {$inc: { count } }, {new: true, upsert: true}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const DailyRecordModel = getModelForClass(DailyRecord);
|
||||
@@ -21,6 +21,8 @@ export default class Equip extends BaseModel {
|
||||
@prop({ required: false })
|
||||
hid: number; // 装备此装备的武将 id
|
||||
|
||||
@prop({ required: true, default: 1 })
|
||||
quality: number; // 品质
|
||||
@prop({ required: true, default: 1 })
|
||||
lv: number; // 强化等级
|
||||
@prop({ required: false, default: [] })
|
||||
|
||||
7
shared/resource/dic_daily.json
Normal file
7
shared/resource/dic_daily.json
Normal file
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"type": 1,
|
||||
"name": "资源本",
|
||||
"sum": 3
|
||||
}
|
||||
]
|
||||
24
shared/resource/dic_daily_war.json
Normal file
24
shared/resource/dic_daily_war.json
Normal file
@@ -0,0 +1,24 @@
|
||||
[
|
||||
{
|
||||
"war_id": 1000,
|
||||
"war_type": 2,
|
||||
"daily_type": 1,
|
||||
"difficulty": 1,
|
||||
"gk_name": "每日资源本A",
|
||||
"cost": 1,
|
||||
"fixReward": "1&1",
|
||||
"conditionReward": "2&1&1|1&1&0",
|
||||
"randomReward": "3&1&2"
|
||||
},
|
||||
{
|
||||
"war_id": 1001,
|
||||
"war_type": 2,
|
||||
"daily_type": 1,
|
||||
"difficulty": 2,
|
||||
"gk_name": "每日资源本B",
|
||||
"cost": 1,
|
||||
"fixReward": "1&50",
|
||||
"conditionReward": "2&1&1|1&1&0",
|
||||
"randomReward": "3&1&2"
|
||||
}
|
||||
]
|
||||
8
shared/resource/dic_event.json
Normal file
8
shared/resource/dic_event.json
Normal file
@@ -0,0 +1,8 @@
|
||||
[
|
||||
{
|
||||
"event_id": 1,
|
||||
"type": 1,
|
||||
"quality": 1,
|
||||
"war_id": 2000
|
||||
}
|
||||
]
|
||||
10
shared/resource/dic_event_war.json
Normal file
10
shared/resource/dic_event_war.json
Normal file
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"war_id": 2000,
|
||||
"war_type": 3,
|
||||
"gk_name": "奇遇",
|
||||
"fixReward": "1&50",
|
||||
"conditionReward": "2&10&1|1&10&0",
|
||||
"randomReward": "3&10&2"
|
||||
}
|
||||
]
|
||||
20
shared/resource/dic_goods.json
Normal file
20
shared/resource/dic_goods.json
Normal file
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"good_id": 1,
|
||||
"name": "青铜短剑",
|
||||
"lv": 1,
|
||||
"good_type": 1
|
||||
},
|
||||
{
|
||||
"good_id": 2,
|
||||
"name": "黑铁剑",
|
||||
"lv": 2,
|
||||
"good_type": 1
|
||||
},
|
||||
{
|
||||
"good_id": 3,
|
||||
"name": "饿狼长剑",
|
||||
"lv": 3,
|
||||
"good_type": 1
|
||||
}
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user