feat(squadrons): add local squadrons, activity, and vehicle research
This commit is contained in:
1 parent
415f78e761
commit
f3fb6f6b53
16 files changed
+2307
-23
No files matched your search
@@ -13,10 +13,12 @@
|
||||
*/
|
||||
import { parseArgs } from 'node:util';
|
||||
import { AccountStore } from './accounts/account-store.ts';
|
||||
import { ClanStore } from './clans/clan-store.ts';
|
||||
import { DatasetCache } from './game-data/datasets/dataset-cache.ts';
|
||||
import { GameFiles } from './game-data/game-files.ts';
|
||||
import type { ItemDefinition } from './game-data/datasets/item-catalogue.ts';
|
||||
import { grantItem } from './items/item-grants.ts';
|
||||
import { availableSquadronRp, clanMembershipOf, setAvailableSquadronRp } from './profile/profile-clan.ts';
|
||||
import { balanceOf, setGjn, setGoldenEagles, setSilverLions } from './profile/profile-currency.ts';
|
||||
import { remainingPremiumDays } from './profile/profile-entitlements.ts';
|
||||
import { externalInventoryItems, grantExternalItem } from './profile/profile-external-inventory.ts';
|
||||
@@ -26,7 +28,8 @@ import { serverTimeNow } from './profile/server-time.ts';
|
||||
import { setUpProfiles } from './profiles-setup.ts';
|
||||
|
||||
const USAGE = 'usage: save-cli.ts --game <game folder> --data <data folder> --player <login or user id> '
|
||||
+ '[--silver <n>] [--gold <n>] [--gjn <n>] [--free-rp <n>] [--give-item <item>[:<pieces>]]... [--give-coupon <itemdefId>[:<qty>]]...';
|
||||
+ '[--silver <n>] [--gold <n>] [--gjn <n>] [--free-rp <n>] [--squadron-rp <n>] '
|
||||
+ '[--give-item <item>[:<pieces>]]... [--give-coupon <itemdefId>[:<qty>]]...';
|
||||
|
||||
function main(): number {
|
||||
const { values } = parseArgs({
|
||||
@@ -38,6 +41,7 @@ function main(): number {
|
||||
gold: { type: 'string' },
|
||||
gjn: { type: 'string' },
|
||||
'free-rp': { type: 'string' },
|
||||
'squadron-rp': { type: 'string' },
|
||||
'give-item': { type: 'string', multiple: true },
|
||||
'give-coupon': { type: 'string', multiple: true },
|
||||
},
|
||||
@@ -50,8 +54,9 @@ function main(): number {
|
||||
const gold = optionalAmount(values.gold);
|
||||
const gjn = optionalAmount(values.gjn);
|
||||
const freeRp = optionalAmount(values['free-rp']);
|
||||
if (silver === null || gold === null || gjn === null || freeRp === null) {
|
||||
console.error('--silver, --gold, --gjn and --free-rp take a whole number of 0 or more');
|
||||
const squadronRp = optionalAmount(values['squadron-rp']);
|
||||
if (silver === null || gold === null || gjn === null || freeRp === null || squadronRp === null) {
|
||||
console.error('--silver, --gold, --gjn, --free-rp and --squadron-rp take a whole number of 0 or more');
|
||||
return 2;
|
||||
}
|
||||
const accounts = new AccountStore(values.data);
|
||||
@@ -60,6 +65,7 @@ function main(): number {
|
||||
console.error(`no player "${values.player}" in ${values.data}`);
|
||||
return 1;
|
||||
}
|
||||
const clans = new ClanStore(values.data);
|
||||
const gameFiles = new GameFiles(values.game);
|
||||
const datasets = new DatasetCache(values.data, gameFiles, () => {});
|
||||
const { profiles, research } = setUpProfiles(values.data, gameFiles, datasets);
|
||||
@@ -85,22 +91,29 @@ function main(): number {
|
||||
}
|
||||
coupons.push({ itemdefId, quantity });
|
||||
}
|
||||
const changes = silver !== undefined || gold !== undefined || gjn !== undefined || freeRp !== undefined || gifts.length > 0 || coupons.length > 0;
|
||||
const changes = silver !== undefined || gold !== undefined || gjn !== undefined || freeRp !== undefined || squadronRp !== undefined || gifts.length > 0 || coupons.length > 0;
|
||||
const now = serverTimeNow();
|
||||
const clanEarned = clans.earnedSquadronExpOf(account.userId);
|
||||
const profile = !changes
|
||||
? profiles.profileOf(account.userId)
|
||||
: profiles.update(account.userId, (saved) => {
|
||||
clans.syncProfile(saved, account);
|
||||
if (silver !== undefined) setSilverLions(saved, silver);
|
||||
if (gold !== undefined) setGoldenEagles(saved, gold);
|
||||
if (gjn !== undefined) setGjn(saved, gjn);
|
||||
if (freeRp !== undefined) setFreeResearchPoints(saved, freeRp);
|
||||
if (squadronRp !== undefined) setAvailableSquadronRp(saved, squadronRp, clanEarned);
|
||||
for (const gift of gifts) grantItem(saved, gift.item, gift.pieces, now);
|
||||
for (const coupon of coupons) grantExternalItem(saved, coupon.itemdefId, coupon.quantity);
|
||||
});
|
||||
clans.syncProfile(profile, account);
|
||||
const balance = balanceOf(profile);
|
||||
const premiumDays = remainingPremiumDays(profile, now);
|
||||
const premiumNote = premiumDays > 0 ? `, premium: ${premiumDays}d` : '';
|
||||
console.log(`${account.login} (${account.userId}): ${balance.silverLions} silver lions, ${balance.goldenEagles} golden eagles, ${balance.gjn} GJN, ${freeResearchPoints(profile)} free research points${premiumNote}`);
|
||||
const sqRp = availableSquadronRp(profile, clanEarned);
|
||||
const clanInfo = clanMembershipOf(profile);
|
||||
const clanNote = clanInfo.clanId !== '-1' ? `, clan: ${clanInfo.clanTag} ${clanInfo.clanName}` : '';
|
||||
console.log(`${account.login} (${account.userId}): ${balance.silverLions} silver lions, ${balance.goldenEagles} golden eagles, ${balance.gjn} GJN, ${freeResearchPoints(profile)} free research points, ${sqRp} squadron RP${premiumNote}${clanNote}`);
|
||||
const items = ownedItems(profile);
|
||||
if (items.length) console.log(`items: ${items.map((item) => `${item.id} x${item.count}`).join(', ')}`);
|
||||
const extItems = externalInventoryItems(profile);
|
||||
|
||||
Reference in new issue
Block a user