活动:大富翁
This commit is contained in:
@@ -124,6 +124,26 @@ export enum DAILY_MEAL_TYPE {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 土地类型
|
||||
*/
|
||||
|
||||
export enum LAND_TYPE {
|
||||
BANK_NORMAL = 1, // 普通土地,银行
|
||||
BANK_COIN = 2, // 铜币银行
|
||||
BANK_GOLD = 3, // 元宝银行
|
||||
SHOP = 4, // 商店
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行操作
|
||||
*/
|
||||
|
||||
export enum BANK_TYPE {
|
||||
IN = 1, // 进
|
||||
OUT = 2, // 出
|
||||
}
|
||||
|
||||
//服务器开服时间
|
||||
export const SERVER_OPEN_TIME = '2021-06-06T20:03:16.637+08:00';
|
||||
//玩家等级大于等于15级才能开启vip签到
|
||||
|
||||
@@ -363,6 +363,10 @@ export const STATUS = {
|
||||
ACTIVITY_NEW_PLAYER_GIFT_END: { code: 50026, simStr: '新手活动结束' },
|
||||
ACTIVITY_POP_UP_SHOP_CLOSED: { code: 50027, simStr: '商店已经关闭' },
|
||||
ACTIVITY_PRE_UNCOMPLETE: { code: 50028, simStr: '上一个任务还未领取' },
|
||||
MONOPOLY_LAND_TYPE_ERROR: { code: 50029, simStr: '土地类型错误' },
|
||||
MONOPOLY_BANK: { code: 50030, simStr: '已经存过' },
|
||||
MONOPOLY_BANK_COUNT_ERROR: { code: 50031, simStr: '数量错误' },
|
||||
MONOPOLY_BANK_SAVE_MAX: { code: 50032, simStr: '超过最大限制数量' },
|
||||
// GM后台相关状态 60000 - 69999
|
||||
GM_ERR_PASSWORD: { code: 60001, simStr: '账号或密码错误' },
|
||||
GM_MISS_API: { code: 60002, simStr: '未找到该接口' },
|
||||
|
||||
47
shared/db/ActivityMonopoly.ts
Normal file
47
shared/db/ActivityMonopoly.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 活动系统 - 大富翁
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class Activity_Monopoly extends BaseModel {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服Id
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true, default: 0 })
|
||||
starPosition: number; // 初始位置
|
||||
@prop({ required: true })
|
||||
curPosition: number; // 当前位置
|
||||
@prop({ required: true, default: 1 })
|
||||
roundIndex: number; // 回合数
|
||||
|
||||
//更新坐标
|
||||
public static async updatePosition(serverId: number, activityId: number, roleId: string, curPosition: number, roundIndex: number) {
|
||||
let result: ActivityMonopolyModelType = await ActivityMonopolyModel.findOneAndUpdate({ serverId, roleId, activityId },
|
||||
{ $set: { curPosition }, $inc: { roundIndex } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询数据
|
||||
public static async findData(serverId: number, activityId: number, roleId: string) {
|
||||
let result: ActivityMonopolyModelType = await ActivityMonopolyModel.findOne({ serverId, roleId, activityId }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动记录
|
||||
public static async deleteActivity(serverId: number, activityId: number, roleId: string) {
|
||||
await ActivityMonopolyModel.deleteMany({ serverId, roleId, activityId });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityMonopolyModel = getModelForClass(Activity_Monopoly);
|
||||
|
||||
export interface ActivityMonopolyModelType extends Pick<DocumentType<Activity_Monopoly>, keyof Activity_Monopoly> { }
|
||||
export type ActivityMonopolyModelTypeParam = Partial<ActivityMonopolyModelType>; // 将所有字段变成可选项
|
||||
90
shared/db/ActivityMonopolyLand.ts
Normal file
90
shared/db/ActivityMonopolyLand.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
/**
|
||||
* 记录
|
||||
*/
|
||||
|
||||
export class Record {
|
||||
@prop({ required: true })
|
||||
resource: string; //类型&资源id&数量
|
||||
@prop({ required: true })
|
||||
type: number; //1,存入,2取出
|
||||
@prop({ required: true })
|
||||
time: Date; //购买时间
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 活动系统 - 大富翁
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class Activity_Monopoly_Land extends BaseModel {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服Id
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
position: number; // 位置
|
||||
@prop({ required: true, default: 1 })
|
||||
level: number; // 等级
|
||||
@prop({ required: true, default: [] })
|
||||
record: Record[]; // 记录
|
||||
@prop({ required: true })
|
||||
stopCount: number; // 停留次数
|
||||
|
||||
|
||||
//更新等级
|
||||
public static async updateLevel(serverId: number, activityId: number, roleId: string, position: number, level: number) {
|
||||
let result: ActivityMonopolyLandModelType = await ActivityMonopolyLandModel.findOneAndUpdate({
|
||||
serverId, roleId, activityId, position
|
||||
},
|
||||
{ $set: { level } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//更新停留次数
|
||||
public static async updateStopCount(serverId: number, activityId: number, roleId: string, position: number) {
|
||||
let result: ActivityMonopolyLandModelType = await ActivityMonopolyLandModel.findOneAndUpdate({
|
||||
serverId, roleId, activityId, position
|
||||
},
|
||||
{ $inc: { stopCount: 1 } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//添加记录
|
||||
public static async addRecord(serverId: number, activityId: number, roleId: string, position: number, type: number, resource: string) {
|
||||
let result: ActivityMonopolyLandModelType = await ActivityMonopolyLandModel.findOneAndUpdate({
|
||||
serverId, roleId, activityId, position
|
||||
},
|
||||
{ $push: { record: { resource, type, time: new Date() } } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询数据
|
||||
public static async findData(serverId: number, activityId: number, roleId: string) {
|
||||
let result: ActivityMonopolyLandModelType[] = await ActivityMonopolyLandModel.find({ serverId, roleId, activityId }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询数据
|
||||
public static async findDataByPosition(serverId: number, activityId: number, roleId: string, position: number) {
|
||||
let result: ActivityMonopolyLandModelType = await ActivityMonopolyLandModel.findOne({ serverId, roleId, activityId, position }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动记录
|
||||
public static async deleteActivity(serverId: number, activityId: number, roleId: string) {
|
||||
await ActivityMonopolyLandModel.deleteMany({ serverId, roleId, activityId });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityMonopolyLandModel = getModelForClass(Activity_Monopoly_Land);
|
||||
|
||||
export interface ActivityMonopolyLandModelType extends Pick<DocumentType<Activity_Monopoly_Land>, keyof Activity_Monopoly_Land> { }
|
||||
export type ActivityMonopolyLandModelTypeParam = Partial<ActivityMonopolyLandModelType>; // 将所有字段变成可选项
|
||||
@@ -13,6 +13,7 @@ export class DailyGKItem {
|
||||
|
||||
constructor(data: any) {
|
||||
this.dayIndex = data.dayIndex;
|
||||
this.gk = data.gk;
|
||||
this.name = data.name;
|
||||
this.reward = data.reward;
|
||||
this.isSuccess = false;
|
||||
|
||||
73
shared/domain/activityField/monopolyField.ts
Normal file
73
shared/domain/activityField/monopolyField.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityMonopolyModelType } from '../../db/ActivityMonopoly';
|
||||
import { ActivityMonopolyLandModelType } from '../../db/ActivityMonopolyLand';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
|
||||
// 地块数据
|
||||
export class LandItem {
|
||||
position: number; // 位置
|
||||
name: string; // 名字
|
||||
level: number; // 等级
|
||||
rewards: string[]; // 奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
landType: number //土地性质 LAND_TYPE
|
||||
saveMax: number //银行存钱最大数额
|
||||
takeOutMax: number //银行取钱最大次数
|
||||
shopActivityId: number //商店对应的商店id
|
||||
|
||||
record: any[] = []; //历史操作
|
||||
stopCount: number //停留次数
|
||||
|
||||
constructor(data: any) {
|
||||
this.position = data.position;
|
||||
this.name = data.name;
|
||||
this.level = data.level;
|
||||
this.rewards = data.rewards;
|
||||
this.landType = data.landType;
|
||||
this.saveMax = data.saveMax;
|
||||
this.takeOutMax = data.takeOutMax;
|
||||
this.shopActivityId = data.shopActivityId;
|
||||
this.record = [];
|
||||
this.stopCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 活动数据
|
||||
export class MonopolyData extends ActivityBase {
|
||||
curPosition: number; // 当前位置
|
||||
roundIndex: number; // 回合数
|
||||
list: Array<LandItem> = [];
|
||||
|
||||
public findMonopolyItem(position: number) {
|
||||
let index = this.list.findIndex(obj => { return obj && obj.position == position })
|
||||
return (index != -1) ? this.list[index] : null;
|
||||
}
|
||||
|
||||
//解析玩家领取记录
|
||||
public setPlayerRecords(data: ActivityMonopolyModelType, landDataArray: ActivityMonopolyLandModelType[]) {
|
||||
this.curPosition = (data && data.curPosition) ? data.curPosition : 0;
|
||||
this.roundIndex = (data && data.roundIndex) ? data.roundIndex : 0;
|
||||
|
||||
for (let landData of landDataArray) {
|
||||
let index = this.list.findIndex(item => { return item.position == landData.position })
|
||||
if (index != -1) {
|
||||
this.list[index].level = landData.level;
|
||||
this.list[index].record = landData.record ? landData.record : [];
|
||||
this.list[index].stopCount = landData.stopCount ? landData.stopCount : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let arr = JSON.parse(data);
|
||||
for (let obj of arr) {
|
||||
this.list.push(new LandItem(obj))
|
||||
}
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
super(activityData)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ export class RefreshShopPage {
|
||||
|
||||
// 商店数据
|
||||
export class RefreshShopData extends ActivityBase {
|
||||
shopType: number = 0;//商店类型,用于客户端显示使用
|
||||
name: string = '';//活动名称
|
||||
interval: number = 0;//周期间隔(秒)
|
||||
list: Array<RefreshShopPage> = [];//商品列表
|
||||
@@ -96,6 +97,7 @@ export class RefreshShopData extends ActivityBase {
|
||||
public initData(data: string) {
|
||||
this.nextRefreshTime = this.endTime;
|
||||
let dataObj = JSON.parse(data);
|
||||
this.shopType = dataObj.shopType;
|
||||
this.name = dataObj.name;
|
||||
this.interval = dataObj.interval;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user