军团活动:修复粮草先行道具使用方式
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { GUILDACTIVITY } from "../../pubUtils/dicParam";
|
||||
import { SimpleGuildRankParam, SimpleRoleRankParam } from '../rank'
|
||||
import { prop } from "@typegoose/typegoose";
|
||||
import { CITY_STATUS, RACE_ACTIVITY_STATUS, RACE_EVENT } from "../../consts";
|
||||
import { CITY_STATUS, RACE_ACTIVITY_STATUS, RACE_EVENT, RACE_EVENT_TYPE } from "../../consts";
|
||||
import { gameData, getRaceEventItems } from "../../pubUtils/data";
|
||||
import { getRandEelm, getRandResultByMember, } from "../../pubUtils/util";
|
||||
import { RewardInter } from "../../pubUtils/interface";
|
||||
@@ -131,26 +131,36 @@ export class WoodenHorse {
|
||||
let effectiveEvents = new Array<Event>();
|
||||
for(let i = 0; i < events.length; i++) {
|
||||
let event = events[i];
|
||||
if(!event.startTime && event.startDistance && this.distance > event.startDistance) {
|
||||
if(event.useDistance() && event.startDistance && this.distance > event.startDistance) {
|
||||
let startTime = Date.now() - Math.floor((this.distance - event.startDistance) / this.speed);
|
||||
event.setStartTime(startTime); // 距离生效的事件的实际生效时间,主要用于速度叠加顺序
|
||||
}
|
||||
let isEffective = false;
|
||||
if(event.startTime <= Date.now() && event.endTime > Date.now()) {
|
||||
isEffective = true;
|
||||
} else if (event.startDistance <= this.distance && event.endDistance > this.distance) {
|
||||
isEffective = true;
|
||||
} else if (event.endTime < Date.now() || event.endDistance < this.distance) {
|
||||
if(event.endTime && event.startTime == event.endTime) {
|
||||
if(event.useTime()) {
|
||||
if(event.startTime <= Date.now() && event.endTime > Date.now()) {
|
||||
isEffective = true;
|
||||
}
|
||||
if(event.endDistance && event.startDistance == event.endDistance) {
|
||||
isEffective = true;
|
||||
if(event.endTime < Date.now()) {
|
||||
if(event.endTime && event.startTime == event.endTime) {
|
||||
isEffective = true;
|
||||
}
|
||||
let index = events.findIndex(cur => cur.id == event.id);
|
||||
events.splice(index, 1);
|
||||
}
|
||||
|
||||
let index = events.findIndex(cur => cur.id == event.id);
|
||||
events.splice(index, 1);
|
||||
}
|
||||
if(event.useDistance()) {
|
||||
if(event.startDistance <= this.distance && event.endDistance > this.distance) {
|
||||
isEffective = true;
|
||||
}
|
||||
if(event.endDistance < this.distance) {
|
||||
if(event.endDistance && event.startDistance == event.endDistance) {
|
||||
isEffective = true;
|
||||
}
|
||||
let index = events.findIndex(cur => cur.id == event.id);
|
||||
events.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(isEffective) {
|
||||
effectiveEvents.push(event);
|
||||
}
|
||||
@@ -279,24 +289,24 @@ export class Event {
|
||||
endDistance?: number;
|
||||
@prop({required: true})
|
||||
count: number = 1;
|
||||
@prop({required: true})
|
||||
type: number = 0; // 1-时间开启 2-距离开启
|
||||
|
||||
constructor(id: number, fromGuild: string, toGuild: string, count?: number, distance?: number) {
|
||||
|
||||
constructor(id: number, fromGuild: string, toGuild: string, count: number = 0, distance: number = 0) {
|
||||
let dicEvent = gameData.raceActivityEvents.get(id);
|
||||
this.id = id;
|
||||
this.fromGuild = fromGuild;
|
||||
this.toGuild = toGuild;
|
||||
|
||||
if(distance) {
|
||||
this.startDistance = distance;
|
||||
this.endDistance = this.startDistance + dicEvent.continueDistance;
|
||||
}
|
||||
if(dicEvent.effectTime) {
|
||||
this.startTime = Date.now() + dicEvent.effectTime * 1000;
|
||||
this.endTime = this.startTime + dicEvent.continueTime * 1000;
|
||||
}
|
||||
this.startDistance = distance;
|
||||
this.endDistance = this.startDistance + dicEvent.continueDistance;
|
||||
this.startTime = Date.now() + dicEvent.effectTime * 1000;
|
||||
this.endTime = this.startTime + dicEvent.continueTime * 1000;
|
||||
if(count) {
|
||||
this.count = count;
|
||||
}
|
||||
this.type = dicEvent.type;
|
||||
}
|
||||
|
||||
setStartTime(time: number) {
|
||||
@@ -312,6 +322,14 @@ export class Event {
|
||||
];
|
||||
return importantEvents.indexOf(this.id) != -1
|
||||
}
|
||||
|
||||
useDistance() {
|
||||
return this.type == RACE_EVENT_TYPE.EVENT||this.type == RACE_EVENT_TYPE.ITEM;
|
||||
}
|
||||
|
||||
useTime() {
|
||||
return this.type == RACE_EVENT_TYPE.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
export interface GuildRankParams {
|
||||
|
||||
Reference in New Issue
Block a user