Merge branch 'main' into compare/scenario2601-200-parity-20260815
This commit is contained in:
commit
fad4602e2e
99 files changed
+1052
-1897
No files matched your search
@@ -8,7 +8,7 @@ const FEATURE_ALIASES: Record<SanctionFeature, ReadonlySet<string>> = {
|
||||
messages: new Set(['*', 'message', 'messages']),
|
||||
};
|
||||
|
||||
export const isFutureSanctionDate = (value: string | undefined, now = new Date()): boolean => {
|
||||
const isFutureSanctionDate = (value: string | undefined, now = new Date()): boolean => {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -108,10 +108,7 @@ export const resolveRealtimeReadModelInvalidation = (
|
||||
const ownGeneralChanged = contains(changes.generalIds, identity.generalId);
|
||||
const ownCityChanged = contains(changes.cityIds, identity.cityId);
|
||||
const ownNationChanged = contains(changes.nationIds, identity.nationId);
|
||||
const ownFrontStatusNationChanged = contains(
|
||||
changes.frontStatusNationIds ?? changes.nationIds,
|
||||
identity.nationId
|
||||
);
|
||||
const ownFrontStatusNationChanged = contains(changes.frontStatusNationIds ?? changes.nationIds, identity.nationId);
|
||||
const ownGeneralMapChanged = contains(changes.mapGeneralIds ?? changes.generalIds, identity.generalId);
|
||||
const frontStatusGeneralChanged =
|
||||
changes.frontStatusGeneralIds !== undefined
|
||||
@@ -122,8 +119,7 @@ export const resolveRealtimeReadModelInvalidation = (
|
||||
const lobbyChanged = changes.lobbyChanged ?? changes.contactsChanged;
|
||||
const entityContextChanged = ownGeneralChanged || ownCityChanged || ownNationChanged;
|
||||
const mapEntitiesChanged =
|
||||
(changes.mapCityIds ?? changes.cityIds).length > 0 ||
|
||||
(changes.mapNationIds ?? changes.nationIds).length > 0;
|
||||
(changes.mapCityIds ?? changes.cityIds).length > 0 || (changes.mapNationIds ?? changes.nationIds).length > 0;
|
||||
const commandEntitiesChanged = changes.cityIds.length > 0 || changes.nationIds.length > 0;
|
||||
|
||||
return {
|
||||
@@ -167,39 +163,6 @@ export const createEmptyRealtimeReadModelChanges = (): RealtimeReadModelChanges
|
||||
lobbyChanged: false,
|
||||
});
|
||||
|
||||
const mergeIds = (left: readonly number[], right: readonly number[]): number[] =>
|
||||
[...new Set([...left, ...right])].sort((a, b) => a - b);
|
||||
|
||||
export const mergeRealtimeReadModelChanges = (
|
||||
left: RealtimeReadModelChanges,
|
||||
right: RealtimeReadModelChanges
|
||||
): RealtimeReadModelChanges => ({
|
||||
generalIds: mergeIds(left.generalIds, right.generalIds),
|
||||
cityIds: mergeIds(left.cityIds, right.cityIds),
|
||||
nationIds: mergeIds(left.nationIds, right.nationIds),
|
||||
mapGeneralIds: mergeIds(left.mapGeneralIds ?? left.generalIds, right.mapGeneralIds ?? right.generalIds),
|
||||
mapCityIds: mergeIds(left.mapCityIds ?? left.cityIds, right.mapCityIds ?? right.cityIds),
|
||||
mapNationIds: mergeIds(left.mapNationIds ?? left.nationIds, right.mapNationIds ?? right.nationIds),
|
||||
frontStatusGeneralIds: mergeIds(
|
||||
left.frontStatusGeneralIds ?? (left.contactsChanged ? left.generalIds : []),
|
||||
right.frontStatusGeneralIds ?? (right.contactsChanged ? right.generalIds : [])
|
||||
),
|
||||
frontStatusNationIds: mergeIds(
|
||||
left.frontStatusNationIds ?? left.nationIds,
|
||||
right.frontStatusNationIds ?? right.nationIds
|
||||
),
|
||||
frontStatusActorIds: mergeIds(left.frontStatusActorIds ?? [], right.frontStatusActorIds ?? []),
|
||||
lobbyGeneralIds: mergeIds(left.lobbyGeneralIds ?? left.generalIds, right.lobbyGeneralIds ?? right.generalIds),
|
||||
reservedGeneralIds: mergeIds(left.reservedGeneralIds, right.reservedGeneralIds),
|
||||
recordGeneralIds: mergeIds(left.recordGeneralIds, right.recordGeneralIds),
|
||||
worldChanged: left.worldChanged || right.worldChanged,
|
||||
globalRecordsChanged: left.globalRecordsChanged || right.globalRecordsChanged,
|
||||
worldHistoryChanged: left.worldHistoryChanged || right.worldHistoryChanged,
|
||||
contactsChanged: left.contactsChanged || right.contactsChanged,
|
||||
frontStatusChanged: Boolean(left.frontStatusChanged) || Boolean(right.frontStatusChanged),
|
||||
lobbyChanged: (left.lobbyChanged ?? left.contactsChanged) || (right.lobbyChanged ?? right.contactsChanged),
|
||||
});
|
||||
|
||||
export const hasRealtimeReadModelChanges = (changes: RealtimeReadModelChanges): boolean =>
|
||||
changes.generalIds.length > 0 ||
|
||||
changes.cityIds.length > 0 ||
|
||||
@@ -251,7 +214,4 @@ export interface MessagesInvalidatedEvent {
|
||||
/** Events safe to expose to an authenticated browser over SSE. */
|
||||
export type PublicRealtimeEvent = ReadModelInvalidatedEvent | MessagesInvalidatedEvent;
|
||||
|
||||
export type RealtimeEvent =
|
||||
| TurnCompletedEvent
|
||||
| ReadModelChangedEvent
|
||||
| MessageCreatedEvent;
|
||||
export type RealtimeEvent = TurnCompletedEvent | ReadModelChangedEvent | MessageCreatedEvent;
|
||||
@@ -32,6 +32,3 @@ const buildTournamentSeedKey = (baseSeed: string, context: TournamentRngContext)
|
||||
|
||||
export const createTournamentRng = (baseSeed: string, context: TournamentRngContext): RandUtil =>
|
||||
new RandUtil(LiteHashDRBG.build(buildTournamentSeedKey(baseSeed, context)));
|
||||
|
||||
export const createTournamentSeedKey = (baseSeed: string, context: TournamentRngContext): string =>
|
||||
buildTournamentSeedKey(baseSeed, context);
|
||||
@@ -26,7 +26,7 @@ function normalizeUint8Array(bytes: Uint8Array): Uint8Array<ArrayBuffer> {
|
||||
return out as Uint8Array<ArrayBuffer>;
|
||||
}
|
||||
|
||||
export function sha512Bytes(data: BytesLike): Uint8Array<ArrayBuffer> {
|
||||
function sha512Bytes(data: BytesLike): Uint8Array<ArrayBuffer> {
|
||||
const input = convertBytesLikeToUint8Array(data);
|
||||
if (nodeCreateHash) {
|
||||
const digest = nodeCreateHash('sha512').update(input).digest();
|
||||
|
||||
Reference in new issue
Block a user