军团:添加活跃宝箱
This commit is contained in:
@@ -70,6 +70,7 @@ export enum GUILD_OPERATE {
|
||||
BE_KICKED = 26, // 被踢出军团
|
||||
BE_SET_AUTH = 27, // 被授权头衔
|
||||
BE_IMPEACH = 28, // 被弹劾
|
||||
RECEIVE_ACTIVE = 29, // 领取每日活跃宝箱
|
||||
}
|
||||
|
||||
// 军团状态
|
||||
|
||||
@@ -304,7 +304,8 @@ export const FILENAME = {
|
||||
DIC_GUILD_TRAIN_BASE: 'trainBase',
|
||||
DIC_GUILD_DONATE_BASE: 'donatebase',
|
||||
DIC_GUILD_WISH_POOL_BASE: 'wishpool',
|
||||
DIC_GUILD_STORE_BASE: 'store'
|
||||
DIC_GUILD_STORE_BASE: 'store',
|
||||
DIC_ACTIVE_DAY_REWARD: 'activeDayReward'
|
||||
}
|
||||
|
||||
export const WAR_RELATE_TABLES = [
|
||||
|
||||
@@ -144,6 +144,9 @@ export const STATUS = {
|
||||
GUILD_STRUCTURE_LV_MAX: { code: 20915, simStr: '建筑物已升至满级' },
|
||||
GUILD_FUND_NOT_ENOUGH: { code: 20916, simStr: '资金不足' },
|
||||
GUILD_MANAGER_REACH_MAX: { code: 20917, simStr: '管理员人数达到最大' },
|
||||
GUILD_ACTIVE_BOX_NOT_FOUND: { code: 20918, simStr: '未找到该活跃宝箱' },
|
||||
GUILD_ACTIVE_POINT_NOT_REACH: { code: 20919, simStr: '军团活跃值不足' },
|
||||
GUILD_ACTIVE_BOX_HAS_RECEIVED: { code: 20920, simStr: '该活跃宝箱已领取' },
|
||||
|
||||
// 通用 30000 - 30099
|
||||
DIC_DATA_NOT_FOUND: { code: 30000, simStr: '数据表未找到' },
|
||||
|
||||
@@ -39,8 +39,14 @@ export default class UserGuild extends BaseModel {
|
||||
@prop({ required: true, type: ActiveRecord, default: [] })
|
||||
activeRecord: ActiveRecord[];
|
||||
|
||||
@prop({ required: true, default: new Date() })
|
||||
refTimeWeekly: number;
|
||||
@prop({ required: true, default: 0 })
|
||||
receivedActive: number;
|
||||
|
||||
@prop({ required: true, default: new Date(), select: false })
|
||||
refTimeDaily: Date;
|
||||
|
||||
@prop({ required: true, default: new Date(), select: false })
|
||||
refTimeWeekly: Date;
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
trainCount: number;//每日挑战训练场的次数
|
||||
@@ -98,7 +104,7 @@ export default class UserGuild extends BaseModel {
|
||||
const update = Object.assign(doc.toJSON(), { guildCode, roleId: role.roleId, role: role._id, job, auth });
|
||||
delete update._id;
|
||||
const result: UserGuildType = await UserGuildModel.findOneAndUpdate({ roleId: role.roleId, guildCode, status: USER_GUILD_STATUS.ON }, update, { upsert: true, new: true })
|
||||
.select('honourWeekly honourUpdateTime job auth')
|
||||
.select('honourWeekly honourUpdateTime job auth receivedActive')
|
||||
.lean();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -45,6 +45,8 @@ import { dicRankRewads, dicRankMax } from './dictionary/DicPvpRankReward';
|
||||
import { dicPvpBoxs } from './dictionary/DicPvpBox';
|
||||
import { dicGuildAuth } from './dictionary/DicGuildAuth';
|
||||
import { dicCenterBase, dicEquipPriduceBase, dicBossBase, dicTrainBase, dicDonateBase, dicWishPoolBase, dicStoreBase, dicStructureConsume } from "./dictionary/DicStructure";
|
||||
import { dicGuildActiveDayReward } from './dictionary/dicGuildActiveDayReward';
|
||||
import { RewardInter } from "./interface";
|
||||
|
||||
export const gameData = {
|
||||
blurprtCompose: dicBlueprtCompose,
|
||||
@@ -113,7 +115,8 @@ export const gameData = {
|
||||
donateBase: dicDonateBase,
|
||||
wishPoolBase: dicWishPoolBase,
|
||||
storeBase: dicStoreBase,
|
||||
structureConsume: dicStructureConsume
|
||||
structureConsume: dicStructureConsume,
|
||||
guildActiveDayReward: dicGuildActiveDayReward
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// 每日个人可领奖励
|
||||
import { readJsonFile, parseGoodStr } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
|
||||
export interface DicGuildActiveDayReward {
|
||||
|
||||
// id
|
||||
readonly id: number;
|
||||
// 权限
|
||||
readonly activeDayPoint: number;
|
||||
// 奖励
|
||||
readonly reward: RewardInter[];
|
||||
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_ACTIVE_DAY_REWARD);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicGuildActiveDayReward = new Map<number, DicGuildActiveDayReward>();
|
||||
|
||||
arr.forEach(o => {
|
||||
o.reward = parseGoodStr(o.reward)
|
||||
dicGuildActiveDayReward.set(o.id, o);
|
||||
});
|
||||
arr = undefined;
|
||||
@@ -38,4 +38,20 @@ export function getBeforeDayDate(day: number) {
|
||||
export function getBeforeDaySeconds(day: number) {
|
||||
let time = nowSeconds() - day * PER_DAY;
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export function getCurWeekDate(day: number, hour: number) {
|
||||
return getWeekDate(new Date(), day, hour);
|
||||
}
|
||||
|
||||
export function getWeekDate(now: Date, day: number, hour: number){ //获得本周的开端日期
|
||||
var nowDayOfWeek = now.getDay();
|
||||
if(nowDayOfWeek == 0) nowDayOfWeek = 7;
|
||||
|
||||
let nowDay = now.getDate();
|
||||
let nowYear = now.getFullYear(); //当前年
|
||||
let nowMonth = now.getMonth(); //月
|
||||
return new Date(nowYear, nowMonth, nowDay - nowDayOfWeek + day, hour);
|
||||
};
|
||||
@@ -8,6 +8,7 @@ import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
|
||||
import { HERO_CE_RATIO, ABI_STAGE } from '../consts';
|
||||
|
||||
import { findIndex } from 'underscore';
|
||||
import { getCurWeekDate, getWeekDate } from './timeUtil';
|
||||
const randomName = require("chinese-random-name");
|
||||
const moment = require('moment');
|
||||
|
||||
@@ -224,6 +225,27 @@ export function shouldRefresh(preTime: Date, now: Date, hour: number, deltaDay =
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算按照每 x 天 y 点刷新一次,是否应该刷新
|
||||
* @param preTime 基准时间
|
||||
* @param curTime 当前时间
|
||||
* @param day 周几刷新
|
||||
* @param hour 几点刷新
|
||||
* @param deltaDay 间隔几天刷新,默认每天刷新(deltaDay = 1)
|
||||
*/
|
||||
export function shouldRefreshWeek(preTime: Date, now: Date, day: number, hour: number, deltaWeek = 1): boolean {
|
||||
if (!preTime) return true;
|
||||
let curTime = new Date(now.getTime());
|
||||
let refreshTime = getWeekDate(now, day, hour);
|
||||
let refeshTime = refreshTime.getTime();
|
||||
|
||||
if (refeshTime - preTime.getTime() > (deltaWeek >= 1 ? deltaWeek - 1 : 0) * 7* 24 * 60 * 60 * 1000 && curTime.getTime() >= refeshTime) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 x天后的y点
|
||||
* @param curTime 现在时间
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"activeDayPoint": 1000,
|
||||
"Reward": 0
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"activeDayPoint": 2000,
|
||||
"Reward": 0
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"activeDayPoint": 3000,
|
||||
"Reward": 0
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"activeDayPoint": 4000,
|
||||
"Reward": 0
|
||||
}
|
||||
]
|
||||
@@ -138,5 +138,10 @@
|
||||
"id": 28,
|
||||
"name": "被弹劾",
|
||||
"authority": "1&"
|
||||
},
|
||||
{
|
||||
"id": 29,
|
||||
"name": "领取活跃宝箱",
|
||||
"authority": "1&2&3"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user