军团活动:诸侯混战城门血量
This commit is contained in:
@@ -310,4 +310,6 @@ export enum RACE_ACTIVITY_STATUS {
|
||||
WAITING = 0, // 未开始
|
||||
START = 1, // 已开始
|
||||
END = 2 // 已结束
|
||||
}
|
||||
}
|
||||
|
||||
export const CITY_ACTIVITY_DOOR = 1047;
|
||||
@@ -37,7 +37,7 @@ export class CeAttrDataRole {
|
||||
}
|
||||
}
|
||||
|
||||
class TopHero {
|
||||
export class TopHero {
|
||||
@prop({ required: true })
|
||||
hid: number; // 武将id
|
||||
@prop({ required: true })
|
||||
@@ -696,12 +696,12 @@ export default class Role extends BaseModel {
|
||||
}
|
||||
|
||||
// 获取战力在中位数的玩家
|
||||
public static async getMedianRole(serverId: number) {
|
||||
public static async getActivePlayers(serverId: number) {
|
||||
let yesterday = <Date>getTimeFunD().getBeforeDayWithHour(1);
|
||||
const roles: RoleType[] = await RoleModel.find({ serverId, updatedAt: { $gte: yesterday } })
|
||||
.select('topLineup')
|
||||
.select('topLineup topLineupCe')
|
||||
.sort({ ce: -1 }).lean();
|
||||
return roles[Math.floor(roles.length / 2)]
|
||||
return roles
|
||||
}
|
||||
|
||||
public static async receiveRankReward(roleId: string, ids: number[]) {
|
||||
|
||||
73
shared/db/ServerRecords.ts
Normal file
73
shared/db/ServerRecords.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { RoleType, TopHero } from './Role';
|
||||
import { getZeroPoint } from '../pubUtils/timeUtil';
|
||||
|
||||
export class ActivePlayer {
|
||||
@prop({ required: true })
|
||||
roleId: string;
|
||||
@prop({ required: true })
|
||||
topLineupCe: number;
|
||||
@prop({ required: true, type: TopHero, default: [], _id: false })
|
||||
topLineup: Array<TopHero>; // 总战力
|
||||
|
||||
constructor(role: RoleType) {
|
||||
this.roleId = role.roleId;
|
||||
this.topLineupCe = role.topLineupCe;
|
||||
this.topLineup = role.topLineup;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 游戏字段接口
|
||||
*/
|
||||
@index({ serverId: 1, date: 1 })
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
export default class ServerRecord extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: 1 })
|
||||
serverId: number; // 小区id
|
||||
|
||||
@prop({ required: true, default: 1 })
|
||||
today: number; // 天
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
activePlayerCe: number; // 前一天活跃玩家前十的最强6人战力和
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
activePlayerCnt: number; // 前一天活跃玩家人数
|
||||
|
||||
@prop({ required: true, type: ActivePlayer, _id: false })
|
||||
activePlayers: ActivePlayer[]; // 前一天的活跃玩家
|
||||
|
||||
@prop({ required: true, type: String, default: [] })
|
||||
activeGuildCodes: string[]; // 前一天参与军团活动的军团
|
||||
|
||||
public static async updateData(serverId: number, update: ServerRecordUpdate) {
|
||||
let today = getZeroPoint();
|
||||
const doc = new ServerRecordModel();
|
||||
let rec: ServerRecordType = await ServerRecordModel.findOneAndUpdate({ serverId, today }, { $set: { ...doc.toJSON(), ...update } }, { new: true, upsert: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async addActiveGuild(serverId: number, guildCode: string) {
|
||||
let tomorrow = getZeroPoint() + 86400;
|
||||
let rec: ServerRecordType = await ServerRecordModel.findOneAndUpdate({ serverId, today: tomorrow }, { $addToSet: [guildCode] }, { new: true, upsert: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async findTodayData(serverId: number) {
|
||||
let today = getZeroPoint();
|
||||
let rec: ServerRecordType = await ServerRecordModel.findOne({ serverId, today }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const ServerRecordModel = getModelForClass(ServerRecord);
|
||||
|
||||
export interface ServerRecordType extends Pick<DocumentType<ServerRecord>, keyof ServerRecord> {
|
||||
id: number;
|
||||
};
|
||||
export type ServerRecordUpdate = Partial<ServerRecordType>; // 将所有字段变成可选项
|
||||
@@ -25,6 +25,7 @@ export class Maintenance {
|
||||
hasNotify: boolean; // 是否有维护通知
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏字段接口
|
||||
*/
|
||||
@@ -86,9 +87,6 @@ export default class Serverlist extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
playerCnt: number; // 当前玩家人数
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
medianCe: number; // 中位数武将战力、缩小10000倍后的结果
|
||||
|
||||
@prop({ required: true, type: Maintenance, _id: false })
|
||||
maintenance: Maintenance
|
||||
|
||||
|
||||
@@ -16,10 +16,12 @@ export interface DicCityActivity {
|
||||
readonly difficult: number;
|
||||
// 相应的出兵表
|
||||
readonly warid: number;
|
||||
// 城门血条
|
||||
readonly hp: number;
|
||||
// 可开启星期
|
||||
readonly week: number[];
|
||||
// 保底血量
|
||||
readonly hp: number;
|
||||
// 城门倍率
|
||||
readonly hpN: number;
|
||||
}
|
||||
|
||||
export const dicCityActivity = new Map<number, DicCityActivity>();
|
||||
|
||||
@@ -223,5 +223,23 @@
|
||||
"template": "<color=#53e1fb>%d</color><color=#301B0C>正在招兵买马:</color><color=#c08834>%d</color><color=#2f9b00><on click=%d>[前往]</on></color>",
|
||||
"worldchat": "<outline color=#1c1613 width=1><color=#53e1fb>%d</color>正在招兵买马:%d<color=#2f9b00><on click=%d>[前往]</on></color></outline>",
|
||||
"comments": "1:%d(军团名);2:%d(军团招募内容)"
|
||||
},
|
||||
{
|
||||
"id": 25,
|
||||
"name": "EQUIP_STAR_UP",
|
||||
"mean": "装备升至12星",
|
||||
"type": "1&",
|
||||
"template": "<color=#301B0C>恭喜</color><color=#c08834>%d</color><color=#301B0C>,成功将</color><on click=%d>%d</on><color=#301B0C>升至满星</color>",
|
||||
"worldchat": "<outline color=#1c1613 width=1>恭喜<color=#c08834>%d</color>,成功将<on click=%d>%d</on>升至满星</outline>",
|
||||
"comments": "1:%d(玩家名);2:%d(装备名)"
|
||||
},
|
||||
{
|
||||
"id": 26,
|
||||
"name": "EQUIP_QUALITY_UP",
|
||||
"mean": "装备升至金色",
|
||||
"type": "1&",
|
||||
"template": "<color=#301B0C>恭喜</color><color=#c08834>%d</color><color=#301B0C>,成功将</color><on click=%d>%d</on><color=#301B0C>升至最高品质</color>",
|
||||
"worldchat": "<outline color=#1c1613 width=1>恭喜<color=#c08834>%d</color>,成功将<on click=%d>%d</on>升至最高品质</outline>",
|
||||
"comments": "1:%d(玩家名);2:%d(装备名)"
|
||||
}
|
||||
]
|
||||
@@ -8,7 +8,8 @@
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 5000000,
|
||||
"week": "2&4&6"
|
||||
"week": "2&4&6",
|
||||
"hpN": 1
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
@@ -19,7 +20,8 @@
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 5000000,
|
||||
"week": "2&4&6"
|
||||
"week": "2&4&6",
|
||||
"hpN": 1
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
@@ -30,7 +32,8 @@
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 5000000,
|
||||
"week": "2&4&6"
|
||||
"week": "2&4&6",
|
||||
"hpN": 1
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
@@ -41,7 +44,8 @@
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 5000000,
|
||||
"week": "2&4&6"
|
||||
"week": "2&4&6",
|
||||
"hpN": 1
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
@@ -52,7 +56,8 @@
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 5000000,
|
||||
"week": "2&4&6"
|
||||
"week": "2&4&6",
|
||||
"hpN": 1
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
@@ -63,7 +68,8 @@
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 5000000,
|
||||
"week": "2&4&6"
|
||||
"week": "2&4&6",
|
||||
"hpN": 1
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
@@ -74,7 +80,8 @@
|
||||
"difficult": 100,
|
||||
"warid": 7003,
|
||||
"hp": 10000000,
|
||||
"week": "4&6"
|
||||
"week": "4&6",
|
||||
"hpN": 2
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
@@ -85,7 +92,8 @@
|
||||
"difficult": 100,
|
||||
"warid": 7003,
|
||||
"hp": 10000000,
|
||||
"week": "4&6"
|
||||
"week": "4&6",
|
||||
"hpN": 2
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
@@ -96,7 +104,8 @@
|
||||
"difficult": 100,
|
||||
"warid": 7003,
|
||||
"hp": 10000000,
|
||||
"week": "4&6"
|
||||
"week": "4&6",
|
||||
"hpN": 2
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
@@ -107,6 +116,7 @@
|
||||
"difficult": 110,
|
||||
"warid": 7004,
|
||||
"hp": 30000000,
|
||||
"week": "6&"
|
||||
"week": "6&",
|
||||
"hpN": 3
|
||||
}
|
||||
]
|
||||
@@ -169,7 +169,7 @@
|
||||
"lv": 1,
|
||||
"hide": 0,
|
||||
"initial_ai": 0,
|
||||
"attribute": "1&2000000|2&2000|4&2500|5&2500",
|
||||
"attribute": "1&1000000",
|
||||
"skill": 0,
|
||||
"seid": 0,
|
||||
"star": 0,
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
"lv": 40,
|
||||
"hide": 1,
|
||||
"initial_ai": 0,
|
||||
"attribute": "&",
|
||||
"attribute": "2&3000",
|
||||
"skill": 0,
|
||||
"seid": 0,
|
||||
"star": 0,
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
"lv": 45,
|
||||
"hide": 1,
|
||||
"initial_ai": 0,
|
||||
"attribute": "&",
|
||||
"attribute": "2&3000",
|
||||
"skill": 0,
|
||||
"seid": 0,
|
||||
"star": 0,
|
||||
@@ -254,8 +254,8 @@
|
||||
},
|
||||
{
|
||||
"warId": 7003,
|
||||
"actorName": "骑兵",
|
||||
"actorId": 1003,
|
||||
"actorName": "武道家",
|
||||
"actorId": 1005,
|
||||
"dataId": 2006,
|
||||
"relation": 2,
|
||||
"outIndex": 5,
|
||||
@@ -277,8 +277,8 @@
|
||||
},
|
||||
{
|
||||
"warId": 7003,
|
||||
"actorName": "骑兵",
|
||||
"actorId": 1003,
|
||||
"actorName": "武道家",
|
||||
"actorId": 1005,
|
||||
"dataId": 2007,
|
||||
"relation": 2,
|
||||
"outIndex": 6,
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
"lv": 45,
|
||||
"hide": 1,
|
||||
"initial_ai": 0,
|
||||
"attribute": "&",
|
||||
"attribute": "2&3000",
|
||||
"skill": 0,
|
||||
"seid": 0,
|
||||
"star": 0,
|
||||
|
||||
Reference in New Issue
Block a user