Skip to content

Commit

Permalink
Rewrite types
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Jul 29, 2024
1 parent 07975b7 commit 98ae0d1
Show file tree
Hide file tree
Showing 25 changed files with 633 additions and 796 deletions.
112 changes: 111 additions & 1 deletion src/structures/Game.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,116 @@
import { GameCode, GameID, GameString } from '../typings';
import Constants from '../utils/Constants';

export type GameString =
| 'Quake Craft'
| 'Walls'
| 'Paintball'
| 'Blitz Survival Games'
| 'The TNT Games'
| 'VampireZ'
| 'Mega Walls'
| 'Arcade'
| 'Arena Brawl'
| 'UHC Champions'
| 'Cops and Crims'
| 'Warlords'
| 'Smash Heroes'
| 'Turbo Kart Racers'
| 'Housing'
| 'SkyWars'
| 'Crazy Walls'
| 'Speed UHC'
| 'SkyClash'
| 'Classic Games'
| 'Prototype'
| 'Bed Wars'
| 'Murder Mystery'
| 'Build Battle'
| 'Duels'
| 'SkyBlock'
| 'The Pit'
| 'Replay'
| 'SMP'
| 'Wool Wars'
| 'Limbo'
| 'Queue'
| 'Main Lobby'
| 'Tournament Lobby'
| 'Idle';

export type GameCode =
| 'QUAKECRAFT'
| 'WALLS'
| 'PAINTBALL'
| 'SURVIVAL_GAMES'
| 'TNTGAMES'
| 'VAMPIREZ'
| 'WALLS3'
| 'ARCADE'
| 'ARENA'
| 'UHC'
| 'MCGO'
| 'BATTLEGROUND'
| 'SUPER_SMASH'
| 'GINGERBREAD'
| 'HOUSING'
| 'SKYWARS'
| 'TRUE_COMBAT'
| 'SPEED_UHC'
| 'SKYCLASH'
| 'LEGACY'
| 'PROTOTYPE'
| 'BEDWARS'
| 'MURDER_MYSTERY'
| 'BUILD_BATTLE'
| 'DUELS'
| 'SKYBLOCK'
| 'PIT'
| 'REPLAY'
| 'SMP'
| 'WOOL_GAMES'
| 'LIMBO'
| 'QUEUE'
| 'MAIN_LOBBY'
| 'TOURNAMENT_LOBBY'
| 'IDLE';

export type GameID =
| 2
| 3
| 4
| 5
| 6
| 7
| 13
| 14
| 17
| 20
| 21
| 23
| 24
| 25
| 26
| 51
| 52
| 54
| 55
| 56
| 57
| 58
| 59
| 60
| 61
| 63
| 64
| 65
| 67
| 68
| -2
| -3
| -4
| -5
| -6;

/**
* Game class
*/
Expand Down
3 changes: 1 addition & 2 deletions src/structures/Guild/Guild.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { calculateExpHistory, getGuildLevel, members, ranks, totalWeeklyGexp } from '../../utils/Guild';
import { ExpHistory } from '../../typings';
import { calculateExpHistory, ExpHistory, getGuildLevel, members, ranks, totalWeeklyGexp } from '../../utils/Guild';
import GuildMember from './GuildMember';
import GuildRank from './GuildRank';
import Color from '../Color';
Expand Down
3 changes: 1 addition & 2 deletions src/structures/Guild/GuildMember.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { parseHistory } from '../../utils/Guild';
import { ExpHistory } from '../../typings';
import { ExpHistory, parseHistory } from '../../utils/Guild';

