-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rewrite/v3' of https://github.com/TheDrone7/shieldbow i…
…nto rewrite/v3
- Loading branch information
Showing
19 changed files
with
868 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,58 @@ | ||
import { Champion, GameMap, GameMode, GameType, Item, RuneTree, SummonerSpell } from '@shieldbow/web'; | ||
import { Client } from 'client'; | ||
import { IMatch } from 'types'; | ||
import { Team } from './team'; | ||
|
||
export class Match { | ||
readonly id: string; | ||
readonly dataVersion: string; | ||
readonly endOfGameResult: string; | ||
readonly gameCreationTimestamp: number; | ||
readonly gameDuration: number; | ||
readonly gameEndTimestamp: number; | ||
readonly gameId: number; | ||
readonly gameMode: GameMode; | ||
readonly gameName: string; | ||
readonly gameStartTimestamp: number; | ||
readonly gameType: GameType; | ||
readonly gameVersion: string; | ||
readonly map: GameMap; | ||
readonly teams: Team[]; | ||
readonly tournamentCode: string; | ||
|
||
constructor( | ||
client: Client, | ||
data: IMatch, | ||
champions: Champion[], | ||
items: Item[], | ||
rTrees: RuneTree[], | ||
spells: SummonerSpell[] | ||
) { | ||
this.id = data.metadata.matchId; | ||
this.dataVersion = data.metadata.dataVersion; | ||
this.endOfGameResult = data.info.endOfGameResult ?? 'GameComplete'; | ||
this.gameCreationTimestamp = data.info.gameCreation; | ||
this.gameDuration = data.info.gameDuration; | ||
this.gameEndTimestamp = data.info.gameEndTimestamp; | ||
this.gameId = data.info.gameId; | ||
this.gameMode = client.gameModes.find((type) => type.gameMode === data.info.gameMode)!; | ||
this.gameName = data.info.gameName; | ||
this.gameStartTimestamp = data.info.gameStartTimestamp; | ||
this.gameType = client.gameTypes.find((type) => type.gametype === data.info.gameType)!; | ||
this.gameVersion = data.info.gameVersion; | ||
this.map = client.maps.find((map) => map.mapId === data.info.mapId)!; | ||
this.teams = data.info.teams.map( | ||
(team) => | ||
new Team( | ||
client, | ||
team, | ||
data.info.participants.filter((p) => p.teamId === team.teamId), | ||
champions, | ||
items, | ||
rTrees, | ||
spells | ||
) | ||
); | ||
this.tournamentCode = data.info.tournamentCode ?? ''; | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
packages/shieldbow/src/structures/match/participant/bounty.ts
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,104 @@ | ||
/** | ||
* A representation of the bounty on a match participant. | ||
*/ | ||
export class ParticipantBounty { | ||
/** | ||
* The bounty level. | ||
*/ | ||
readonly level: number; | ||
/** | ||
* The amount of gold killing the participant will earn. | ||
* | ||
* The maximum amount that can be earned at once is 1000. | ||
* The rest is carried over when the participant respawns. | ||
*/ | ||
readonly killBounty: number; | ||
/** | ||
* The amount of gold assisting in killing the participant will earn. | ||
*/ | ||
readonly assistBounty: number; | ||
/** | ||
* The number of consecutive kills the participant has (to earn them this bounty). | ||
*/ | ||
readonly consecutiveKills: number; | ||
/** | ||
* The number of consecutive deaths the participant has (to earn them this bounty). | ||
*/ | ||
readonly consecutiveDeaths: number; | ||
/** | ||
* The announcement that is made when the participant kills an enemy. | ||
* | ||
* This is only available for bounty levels \> 2. | ||
*/ | ||
readonly announcement?: string; | ||
|
||
/** | ||
* Creates a new bounty instance. | ||
* @param level - the bounty level of the participant. | ||
*/ | ||
constructor(level: number) { | ||
this.level = level; | ||
this.killBounty = 300; | ||
this.assistBounty = 150; | ||
if (level < 0) { | ||
this.consecutiveKills = 0; | ||
this.consecutiveDeaths = -level; | ||
} else { | ||
this.consecutiveKills = level; | ||
this.consecutiveDeaths = 0; | ||
} | ||
if (level < -5) { | ||
this.killBounty = 100; | ||
this.assistBounty = 50; | ||
} else if (level > 7) { | ||
this.killBounty = 1000 + (level - 7) * 100; | ||
this.assistBounty = 150; | ||
this.announcement = 'Legendary'; | ||
} else | ||
switch (level) { | ||
case -5: | ||
this.killBounty = 112; | ||
this.assistBounty = 56; | ||
break; | ||
case -4: | ||
this.killBounty = 140; | ||
this.assistBounty = 70; | ||
break; | ||
case -3: | ||
this.killBounty = 176; | ||
this.assistBounty = 88; | ||
break; | ||
case -2: | ||
this.killBounty = 220; | ||
this.assistBounty = 110; | ||
break; | ||
case -1: | ||
this.killBounty = 274; | ||
this.assistBounty = 137; | ||
break; | ||
case 2: | ||
this.killBounty = 450; | ||
break; | ||
case 3: | ||
this.killBounty = 600; | ||
this.announcement = 'Killing Spree'; | ||
break; | ||
case 4: | ||
this.killBounty = 700; | ||
this.announcement = 'Rampage'; | ||
break; | ||
case 5: | ||
this.killBounty = 800; | ||
this.announcement = 'Unstoppable'; | ||
break; | ||
case 6: | ||
this.killBounty = 900; | ||
this.announcement = 'Dominating'; | ||
break; | ||
case 7: | ||
this.killBounty = 1000; | ||
this.announcement = 'Godlike'; | ||
break; | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
packages/shieldbow/src/structures/match/participant/champion.ts
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,59 @@ | ||
import { Collection } from '@discordjs/collection'; | ||
import { Champion } from '@shieldbow/web'; | ||
import { IMatchParticipant } from 'types'; | ||
|
||
/** | ||
* Represents the stats of a champion picked by a participant in a match. | ||
*/ | ||
export class ParticipantChampion { | ||
/** | ||
* The champion that the participant picked. | ||
*/ | ||
readonly champ: Champion; | ||
/** | ||
* The amount of experience the participant earned on the champion. | ||
*/ | ||
readonly xp: number; | ||
/** | ||
* The level of the champion. | ||
*/ | ||
readonly level: number; | ||
/** | ||
* The numerical ID (key) of the champion. | ||
*/ | ||
readonly id: number; | ||
/** | ||
* The name of the champion. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The transformation of the champion. | ||
* | ||
* This is only used for Kayn - `DARKIN` or `ASSASSIN`. | ||
*/ | ||
readonly transformation: 'NONE' | 'DARKIN' | 'ASSASSIN' = 'NONE'; | ||
/** | ||
* The number of times each ability of the champion was used by the participant. | ||
*/ | ||
readonly abilitiesUsed: Collection<'Q' | 'W' | 'E' | 'R', number> = new Collection(); | ||
|
||
/** | ||
* Creates a new instance of ParticipantChampion. | ||
* @param data - The raw match participant data. | ||
* @param champions - The array of champions. | ||
*/ | ||
constructor(data: IMatchParticipant, champions: Champion[]) { | ||
if (data.championName) this.champ = champions.find((c) => c.name === data.championName)!; | ||
else this.champ = champions.find((c) => c.key === data.championId)!; | ||
this.id = data.championId; | ||
this.name = data.championName; | ||
this.xp = data.champExperience; | ||
this.level = data.champLevel; | ||
this.transformation = data.championTransform === 0 ? 'NONE' : data.championTransform === 1 ? 'DARKIN' : 'ASSASSIN'; | ||
|
||
this.abilitiesUsed.set('Q', data.spell1Casts); | ||
this.abilitiesUsed.set('W', data.spell2Casts); | ||
this.abilitiesUsed.set('E', data.spell3Casts); | ||
this.abilitiesUsed.set('R', data.spell4Casts); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/shieldbow/src/structures/match/participant/damage.ts
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,64 @@ | ||
import { IMatchParticipant } from 'types'; | ||
|
||
/** | ||
* Represents the damage stats of a participant in a match. | ||
*/ | ||
export class ParticipantDamageDealt { | ||
/** | ||
* The total damage dealt to buildings. | ||
* | ||
* This includes turrets, inhibitors, and the nexus. | ||
*/ | ||
readonly toBuildings: number; | ||
/** | ||
* The total damage dealt to neutral objectives. | ||
* | ||
* This includes dragons, grubs, rift herald, and baron. | ||
*/ | ||
readonly toObjectives: number; | ||
/** | ||
* The total damage dealt to turrets only. | ||
*/ | ||
readonly toTurrets: number; | ||
/** | ||
* The total damage self-mitigated by the participant. | ||
*/ | ||
readonly selfMitigated: number; | ||
/** | ||
* Creates a new instance of ParticipantDamageDealt. | ||
* @param data - The raw match participant data. | ||
*/ | ||
constructor(data: IMatchParticipant) { | ||
this.toBuildings = data.damageDealtToBuildings; | ||
this.toObjectives = data.damageDealtToObjectives; | ||
this.toTurrets = data.damageDealtToTurrets; | ||
this.selfMitigated = data.damageSelfMitigated; | ||
} | ||
} | ||
|
||
/** | ||
* Represents the amount of damage of a specific type for a participant in a match. | ||
*/ | ||
export class ParticipantDamage { | ||
/** | ||
* The total damage dealt. | ||
*/ | ||
readonly dealt: number; | ||
/** | ||
* The total damage dealt to champions. | ||
*/ | ||
readonly toChampions: number; | ||
/** | ||
* The total damage taken. | ||
*/ | ||
readonly taken: number; | ||
/** | ||
* Creates a new instance of ParticipantDamage. | ||
* @param data - The raw match participant data. | ||
*/ | ||
constructor(data: IMatchParticipant) { | ||
this.dealt = data.totalDamageDealt; | ||
this.toChampions = data.totalDamageDealtToChampions; | ||
this.taken = data.totalDamageTaken; | ||
} | ||
} |
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,5 @@ | ||
import { IMatchParticipant } from 'types'; | ||
|
||
export class ParticipantGold { | ||
constructor(data: IMatchParticipant) {} | ||
} |
Oops, something went wrong.