✨ feat(gvg): 准备期征战中原初始
This commit is contained in:
@@ -5,6 +5,7 @@ import { index, getModelForClass, prop, DocumentType, } from '@typegoose/typegoo
|
||||
import { getFutureTime, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
import { GVG } from '../pubUtils/dicParam';
|
||||
import { GVG_RESOURCE_TYPE } from '../consts';
|
||||
|
||||
@index({ leagueCode: 1, configId: 1 })
|
||||
@index({ fieldId: 1 })
|
||||
@@ -138,9 +139,10 @@ export default class GVGLeagueFarm extends BaseModel {
|
||||
public static async lockMineOrForestry(configId: number, leagueCode: string, farmId: number, type: number, roleId: string, fieldId: number, itemId: number) {
|
||||
// 先创建
|
||||
await GVGLeagueFarmModel.findOneAndUpdate({ configId, leagueCode, farmId, fieldId }, { $setOnInsert: { unlockTime: 0, itemId: 0, type } }, { upsert: true });
|
||||
let unlockTime = nowSeconds() + type == GVG_RESOURCE_TYPE.MINERAL? GVG.GVG_MINE_LOCK_TIME: GVG.GVG_FORESTRY_LOCK_TIME;
|
||||
const result: GVGLeagueFarmType = await GVGLeagueFarmModel.findOneAndUpdate(
|
||||
{ configId, leagueCode, farmId, fieldId, $or:[{ unlockTime: { $lt: nowSeconds() } }, {lockRoleId: roleId}] },
|
||||
{ $set: { unlockTime: nowSeconds() + GVG.GVG_FARM_LOCK_TIME, lockRoleId: roleId, itemId } },
|
||||
{ $set: { unlockTime, lockRoleId: roleId, itemId } },
|
||||
{ new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user