feat(battle): apply research efficiency rules to battle RP
Vehicle research points now follow rank.blk: the predecessor bonus (expBonusPercentForChildForMode), the rank difference penalty (expPenaltyPercentForHigherRank / LowerRank) and the Vehicle Research Bonus (ExpNewNationBonus, five battles per nation and type per UTC day). Modifications keep the research points before these terms. The settlement records each vehicle's breakdown in the session log's container.researchPoints, which the stock debriefing explains in its research rows. The debriefing patch now selects the battle's logs by room id, since a LocalMP host is in no matching room and the stock current-room check cannot match them.
This commit is contained in:
1 parent
9f28a84cd3
commit
de469b0d6b
18 files changed
+598
-170
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Vehicle Research Bonus battles used today, per country and vehicle type (research/
|
||||
* research-efficiency.ts). Kept in a block of the local service's own; the client's profile
|
||||
* parser ignores it:
|
||||
*
|
||||
* wtoResearchBonus{ day:i=<days since 1970-01-01 UTC> country_usa{ Tank:i=2 } }
|
||||
*
|
||||
* The count resets when the UTC day changes (the bonus battles reset at 00:00 GMT).
|
||||
*/
|
||||
import { ensureBlock, findBlock, findParam, setParam, type BlkBlock } from '@wto/blk';
|
||||
|
||||
const BLOCK = 'wtoResearchBonus';
|
||||
const DAY = 'day';
|
||||
const SECONDS_PER_DAY = 86_400;
|
||||
|
||||
export function researchBonusBattlesUsed(profile: BlkBlock, country: string, vehicleType: string, nowUnixSec: number): number {
|
||||
const block = findBlock(profile, BLOCK);
|
||||
if (!block || intParam(block, DAY) !== dayOf(nowUnixSec)) return 0;
|
||||
const countryBlock = findBlock(block, country);
|
||||
return countryBlock ? intParam(countryBlock, vehicleType) : 0;
|
||||
}
|
||||
|
||||
export function useResearchBonusBattle(profile: BlkBlock, country: string, vehicleType: string, nowUnixSec: number): void {
|
||||
const used = researchBonusBattlesUsed(profile, country, vehicleType, nowUnixSec);
|
||||
const block = ensureBlock(profile, BLOCK);
|
||||
const day = dayOf(nowUnixSec);
|
||||
if (intParam(block, DAY) !== day) {
|
||||
block.blocks.length = 0;
|
||||
setParam(block, DAY, { type: 'int', value: day });
|
||||
}
|
||||
setParam(ensureBlock(block, country), vehicleType, { type: 'int', value: used + 1 });
|
||||
}
|
||||
|
||||
function dayOf(unixSec: number): number {
|
||||
return Math.floor(unixSec / SECONDS_PER_DAY);
|
||||
}
|
||||
|
||||
function intParam(block: BlkBlock, name: string): number {
|
||||
const value = findParam(block, name)?.value;
|
||||
return value?.type === 'int' ? value.value : 0;
|
||||
}
|
||||
Reference in new issue
Block a user