Read squadron action parameters from the request headers and persist squadron state on profile refresh. Use floating-point trophy weights to match the client probability display and assign unique log IDs when opening multiple chests. Tighten shop, marketplace, squadron, and cloud settings validation. Move PBBD and inventory encoding into the protocol modules and share CSV reading. Update the research and acceptance instructions. Type checking and all eight executable patch checks passed. In-game acceptance is pending.
232 lines
9.4 KiB
TypeScript
232 lines
9.4 KiB
TypeScript
/**
|
|
* Default offline squadron directory seeded on first creation of `<data>/clans.json`
|
|
* (implementation notes section I; implementation notes).
|
|
*/
|
|
import {
|
|
BATTALION_INITIAL_MEMBER_LIMIT,
|
|
ClanRole,
|
|
MAX_ACTIVITY_PER_PERIOD,
|
|
MAX_CLAN_ACTIVITY,
|
|
NORMAL_CLAN_MEMBER_LIMIT,
|
|
REWARD_PERIOD_DAYS,
|
|
type ClanActivityPeriodEntry,
|
|
type ClanMemberRecord,
|
|
type ClanRecord,
|
|
} from './clan-types.ts';
|
|
|
|
interface NpcSpec {
|
|
readonly uid: string;
|
|
readonly nick: string;
|
|
readonly role: number;
|
|
readonly title: string;
|
|
readonly icon: string;
|
|
readonly unit: string;
|
|
readonly activity: number;
|
|
}
|
|
|
|
interface SeedSpec {
|
|
readonly id: string;
|
|
readonly tag: string;
|
|
readonly name: string;
|
|
readonly type: 'normal' | 'battalion';
|
|
readonly slogan: string;
|
|
readonly desc: string;
|
|
readonly announcement: string;
|
|
readonly region: string;
|
|
readonly autoaccept: boolean;
|
|
readonly mlimit: number;
|
|
readonly dayOffset: number;
|
|
readonly eloArc: number;
|
|
readonly eloHist: number;
|
|
readonly eloSim: number;
|
|
readonly npcs: readonly NpcSpec[];
|
|
}
|
|
|
|
const SEED_SPECS: readonly SeedSpec[] = [
|
|
{
|
|
id: '500001',
|
|
tag: '[WTOF]',
|
|
name: 'War Thunder Offline Guard',
|
|
type: 'normal',
|
|
slogan: '离线天空与钢铁防线 · 自由研发全部联队载具',
|
|
desc: 'War Thunder Offline 官方预置主力联队。开启自动审批,加入即可获得完整联队活跃度与联队研发点支持。',
|
|
announcement: '欢迎加入 [WTOF]!可在联队页面右上角点击「联队载具」或「活跃度」查看研发进度。',
|
|
region: 'CN / Global',
|
|
autoaccept: true,
|
|
mlimit: NORMAL_CLAN_MEMBER_LIMIT,
|
|
dayOffset: 0,
|
|
eloArc: 1840,
|
|
eloHist: 2150,
|
|
eloSim: 1620,
|
|
npcs: [
|
|
{ uid: '900001001', nick: 'Lin_Wei', role: ClanRole.LEADER, title: 'title_marshall', icon: 'cardicon_28', unit: 'cn_ztz_99a', activity: MAX_ACTIVITY_PER_PERIOD },
|
|
{ uid: '900001002', nick: 'Elena_Valkyrie', role: ClanRole.DEPUTY, title: 'title_ace', icon: 'cardicon_fem_01', unit: 'su_27sm', activity: MAX_ACTIVITY_PER_PERIOD },
|
|
{ uid: '900001003', nick: 'iron_tiger_88', role: ClanRole.OFFICER, title: 'title_tank_destroyer', icon: 'cardicon_14', unit: 'germ_leopard_2a7v', activity: MAX_ACTIVITY_PER_PERIOD },
|
|
{ uid: '900001004', nick: 'Tomcat_Actual', role: ClanRole.OFFICER, title: 'title_jet_powered', icon: 'cardicon_07', unit: 'f_14b', activity: 345 },
|
|
{ uid: '900001005', nick: 'Kuroshio_DD', role: ClanRole.SERGEANT, title: 'title_sea_wolf', icon: 'cardicon_19', unit: 'jp_destroyer_shimakaze', activity: 330 },
|
|
{ uid: '900001006', nick: 'Northern_Fox', role: ClanRole.REGULAR, title: 'title_sniper', icon: 'cardicon_11', unit: 'sw_strv_122b_plus', activity: 310 },
|
|
],
|
|
},
|
|
{
|
|
id: '500002',
|
|
tag: '=PLAF=',
|
|
name: 'Red Falcon Aviation Wing',
|
|
type: 'normal',
|
|
slogan: '鹰击长空 · 现代喷气空战与陆空协同联队',
|
|
desc: '专注于高阶喷气机与现代主战坦克联合作战的离线联队,支持自动入队与高活跃度加成。',
|
|
announcement: '本期联队研发推荐:F-16A OCU、苏-33、豹 2PL、M1A1 AIM。',
|
|
region: 'Asia',
|
|
autoaccept: true,
|
|
mlimit: NORMAL_CLAN_MEMBER_LIMIT,
|
|
dayOffset: 12,
|
|
eloArc: 1690,
|
|
eloHist: 2040,
|
|
eloSim: 1780,
|
|
npcs: [
|
|
{ uid: '900002001', nick: 'SkyDragon_J20', role: ClanRole.LEADER, title: 'title_ace', icon: 'cardicon_25', unit: 'j_11a', activity: MAX_ACTIVITY_PER_PERIOD },
|
|
{ uid: '900002002', nick: 'Thunderbolt_CN', role: ClanRole.DEPUTY, title: 'title_pilot', icon: 'cardicon_09', unit: 'jh_7a', activity: MAX_ACTIVITY_PER_PERIOD },
|
|
{ uid: '900002003', nick: 'SteelWall_99', role: ClanRole.OFFICER, title: 'title_unstoppable', icon: 'cardicon_16', unit: 'cn_vt_4a1', activity: 350 },
|
|
{ uid: '900002004', nick: 'NightHawk_04', role: ClanRole.REGULAR, title: 'title_eagle', icon: 'cardicon_05', unit: 'f_15j_kai', activity: 300 },
|
|
],
|
|
},
|
|
{
|
|
id: '500003',
|
|
tag: '-1STG-',
|
|
name: '1st Armored Guards Division',
|
|
type: 'normal',
|
|
slogan: 'Steel & Fire — Heavy Armor Historical Squadron',
|
|
desc: 'Classic and modern armored warfare squadron. Open auto-accept recruitment for all tank commanders.',
|
|
announcement: 'Squadron vehicles ready for research at full 20,000 RP per period.',
|
|
region: 'EU / Global',
|
|
autoaccept: true,
|
|
mlimit: NORMAL_CLAN_MEMBER_LIMIT,
|
|
dayOffset: 24,
|
|
eloArc: 1920,
|
|
eloHist: 1980,
|
|
eloSim: 1510,
|
|
npcs: [
|
|
{ uid: '900003001', nick: 'Kommissar_KVs', role: ClanRole.LEADER, title: 'title_hero', icon: 'cardicon_22', unit: 'ussr_t_90m', activity: MAX_ACTIVITY_PER_PERIOD },
|
|
{ uid: '900003002', nick: 'PanzerMeyer_IV', role: ClanRole.OFFICER, title: 'title_tankman', icon: 'cardicon_12', unit: 'germ_pzkpfw_VI_ausf_h1_tiger', activity: 340 },
|
|
{ uid: '900003003', nick: 'DesertRat_UK', role: ClanRole.REGULAR, title: 'title_conqueror', icon: 'cardicon_18', unit: 'uk_challenger_2_black_night', activity: 290 },
|
|
],
|
|
},
|
|
{
|
|
id: '500004',
|
|
tag: '^82AB^',
|
|
name: '82nd Combined Task Force',
|
|
type: 'normal',
|
|
slogan: 'All The Way — Air, Ground & Naval Task Force',
|
|
desc: '需要审批模式的示例联队(用于测试发送与撤回入队申请流程)。若想立即加入联队,请选择 [WTOF]、=PLAF= 或 -1STG-。',
|
|
announcement: 'Manual application review enabled for testing request/cancel workflow.',
|
|
region: 'NA',
|
|
autoaccept: false,
|
|
mlimit: NORMAL_CLAN_MEMBER_LIMIT,
|
|
dayOffset: 35,
|
|
eloArc: 1550,
|
|
eloHist: 1760,
|
|
eloSim: 1490,
|
|
npcs: [
|
|
{ uid: '900004001', nick: 'Major_Winters', role: ClanRole.LEADER, title: 'title_brother_in_arms', icon: 'cardicon_03', unit: 'us_m1a2_sep2_abrams', activity: MAX_ACTIVITY_PER_PERIOD },
|
|
{ uid: '900004002', nick: 'Mustang_Lead', role: ClanRole.OFFICER, title: 'title_ace', icon: 'cardicon_08', unit: 'p-51d-30_usaaf_korea', activity: 315 },
|
|
],
|
|
},
|
|
{
|
|
id: '500005',
|
|
tag: '**RCON**',
|
|
name: 'Reconnaissance Battalion Alpha',
|
|
type: 'battalion',
|
|
slogan: '轻量级战术分队 · 侦察与快速反应',
|
|
desc: '战斗群(Battalion)类型预置联队,开启自动加入,支持体验战斗群架构与联队扩编。',
|
|
announcement: '轻装侦察分队常驻开放。',
|
|
region: 'Global',
|
|
autoaccept: true,
|
|
mlimit: BATTALION_INITIAL_MEMBER_LIMIT,
|
|
dayOffset: 48,
|
|
eloArc: 1410,
|
|
eloHist: 1610,
|
|
eloSim: 1320,
|
|
npcs: [
|
|
{ uid: '900005001', nick: 'Ghost_Scout', role: ClanRole.LEADER, title: 'title_scout', icon: 'cardicon_15', unit: 'us_hstvl', activity: MAX_ACTIVITY_PER_PERIOD },
|
|
{ uid: '900005002', nick: 'Lynx_Spotter', role: ClanRole.REGULAR, title: 'title_sniper', icon: 'cardicon_20', unit: 'it_centauro_rgo_120', activity: 280 },
|
|
],
|
|
},
|
|
];
|
|
|
|
export function createDefaultClans(nowSec = Math.floor(Date.now() / 1000)): ClanRecord[] {
|
|
const todayDay = Math.floor(nowSec / 86400);
|
|
const createdBase = nowSec - 180 * 86400;
|
|
return SEED_SPECS.map((spec) => buildSeededClan(spec, createdBase + spec.dayOffset * 86400, todayDay));
|
|
}
|
|
|
|
export function buildDefaultPeriods(todayDay: number, periodActivity = MAX_ACTIVITY_PER_PERIOD): ClanActivityPeriodEntry[] {
|
|
const expPerPeriod = Math.round((periodActivity / MAX_ACTIVITY_PER_PERIOD) * MAX_CLAN_ACTIVITY);
|
|
return [0, 1, 2].map((idx) => ({
|
|
day: todayDay - idx * REWARD_PERIOD_DAYS,
|
|
activity: periodActivity,
|
|
exp: expPerPeriod,
|
|
}));
|
|
}
|
|
|
|
function buildSeededClan(spec: SeedSpec, cdateSec: number, todayDay: number): ClanRecord {
|
|
const members = spec.npcs.map((npc, idx) => buildSeededMember(spec, npc, idx, cdateSec, todayDay));
|
|
const leader = spec.npcs[0]!;
|
|
return {
|
|
id: spec.id,
|
|
name: spec.name,
|
|
tag: spec.tag,
|
|
lastPaidTag: spec.tag,
|
|
type: spec.type,
|
|
slogan: spec.slogan,
|
|
desc: spec.desc,
|
|
announcement: spec.announcement,
|
|
region: spec.region,
|
|
status: 'open',
|
|
autoaccept: spec.autoaccept,
|
|
mlimit: spec.mlimit,
|
|
mspent: 0,
|
|
cdateSec,
|
|
changedByUid: leader.uid,
|
|
changedByNick: leader.nick,
|
|
changedTimeSec: cdateSec,
|
|
regionLastUpdatedSec: 0,
|
|
stats: {
|
|
dr_era5_arc: spec.eloArc, dr_era5_hist: spec.eloHist, dr_era5_sim: spec.eloSim,
|
|
akills_arc: 4280, akills_hist: 6150, akills_sim: 1420,
|
|
gkills_arc: 7890, gkills_hist: 11240, gkills_sim: 2680,
|
|
deaths_arc: 5120, deaths_hist: 6890, deaths_sim: 1950,
|
|
ftime_arc: 18400, ftime_hist: 32600, ftime_sim: 8900,
|
|
},
|
|
members,
|
|
candidates: [],
|
|
blacklist: [],
|
|
logs: [{
|
|
id: 1, ev: 'create', timeSec: cdateSec, uId: leader.uid, uN: leader.nick,
|
|
name: spec.name, type: spec.type, tag: spec.tag, desc: spec.desc,
|
|
slogan: spec.slogan, region: spec.region, announcement: spec.announcement,
|
|
}],
|
|
bestRewards: [],
|
|
};
|
|
}
|
|
|
|
function buildSeededMember(spec: SeedSpec, npc: NpcSpec, idx: number, cdateSec: number, todayDay: number): ClanMemberRecord {
|
|
const periods = buildDefaultPeriods(todayDay, npc.activity);
|
|
return {
|
|
uid: npc.uid,
|
|
nick: npc.nick,
|
|
role: npc.role,
|
|
joinDateSec: cdateSec + idx * 3600,
|
|
isNpc: true,
|
|
npcTitle: npc.title,
|
|
npcPilotIcon: npc.icon,
|
|
npcFrame: '',
|
|
npcShowcaseUnit: npc.unit,
|
|
curActivity: npc.activity,
|
|
totalActivity: periods.reduce((sum, p) => sum + p.activity, 0),
|
|
earnedSquadronExp: periods.reduce((sum, p) => sum + p.exp, 0),
|
|
ratingArc: Math.max(800, spec.eloArc - idx * 45),
|
|
ratingHist: Math.max(850, spec.eloHist - idx * 50),
|
|
ratingSim: Math.max(700, spec.eloSim - idx * 40),
|
|
periods,
|
|
};
|
|
}
|