-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
29 changed files
with
432 additions
and
604 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
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 |
---|---|---|
@@ -1,40 +1,29 @@ | ||
import RedisClient from '../../../db/RedisClient.js' | ||
import { logger } from '../../../utils/logger.js' | ||
import { GSIHandler } from '../../GSIHandler.js' | ||
import { server } from '../../index.js' | ||
import { isPlayingMatch } from '../../lib/isPlayingMatch.js' | ||
import eventHandler from '../EventHandler.js' | ||
|
||
const redisClient = RedisClient.getInstance() | ||
|
||
eventHandler.registerEvent(`hero:alive`, { | ||
handler: async (dotaClient: GSIHandler, alive: boolean) => { | ||
if (!dotaClient.client.stream_online) return | ||
if (!isPlayingMatch(dotaClient.client.gsi)) return | ||
|
||
async function handler() { | ||
const redisJson = (await redisClient.client.json.get(`${dotaClient.getToken()}:aegis`)) as any | ||
const redisClient = RedisClient.getInstance() | ||
const redisJson = (await redisClient.client.json.get(`${dotaClient.getToken()}:aegis`)) as any | ||
|
||
// Case one, we had aegis, and we die with it. Triggers on an aegis death | ||
const playingHeroSlot = Number( | ||
await redisClient.client.get(`${dotaClient.getToken()}:playingHeroSlot`), | ||
) | ||
if (!alive && redisJson?.playerId === playingHeroSlot) { | ||
try { | ||
void redisClient.client.json.del(`${dotaClient.getToken()}:aegis`) | ||
} catch (e) { | ||
logger.error('Error in hero alive', { e }) | ||
} | ||
server.io.to(dotaClient.getToken()).emit('aegis-picked-up', {}) | ||
// Case one, we had aegis, and we die with it. Triggers on an aegis death | ||
const playingHeroSlot = Number( | ||
await redisClient.client.get(`${dotaClient.getToken()}:playingHeroSlot`), | ||
) | ||
|
||
return | ||
} | ||
if (!(!alive && redisJson?.playerId === playingHeroSlot)) { | ||
return | ||
} | ||
|
||
try { | ||
void handler() | ||
} catch (e) { | ||
logger.error('Error in hero alive', { e }) | ||
} | ||
await redisClient.client.json.del(`${dotaClient.getToken()}:aegis`) | ||
server.io.to(dotaClient.getToken()).emit('aegis-picked-up', {}) | ||
|
||
return | ||
}, | ||
}) |
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
2 changes: 1 addition & 1 deletion
2
...ta/src/dota/lib/getCurrentMatchPlayers.ts → .../dota/src/dota/lib/getSpectatorPlayers.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
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.