class GuildMember {
uuid: string;
Expand Down
159 changes: 150 additions & 9 deletions src/structures/MiniGames/BedWars.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,155 @@
import {
BedWarsCollectedItems,
BedWarsPracticeStats,
BedwarsDreamStats,
BedWarsModeStats,
BedWarsPrestige,
BedWarsBeds,
BedWarsAvg
} from '../../typings';
import divide from '../../utils/divide';

export type BedWarsPrestige =
| 'Stone'
| 'Iron'
| 'Gold'
| 'Diamond'
| 'Emerald'
| 'Sapphire'
| 'Ruby'
| 'Crystal'
| 'Opal'
| 'Amethyst'
| 'Rainbow'
| 'Iron Prime'
| 'Gold Prime'
| 'Diamond Prime'
| 'Emerald Prime'
| 'Sapphire Prime'
| 'Ruby Prime'
| 'Crystal Prime'
| 'Opal Prime'
| 'Amethyst Prime'
| 'Mirror'
| 'Light'
| 'Dawn'
| 'Dusk'
| 'Air'
| 'Wind'
| 'Nebula'
| 'Thunder'
| 'Earth'
| 'Water'
| 'Fire'
| 'Sunrise'
| 'Eclipse'
| 'Gamma'
| 'Majestic'
| 'Andesine'
| 'Marine'
| 'Element'
| 'Galaxy'
| 'Atomic'
| 'Sunset'
| 'Time'
| 'Winter'
| 'Obsidian'
| 'Spring'
| 'Ice'
| 'Summer'
| 'Spinel'
| 'Autumn'
| 'Mystic'
| 'Eternal';

export interface BedWarsCollectedItems {
iron: number;
gold: number;
diamond: number;
emerald: number;
}

export interface BedWarsAvg {
kills: number;
finalKills: number;
bedsBroken: number;
}

export interface BedWarsBeds {
lost: number;
broken: number;
BLRatio: number;
}

export interface BedWarsModeStats {
winstreak: number;
playedGames: number;
kills: number;
deaths: number;
wins: number;
losses: number;
finalKills: number;
finalDeaths: number;
beds: BedWarsBeds;
avg: BedWarsAvg;
KDRatio: number;
WLRatio: number;
finalKDRatio: number;
}
export interface BedwarsDreamModeStats {
doubles: BedWarsModeStats;
fours: BedWarsModeStats;
}

export interface BedwarsDreamStats {
ultimate: BedwarsDreamModeStats;
rush: BedwarsDreamModeStats;
armed: BedwarsDreamModeStats;
lucky: BedwarsDreamModeStats;
voidless: BedwarsDreamModeStats;
}

export interface BedWarsPracticeAttempts {
failed: number;
successful: number;
total: number;
}

export interface BedWarsPracticeElevation {
straight: number;
diagonal: number;
}

export interface BedWarsPracticeElevations {
none: BedWarsPracticeElevation;
slight: BedWarsPracticeElevation;
staircase: BedWarsPracticeElevation;
}

export interface BedWarsPracticeRecord {
elevation: BedWarsPracticeElevations;
}

export interface BedWarsPracticeRecords {
blocks30: BedWarsPracticeRecord;
blocks50: BedWarsPracticeRecord;
blocks100: BedWarsPracticeRecord;
}

export interface BedWarsPracticeBridging {
blocksPlaced: number;
attempts: BedWarsPracticeAttempts;
records: BedWarsPracticeRecords;
}

export interface BedWarsPracticePearlClutching {
attempts: BedWarsPracticeAttempts;
}

export interface BedWarsPracticeBase {
blocksPlaced: number;
attempts: BedWarsPracticeAttempts;
}

export interface BedWarsPracticeStats {
selected: string;
bridging: BedWarsPracticeBridging;
fireballJumping: BedWarsPracticeBase;
pearlClutching: BedWarsPracticePearlClutching;
mlg: BedWarsPracticeBase;
}

function generateStatsForMode(data: Record<string, any>, mode: string): BedWarsModeStats {
return {
winstreak: data[`${mode}_winstreak`] || 0,
Expand Down
9 changes: 8 additions & 1 deletion src/structures/MiniGames/BuildBattle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { BuildBattleWins } from '../../typings';
import divide from '../../utils/divide';

export interface BuildBattleWins {
solo: number;
teams: number;
pro: number;
gtb: number;
}

/**
* BuildBattle class
*/
Expand Down
7 changes: 6 additions & 1 deletion src/structures/MiniGames/Pit.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { decode } from '../../utils/SkyblockUtils';
import PitInventoryItem from './PitInventoryItem';
import Constants from '../../utils/Constants';
import { PitArmor } from '../../typings';
import divide from '../../utils/divide';

export interface PitArmor {
helmet: PitInventoryItem | null;
chestplate: PitInventoryItem | null;
leggings: PitInventoryItem | null;
boots: PitInventoryItem | null;
}
/**
* Pit Class
*/
Expand Down
14 changes: 13 additions & 1 deletion src/structures/MiniGames/SkyWars.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { removeSnakeCaseString } from '../../utils/removeSnakeCase';
import { SkyWarsPrestige } from '../../typings';
import divide from '../../utils/divide';

export type SkyWarsPrestige =
| 'Iron'
| 'Gold'
| 'Diamond'
| 'Emerald'
| 'Sapphire'
| 'Ruby'
| 'Crystal'
| 'Opal'
| 'Amethyst'
| 'Rainbow'
| 'Mythic';

function getSkyWarsPrestige(level: number): SkyWarsPrestige {
if (60 <= level) return 'Mythic';
return (['Iron', 'Iron', 'Gold', 'Diamond', 'Emerald', 'Sapphire', 'Ruby', 'Crystal', 'Opal', 'Amethyst', 'Rainbow'][
Expand Down
23 changes: 22 additions & 1 deletion src/structures/MiniGames/WoolWars.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import { WoolWarsPrivateGamesConfig, WoolWarsStats } from '../../typings';
import divide from '../../utils/divide';

export interface WoolWarsStats {
wins: number;
gamesPlayed: number;
woolsPlaced: number;
blocksBroken: number;
placeBreakRatio: number;
kills: number;
deaths: number;
KDRatio: number;
assists: number;
powerups: number;
}
export interface WoolWarsPrivateGamesConfig {
one_hit_one_kil: boolean;
rainbow_wool: 'Enabled' | 'Disabled';
health_buff: string;
game_speed: string;
speed: string;
no_class: 'Enabled' | 'Disabled';
respawn_enable: boolean;
}

function convertXPToLevel(exp: number): number {
const minimalExp = [0, 1e3, 3e3, 6e3, 1e4, 15e3];
const baseLevel = minimalExp.length;
Expand Down
Loading

0 comments on commit 98ae0d1

Please sign in to comment.