军团活动:诸侯混战城池状态
This commit is contained in:
@@ -410,7 +410,8 @@ export enum POPULATE_TYPE {
|
||||
NOT = 0,
|
||||
FRIEND = 1,
|
||||
BLACKLIST = 2,
|
||||
FRIENDSHIP = 3
|
||||
FRIENDSHIP = 3,
|
||||
FRIEND_NAME_ONLY = 4
|
||||
}
|
||||
|
||||
export enum BLOCK_OPEATE {
|
||||
|
||||
@@ -54,6 +54,9 @@ export default class FriendRelation extends BaseModel {
|
||||
.populate('blacklist.role', ROLE_SELECT.SHOW_SIMPLE, 'Role')
|
||||
} else if (populateType == POPULATE_TYPE.FRIENDSHIP) {
|
||||
document.populate('friends.friendShip', null, 'FriendShip');
|
||||
} else if (populateType == POPULATE_TYPE.FRIEND_NAME_ONLY) {
|
||||
document
|
||||
.populate('friends.role', 'roleName', 'Role')
|
||||
}
|
||||
|
||||
let result: FriendRelationType = await document.lean({ getters: true, virtuals: true });;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
import { ItemReward } from '../domain/dbGeneral';
|
||||
import { getTodayZeroDate } from '../pubUtils/timeUtil';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
import { Member, WoodenHorse } from '../domain/battleField/guildActivity'
|
||||
import { Member, WoodenHorse, Event } from '../domain/battleField/guildActivity'
|
||||
|
||||
|
||||
@index({ code: 1 })
|
||||
@@ -56,13 +56,18 @@ export default class GuildActivityRecord extends BaseModel {
|
||||
|
||||
@prop({ required: true, _id: false })
|
||||
woodenHorse: WoodenHorse; // 粮草先行木马
|
||||
|
||||
@prop({ required: true, type: () => Event, _id: false })
|
||||
events: Event[]; // 粮草先行木马
|
||||
|
||||
|
||||
// 每天一条记录
|
||||
public static async getRecord(guildCode: string, serverId: number, aid: number) {
|
||||
public static async getRecord(guildCode: string, serverId: number, aid: number, events?: Event[]) {
|
||||
let today = getTodayZeroDate();
|
||||
let docs = new GuildActivityRecordModel();
|
||||
let code = genCode(10);
|
||||
let update = Object.assign(docs, { code, guildCode, serverId, aid, createdAt: new Date() })
|
||||
let update = Object.assign(docs, { code, guildCode, serverId, aid, createdAt: new Date() });
|
||||
if(events) update = Object.assign(update, { events });
|
||||
let rec: GuildActivityRecordType = await GuildActivityRecordModel.findOneAndUpdate(
|
||||
{ guildCode, createdAt: { $gte: today }},
|
||||
{ $setOnInsert: update },
|
||||
@@ -79,6 +84,16 @@ export default class GuildActivityRecord extends BaseModel {
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
||||
public static async pushEvent(guildCode: string, event: Event) {
|
||||
let today = getTodayZeroDate();
|
||||
|
||||
let rec: GuildActivityRecordType = await GuildActivityRecordModel.findOneAndUpdate(
|
||||
{ guildCode, createdAt: { $gte: today } },
|
||||
{ $push: { events: event } }, { new: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async findBySourceCode(guildCode: string, sourceType: number, sourceCode: string) {
|
||||
const rec = await GuildActivityRecordModel.findOne({ guildCode, auctionType: sourceType, code: sourceCode }).select('members').lean();
|
||||
return rec;
|
||||
|
||||
@@ -278,7 +278,7 @@ export class RaceActivityObject {
|
||||
|
||||
public async useItem(fromRoleId: string, sid: string, fromGuild: string, toGuild: string, id: number, count: number) {
|
||||
let rec = this.handleItem(fromRoleId, sid, id, count);
|
||||
if(!rec) return rec;
|
||||
if(!rec) return false;
|
||||
let event = new Event(id, fromGuild, toGuild, count);
|
||||
if(!this.events.has(toGuild)) {
|
||||
this.events.set(toGuild, [event]);
|
||||
@@ -287,6 +287,8 @@ export class RaceActivityObject {
|
||||
}
|
||||
let chatSid = await getGuildChannelSid(toGuild);
|
||||
pinus.app.rpc.chat.guildRemote.sendRaceEvent.toServer(chatSid, toGuild, [event]);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
// 定时任务到,开始比赛,设置开始赛道,发放初始道具
|
||||
@@ -546,13 +548,21 @@ export class WoodenHorse {
|
||||
}
|
||||
|
||||
export class Event {
|
||||
@prop({required: true})
|
||||
id: number;
|
||||
@prop({required: true})
|
||||
fromGuild: string;
|
||||
@prop({required: true})
|
||||
toGuild: string;
|
||||
@prop({required: true})
|
||||
startTime?: number;
|
||||
@prop({required: true})
|
||||
startDistance?: number;
|
||||
@prop({required: true})
|
||||
endTime?: number;
|
||||
@prop({required: true})
|
||||
endDistance?: number;
|
||||
@prop({required: true})
|
||||
count: number = 1;
|
||||
|
||||
constructor(id: number, fromGuild: string, toGuild: string, distance?: number, count?: number) {
|
||||
|
||||
@@ -61,7 +61,7 @@ import { Attribute } from "../domain/roleField/attribute";
|
||||
import { dicGuildActivity, DicGuildActivity } from './dictionary/DicGuildActivity';
|
||||
import { dicGateActivityPoint } from './dictionary/DicGateActivityPoint';
|
||||
import { dicGuildAuction } from './dictionary/DicGuildAuction';
|
||||
import { getCutDay } from "./timeUtil";
|
||||
import { getCurDay } from "./timeUtil";
|
||||
import { dicCityActivity } from "./dictionary/DicCityActivity";
|
||||
import { dicChatAccuse } from "./dictionary/DicChatAccuse";
|
||||
import { dicCityActivityReward } from "./dictionary/DicCityActivityReward";
|
||||
@@ -463,7 +463,7 @@ export function getDicFriendByLv(lv: number) {
|
||||
* @description 获取今天开启的活动的配置
|
||||
*/
|
||||
export function getTodayGuildActivity() {
|
||||
let today = getCutDay();
|
||||
let today = getCurDay();
|
||||
let dic: DicGuildActivity;
|
||||
for(let [_id, dicGuildActivity] of gameData.guildActivity) {
|
||||
if(dicGuildActivity.openDay.includes(today)) {
|
||||
|
||||
@@ -18,6 +18,8 @@ export interface DicCityActivity {
|
||||
readonly warid: number;
|
||||
// 城门血条
|
||||
readonly hp: number;
|
||||
// 可开启星期
|
||||
readonly week: number[];
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_CITY_ACTIVITY);
|
||||
@@ -27,6 +29,7 @@ export const dicCityActivity = new Map<number, DicCityActivity>();
|
||||
|
||||
arr.forEach(o => {
|
||||
o.preCity = parseNumberList(o.preCity);
|
||||
o.week = parseNumberList(o.week);
|
||||
dicCityActivity.set( o.id, o );
|
||||
});
|
||||
arr = undefined;
|
||||
@@ -11,9 +11,9 @@ export interface DicGuildActivity {
|
||||
// 持续时间 秒
|
||||
readonly duringTime: number;
|
||||
// 开启时间 几点
|
||||
readonly startTime: number;
|
||||
startTime: number;
|
||||
// 开启时间 几点
|
||||
readonly startMinute: number;
|
||||
startMinute: number;
|
||||
// 开始倒计时 几点
|
||||
readonly countDown: number;
|
||||
// 对应关卡id
|
||||
|
||||
@@ -180,9 +180,22 @@ export function getNextTime(date: Date, h: number, m = 0, s = 0, ms = 0): Date {
|
||||
* @param needHandle 是否处理周日
|
||||
* @param {Date} time
|
||||
*/
|
||||
export function getCutDay( needHandle = false, time?: Date) {
|
||||
|
||||
let week = undefined;
|
||||
|
||||
export function getCurDay( needHandle = false, time?: Date) {
|
||||
if(!time) time = new Date();
|
||||
let d = time.getDay();
|
||||
if(needHandle && d == 0) d = 7;
|
||||
|
||||
if(week != undefined) {
|
||||
d = week;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
export function setWeek(d?: number) {
|
||||
week = d;
|
||||
if(d == 7) week = 0;
|
||||
}
|
||||
@@ -7,7 +7,8 @@
|
||||
"preCity": 0,
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 20000
|
||||
"hp": 20000,
|
||||
"week": "2&4&6"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
@@ -17,7 +18,8 @@
|
||||
"preCity": 0,
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 20000
|
||||
"hp": 20000,
|
||||
"week": "2&4&6"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
@@ -27,7 +29,8 @@
|
||||
"preCity": 0,
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 20000
|
||||
"hp": 20000,
|
||||
"week": "2&4&6"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
@@ -37,7 +40,8 @@
|
||||
"preCity": 0,
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 20000
|
||||
"hp": 20000,
|
||||
"week": "2&4&6"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
@@ -47,7 +51,8 @@
|
||||
"preCity": 0,
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 20000
|
||||
"hp": 20000,
|
||||
"week": "2&4&6"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
@@ -57,7 +62,8 @@
|
||||
"preCity": 0,
|
||||
"difficult": 90,
|
||||
"warid": 7002,
|
||||
"hp": 20000
|
||||
"hp": 20000,
|
||||
"week": "2&4&6"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
@@ -67,7 +73,8 @@
|
||||
"preCity": "1&2",
|
||||
"difficult": 100,
|
||||
"warid": 7003,
|
||||
"hp": 30000
|
||||
"hp": 30000,
|
||||
"week": "4&6"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
@@ -77,7 +84,8 @@
|
||||
"preCity": "3&4",
|
||||
"difficult": 100,
|
||||
"warid": 7003,
|
||||
"hp": 30000
|
||||
"hp": 30000,
|
||||
"week": "4&6"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
@@ -87,7 +95,8 @@
|
||||
"preCity": "5&6",
|
||||
"difficult": 100,
|
||||
"warid": 7003,
|
||||
"hp": 50000
|
||||
"hp": 50000,
|
||||
"week": "4&6"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
@@ -97,6 +106,7 @@
|
||||
"preCity": "7&8&9",
|
||||
"difficult": 110,
|
||||
"warid": 7004,
|
||||
"hp": 50000
|
||||
"hp": 50000,
|
||||
"week": "6&"
|
||||
}
|
||||
]
|
||||
@@ -4,8 +4,8 @@
|
||||
"name": "蛮夷入侵",
|
||||
"openDay": "3&0",
|
||||
"duringTime": 900,
|
||||
"startTime": 20,
|
||||
"startMinute": 0,
|
||||
"startTime": 14,
|
||||
"startMinute": 48,
|
||||
"countDown": 5,
|
||||
"warid": 7001,
|
||||
"honour": 500
|
||||
|
||||
Reference in New Issue
Block a user