feat(gvg): 农庄

This commit is contained in:
luying
2023-01-12 20:50:36 +08:00
parent 54837f24b6
commit b2b9404684
30 changed files with 1192 additions and 104 deletions

View File

@@ -4,6 +4,8 @@ import { GVGLeaguePrepareType } from "../../db/GVGLeaguePrepare";
import { Distribute, GVGUserDataType } from "../../db/GVGUserData";
import { GuildType } from "../../db/Guild";
import { LEAGUE_JOB } from "../../consts";
import { GVGLeagueFarmType } from "../../db/GVGLeagueFarm";
import { nowSeconds } from "../../pubUtils/timeUtil";
class LeagueLeaderInfo {
name: string; // 盟主名
@@ -124,6 +126,10 @@ export class GVGMainData {
setLeagueCe(leagueCe: number) {
this.leagueCe = leagueCe;
}
setCities(cities: number[]) {
this.cities = cities;
}
}
export class LeagueListInfo {
@@ -280,4 +286,61 @@ export class LeagueDistributeInfo {
setMembers(members: LeagueMemberDistributeInfo[]) {
this.members = members;
}
}
export class LeagueFarmListInfo {
farmId: number;
count: number; // 已种植数量
canHarvest: boolean;
constructor(farmId: number, count: number, canHarvest: boolean) {
this.farmId = farmId;
this.count = count;
this.canHarvest = canHarvest;
}
}
export class LeagueField {
fieldId: number; // 田的编号
seedType: number; // 已种植了的种子类型 0-未种 1-小麦 2-玉米 3-水稻
addType: number; // 特殊加成类型 0-普通田 1-小麦加成 2-玉米 3-水稻
harvestTime: number; // 收获时间, 10位时间戳
unlockTime: number; // 锁定时间,会按照内政令的数量给玩家预锁定一批填,超过时间限制就不锁给他了也会分给其他人了
constructor(leagueFarm: GVGLeagueFarmType) {
if(!leagueFarm) return;
this.fieldId = leagueFarm.fieldId;
this.seedType = leagueFarm.seedType;
this.addType = leagueFarm.addType;
this.harvestTime = leagueFarm.harvestTime;
this.unlockTime = leagueFarm.unlockTime;
}
}
export class LeagueFarmMember {
roleId: string; // 种田玩家
roleName: string;
guildName: string;
serverName: string;
count: number; // 种植地块
output: number; // 预计产量
canHelp: boolean; // 是否可以帮收
harvestTime: number; // 收成时间10位时间戳
constructor(role: RoleType, serverNames: any) {
this.roleId = role.roleId;
this.roleName = role.roleName;
this.guildName = role.guildName;
this.serverName = serverNames[role.serverId];
}
setByFields(fields: GVGLeagueFarmType[]) {
this.count = fields.length;
this.harvestTime = Math.min(...fields.map(cur => cur.harvestTime))||0;
this.canHelp = !!fields.find(cur => cur.harvestTime < nowSeconds());
}
setOutput(output: number) {
this.output = output;
}
}