军团活动:添加诸侯混战表

This commit is contained in:
luying
2021-03-19 20:45:09 +08:00
parent 44313009b1
commit 7df19fd510
5 changed files with 101 additions and 14 deletions

View File

@@ -7,6 +7,7 @@ import { ServerlistModel } from "../../../db/Serverlist";
import { UserGuildActivityRecModel, Record } from "../../../db/UserGuildActivityRec";
import { GUILDACTIVITY } from "../../../pubUtils/dicParam";
import { GuildActivityRecordModel } from "../../../db/GuildActivityRec";
import { GuildActivityCityModel } from "../../../db/GuildActivityCity";
import { RoleModel, RoleType } from "../../../db/Role";
import { GuildModel } from "../../../db/Guild";
import { RankParam, GuildRankParam } from "../../../domain/rank";
@@ -280,10 +281,14 @@ export class GateActivityHandler {
return resResult(STATUS.SUCCESS, res)
}
async test() {
async test(msg: { }, session: BackendSession) {
let guildCode = session.get('guildCode');
let serverId = session.get('serverId');
let result = await setMedianCe();
return resResult(STATUS.SUCCESS, {result});
await GuildActivityCityModel.declare(serverId, 1, guildCode);
// let result = await setMedianCe();
// return resResult(STATUS.SUCCESS, {result});
}
async debugIncChallengeCnt(msg: { }, session: BackendSession) {

View File

@@ -342,7 +342,8 @@ export const FILENAME = {
DIC_ROLE_FRIEND_LEVEL: 'dic_zyz_closelevel',
DIC_GUILD_ACTIVITY: 'dic_zyz_guildActivity',
DIC_GATE_ACTIVITY_POINT: 'dic_zyz_gateActivityPoint',
DIC_GUILD_AUCTION: 'dic_zyz_guildAuction'
DIC_GUILD_AUCTION: 'dic_zyz_guildAuction',
DIC_CITY_ACTIVITY: 'dic_zyz_cityActivity'
}
export const WAR_RELATE_TABLES = [

View File

@@ -0,0 +1,42 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { getTodayZeroDate } from '../pubUtils/timeUtil';
@index({ code: 1 })
export default class GuildActivityCity extends BaseModel {
@prop({ required: true })
serverId: number; // 分服
@prop({ required: true })
cityId: number; // 城池id
@prop({ required: true, type: String, default: [] })
declareGuilds: string[]; // 宣战的公会的code
@prop({ required: true, default: 0 })
declareCnt: number; // 宣战数量
@prop({ required: true })
guardGuildCode: string; // 占领的军团的code
@prop({ required: true })
guardGuildName: string; // 占领的军团名
// 每天宣战一次
public static async declare(serverId: number, cityId: number, guildCode: string) {
let today = getTodayZeroDate();
let rec: GuildActivityCityType = await GuildActivityCityModel.findOneAndUpdate(
{ serverId, cityId, createdAt: { $gte: today }, declareGuilds: { $nin: [guildCode] }},
{ $setOnInsert: { cityId }, $push: { declareGuilds: guildCode }, $inc: {declareCnt: 1 } },
{new: true, upsert: true}).lean();
return rec;
}
}
export const GuildActivityCityModel = getModelForClass(GuildActivityCity);
export interface GuildActivityCityType extends Pick<DocumentType<GuildActivityCity>, keyof GuildActivityCity> { };
export type GuildActivityCityUpdateParam = Partial<GuildActivityCityType>; // 将所有字段变成可选项

View File

@@ -0,0 +1,29 @@
// 军团诸侯混战城池表
import { readJsonFile, parseNumberList } from '../util'
import { FILENAME } from '../../consts'
export interface DicCityActivity {
// 城池id
readonly id: number;
// 城池类型
readonly type: number;
// 下一次自动宣战城池
readonly nextCity: number;
// 难度系数
readonly difficult: number;
// 相应的出兵表
readonly warid: number;
// 城门血条
readonly hp: number;
}
const str = readJsonFile(FILENAME.DIC_CITY_ACTIVITY);
let arr = JSON.parse(str);
export const dicCityActivity = new Map<number, DicCityActivity>();
arr.forEach(o => {
dicCityActivity.set( o.id, o );
});
arr = undefined;

View File

@@ -5,7 +5,8 @@
"type": 1,
"nextCity": 7,
"difficult": 90,
"warid": 0
"warid": 7002,
"hp": 20000
},
{
"id": 2,
@@ -13,7 +14,8 @@
"type": 1,
"nextCity": 7,
"difficult": 90,
"warid": 0
"warid": 7002,
"hp": 20000
},
{
"id": 3,
@@ -21,7 +23,8 @@
"type": 1,
"nextCity": 8,
"difficult": 90,
"warid": 0
"warid": 7002,
"hp": 20000
},
{
"id": 4,
@@ -29,7 +32,8 @@
"type": 1,
"nextCity": 8,
"difficult": 90,
"warid": 0
"warid": 7002,
"hp": 20000
},
{
"id": 5,
@@ -37,7 +41,8 @@
"type": 1,
"nextCity": 9,
"difficult": 90,
"warid": 0
"warid": 7002,
"hp": 20000
},
{
"id": 6,
@@ -45,7 +50,8 @@
"type": 1,
"nextCity": 9,
"difficult": 90,
"warid": 0
"warid": 7002,
"hp": 20000
},
{
"id": 7,
@@ -53,7 +59,8 @@
"type": 2,
"nextCity": 10,
"difficult": 100,
"warid": 0
"warid": 7002,
"hp": 30000
},
{
"id": 8,
@@ -61,7 +68,8 @@
"type": 2,
"nextCity": 10,
"difficult": 100,
"warid": 0
"warid": 7002,
"hp": 30000
},
{
"id": 9,
@@ -69,7 +77,8 @@
"type": 2,
"nextCity": 10,
"difficult": 100,
"warid": 0
"warid": 7002,
"hp": 50000
},
{
"id": 10,
@@ -77,6 +86,7 @@
"type": 3,
"nextCity": 0,
"difficult": 110,
"warid": 0
"warid": 7002,
"hp": 50000
}
]