-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
241 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
import { Location } from '../types.js' | ||
import { NestedOmit } from './util.js' | ||
|
||
//#region Parsed | ||
export type OAPITown = NestedOmit<RawTown, | ||
"strings.town" | | ||
"strings.founder" | | ||
"timestamps" | | ||
"perms.rnaoPerms" | | ||
"perms.flagPerms" | ||
> & { | ||
name: string | ||
nation: string | ||
founder: string | ||
created: number | ||
joinedNation: number | ||
perms: { | ||
build: RawTownPerms | ||
destroy: RawTownPerms | ||
switch: RawTownPerms | ||
itemUse: RawTownPerms | ||
flags: RawFlagPerms | ||
} | ||
} | ||
|
||
export type OAPINation = NestedOmit<RawNation, | ||
"strings.nation" | | ||
"timestamps" | ||
> & { | ||
name: string | ||
created: number | ||
} | ||
|
||
export type OAPIResident = NestedOmit<RawResident, | ||
"strings" | | ||
"affiliation" | | ||
"ranks" | | ||
"perms" | | ||
"stats" | ||
> & { | ||
name: string | ||
uuid: string | ||
title?: string | ||
surname?: string | ||
town?: string | ||
nation?: string | ||
balance: number | ||
timestamps: Timestamps | ||
townRanks?: string[] | ||
nationRanks?: string[] | ||
perms?: { | ||
build: RawResidentPerms | ||
destroy: RawResidentPerms | ||
switch: RawResidentPerms | ||
itemUse: RawResidentPerms | ||
flags: RawFlagPerms | ||
} | ||
} | ||
//#endregion | ||
|
||
//#region Raw, unparsed types | ||
export type RawEntity = { | ||
uuid: string | ||
status: RawEntityStatus | ||
stats: RawEntityStats | ||
ranks?: { [key: string]: string[] } | ||
} | ||
|
||
export type RawEntityStatus = Partial<{ | ||
isPublic: boolean | ||
isOpen: boolean | ||
isNeutral: boolean | ||
isCapital: boolean | ||
isOverClaimed: boolean | ||
isRuined: boolean | ||
isOnline: boolean | ||
isNPC: boolean | ||
}> | ||
|
||
export type RawEntityStats = { | ||
maxTownBlocks?: number | ||
numTownBlocks?: number | ||
numResidents?: number | ||
numTowns?: number | ||
balance: number | ||
} | ||
|
||
export type RawResidentPerms = { | ||
friend: boolean | ||
town: boolean | ||
ally: boolean | ||
outsider: boolean | ||
} | ||
|
||
export type RawTownPerms = { | ||
resident: boolean | ||
nation: boolean | ||
ally: boolean | ||
outsider: boolean | ||
} | ||
|
||
export type RawFlagPerms = { | ||
pvp: boolean | ||
explosion: boolean | ||
fire: boolean | ||
mobs: boolean | ||
} | ||
|
||
export type RawEntityPerms<PermsType> = { | ||
flagPerms: RawFlagPerms | ||
rnaoPerms: { | ||
buildPerms: PermsType | ||
destroyPerms: PermsType | ||
switchPerms: PermsType | ||
itemUsePerms: PermsType | ||
} | ||
} | ||
|
||
export type TownSpawn = Location & { | ||
world: string | ||
pitch?: number | ||
yaw?: number | ||
} | ||
|
||
export type TownCoordinates = { | ||
spawn: TownSpawn | ||
home: number[] | ||
townBlocks: { | ||
x: number[] | ||
z: number[] | ||
} | ||
} | ||
|
||
export type RawTown = RawEntity & { | ||
name: string | ||
board: string | ||
mayor: string | ||
founder: string | ||
mapColorHexCode: string | ||
nation?: string | ||
timestamps?: Timestamps | ||
perms: RawEntityPerms<RawTownPerms> | ||
coordinates: TownCoordinates | ||
residents: string[] | ||
trusted?: string[] | ||
outlaws?: string[] | ||
} | ||
|
||
export type RawNation = RawEntity & { | ||
name: string | ||
board: string | ||
king: string | ||
capital: string | ||
mapColorHexCode: string | ||
timestamps?: Timestamps | ||
towns: string[] | ||
residents: string[] | ||
allies: string[] | ||
enemies: string[] | ||
} | ||
|
||
export type Timestamps = { | ||
joinedNationAt?: number | ||
joinedTownAt?: number | ||
registered: number | ||
lastOnline?: number | ||
} | ||
|
||
export type RawResident = RawEntity & { | ||
name: string | ||
title: string | ||
surname: string | ||
town?: string | ||
nation?: string | ||
timestamps?: Timestamps | ||
perms: RawEntityPerms<RawResidentPerms> | ||
friends?: string[] | ||
} | ||
|
||
export type RawServerInfo = { | ||
world: { | ||
hasStorm: boolean | ||
isThundering: boolean | ||
time: number | ||
fullTime: number | ||
} | ||
players: { | ||
maxPlayers: number | ||
numOnlineTownless: number | ||
numOnlinePlayers: number | ||
} | ||
stats: { | ||
numResidents: number | ||
numTownless: number | ||
numTowns: number | ||
numNations: number | ||
numTownBlocks: number | ||
} | ||
} | ||
//#endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export type NestedOmit<T, K extends PropertyKey> = { | ||
[P in keyof T as P extends K ? never : P]: | ||
NestedOmit<T[P], K extends `${Exclude<P, symbol>}.${infer R}` ? R : never> | ||
} extends infer O ? { [P in keyof O]: O[P] } : never; | ||
|
||
export type ValidateShape<T, Shape> = T extends Shape ? Exclude<keyof T, keyof Shape> extends never ? T : never : never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.