lol-livegame-client
v1.0.1
Published
Library to connect to League of Legends - Game Client API
Maintainers
Readme
lol-livegame-client
A client for the League of Legends Game Client Api. With types and constant values and event handling.
Installation
Install using npm or git.
- Github:
git clone https://github.com/Zonkodonko/lol-livegame-client.git - NPM:
npm install lol-livegame-client
Make Requests
Use the GameClient object to make requests to the game.
Usage Example:
GameClient.getAllGameData().then((gameData: GameData) => console.log(JSON.stringify(gameData)))In case I am too slow updating the library, you can make custom requests:
GameClient.requestLiveApi('/liveclientdata/newendpoint').then(response => console.log(response))Events
To listen to events, subscribe to the LoLEventManager and start fetching events (requesting GET https://127.0.0.1:2999/liveclientdata/eventdata) .
You can start fetching before the game starts. The event manager will retry until the game starts or max retries are reached.
Usage Example:
const eventManager = new LoLEventManager()
eventManager.subscribe((event: LoLEvent) => {
switch (event.EventName) {
case EventName.GameStart:
console.log('Game started!')
break;
case EventName.GameEnd:
console.log('Game ended!')
break;
default:
console.log('Unknown event:', event.EventName)
}
});
eventManager.startFetching()You can find supported events in the EventName enum.
Static Names
Turrets and Inhibitors
Turrets and inhibitors are named in the format {type}_T{team}_L{lane}_P{position}_{native id} but you dont need to remember this. Thats what the Turret class is for. It extracts all information from the name.
You can find all names at StructureNames.md
Usage Example:
const turretName = (event as TurretKilled).TurretKilled; //Turret_TChaos_L1_P2_2237424422
const turret = new Turret(eventName);
if(turret.lane === Lane.Mid) { // Lane.Mid === 1
console.log("Mid lane turret killed!")
}Contributing
Contributions are welcome!
If something doesn't work, make an issue or a pull request...duh
