# lcinterface

> An easy way to interact with the league client. This module is basically a middle layer between your app and the league client

Latest version **4.1.3** (published 2022-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install lcinterface
pnpm add lcinterface
yarn add lcinterface
bun add lcinterface
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.3 |
| Published | 2022-08-13 |
| First published | 2022-06-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | cactoes |
| Keywords | lcu, league-client, league-of-legends, typescript, javascript, interface |

## Links

- npm: https://www.npmjs.com/package/lcinterface
- Repository: https://github.com/cactoes/league_client_interface
- Homepage: https://github.com/cactoes/league_client_interface#readme
- Issues: https://github.com/cactoes/league_client_interface/issues
- npm.io page: https://npm.io/package/lcinterface

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 4.1.3 (latest) — 2022-08-13
- 4.1.2 — 2022-08-11
- 4.1.1 — 2022-08-11
- 4.1.0 — 2022-08-11
- 4.0.0 — 2022-06-25
- 3.3.2 — 2022-06-22
- 3.3.1 — 2022-06-21
- 3.3.0 — 2022-06-21
- 3.2.3 — 2022-06-19
- 3.2.2 — 2022-06-19
- 3.2.1 — 2022-06-19
- 3.2.0 — 2022-06-19
- 3.1.3 — 2022-06-19
- 3.1.2 — 2022-06-19
- 3.1.1 — 2022-06-19
- … 19 more at https://npm.io/package/lcinterface/versions

## README

# League client interface
An easy way to interact with the league client. This module is basically a middle layer between your app and the league client

# Documentation
## Dependencies
- node-fetch@2.6.1

## Importing
```
$ npm install lcinterface
```
```javascript
const { LCIConnector, LCIClient } = require("lcinterface")
const connector = new LCIConnector()
```
## Getting client credentials 
```javascript
// optional
// the interval a wich lcinterface checks if the league of legends process is running (default is 1 sec/1000 ms)
connector.setCheckProcessInterval(1000)

// listen for event connect
connector.on("connect", (credentials) => {
  // do stuff with our client credentials

  // when you are done
  connector.disconnect()
})
// start the client connector
connector.connect()
```
### All events
- LCIConnector
  - `connect` When lcinterface connects to the league client
  - `disconnect` When lcinterface disconnects from the league client

## Using LCIClient
LCIClient is an object with functions and data

### Endpoints
All the built in endpoints in lcinterface

#### Usage
How to use the endpoints
```javascript
await LCIclient.virtualCall(LCIClient.endpoints.user.me, "get")
```

### All endpoints
The built-in endpoints, you cannot make add a new group (ex. user), only new endpoints
- user
  - me [get/post] Gets local user data
- game
  - gameflow [get] Current gameflow state
  - session [get] Current data of the match you are in
  - champselect [get] Champion select data
  - action (when you [get] session you will see what action means)
    - [patch] Needs action id (+`/${actionId}`) and data containing { championId }, doesn't return a body
    - [post] Needs action id (+`/${actionId}`) and data containing { championId }, doesn't return a body
- runes
  - runes
    - [get] All runes of the user
    - [put] To change your runes
  - spells [patch] Set users active summoner spells, need data { spell1Id, spell2Id }, doesn't return a body
- lobby
  - lobby
    - [get] Gets all data of the current lobby
    - [post] Change lobby data or create a lobby wich needs data { queueId }
  - search
    - [post] Starts searching a match (if in lobby), doesn't return a body
    - [delete] Stops searching a match (if in lobby), doesn't return a body
  - partytype [put] Set party to open or closed (string), doesn't return a body
  - position [put] Sets your lanes needs data { firstPreference, secondPreference }, doesn't return a body
  - matchaccept [post] Accepts a match
  - matchdecline [post] Declines a match
#### For all endpoints
[https://lcu.vivide.re/](https://lcu.vivide.re/)

### LCIClient data
All the built in data in lcinterface

#### Usage
```javascript
console.log(LCIClient.game.lanes.UTILITY)
```

### All data
- gameflows
  - NONE
  - LOBBY
  - MATCHMAKING
  - READYCHECK
  - CHAMPSELECT
  - INPROGRESS
  - WAITINGFORSTATS
  - ENDOFGAME
- lanes
  - UNSELECTED
  - TOP
  - JUNGLE
  - MIDDLE
  - BOTTOM
  - UTILITY
- spells
  - Spellname (Barrier, Cleanse, Exhaust, Flash, Ghost, Heal, Smite, Teleport, Clarity, Ignite, Mark)
    - [id] Spell id
    - [key] Other spell name form (ex. summonerFlash)
    - [name] Spellname
- queueId
  - normal
    - blind
    - draft
  - ranked
    - solo_duo
    - flex
  - extra
    - aram
- partytype
  - open
  - closed

## States
LCInterface has some built-in "states" that can giv you some information, [how to get states](#getting-a-state) / [how to set/create states](#setting--creating-a-state)
- [hooked] If LCInterfaces is hooked or not (boolean)
- [vcc] Virtual call count, ammount of times a virtual call is made (number)
- [unsafe] Can LCInterface make unsafe virtual calls (boolean), default is true
- + any you add

## Interface functions
### Hooking
"Hook" onto the interface aka initialise the interface, returns false if already hooked <br />
- params
  - [credentials] All the credentials
- returns boolean
```typescript
LCIClient.hook(credentials: object): boolean
```
### Unhooking
"Unhook" for the league client, returns false if not yet hooked
- return boolean
```typescript
LCIClient.unhook(): boolean
```

### Unsafe virual calls
You can make [virutal calls](#interacting-with-the-client) if you aren't hooked yet, enabled by default
- params
  - [value] Enable or disable the allowing of unsafe call (boolean)
- returns boolean
```typescript
LCIClient.allowUnsafeCalls(value: boolean): boolean
```

### Interacting with the client
Interact with the league client's endpoints **is async**
- params
  - [endpoint] Where to make the call to (string)
  - [method] What method to use
  - [data] (optional) What data to send (object | string), default is empty object
- returns json obj \<T\> | a boolean
```typescript
await LCIClient.virtualCall<T>(endpoint: string, method: methods, data: object | string = {}): Promise<T | boolean>
```

### Getting a state
LCInterface has some built in states (wich you can add to), that you can check
- params
  - [state] What state to check (string)
- returns state data \<T\> | false if state doesn't exist
```typescript
LCIClient.getState<T>(state: string): T | boolean
```

### Setting / Creating a state
LCInterface has some built in states, wich you can set or add to
- params
  - [state] What state to change / create (string)
  - [value] What to set it to
- returns state data \<T\>
```typescript
LCIClient.setState<T>(state: string, value: T): T
```

### Checking a state's value
Here you can check the value of a state
- params
  - [state] The state to check (string)
- returns boolean
```typescript
LCIClient.isCorrectValue<T>(state: string, value: T): boolean
```

## Fast interface functions
LCInterface also has a few faster (unsafer) versions of methods

### Fast hook
Same as the default hook but skips any checks, assumes you are unhooked (will overide data) and is still async
- params
  - [credentials] Only port and password are required
- returns always true
```typescript
await LCIClient.__fasthook(credentials: base_credentials): boolean
```

### Fast unhook
Same as the default unhook but skips any checks, assumes you are hooked and is still async
- returns always false
```typescript
await LCIClient.__fastunhook(): boolean
```

### Fast virtual call
Same as the default virtual call but skips increasing vcc count, assumes you are hooked and is still async
- returns json obj \<T\>
```typescript
await LCIClient.__fastvirtualCall<T>(endpoint: string, method: methods, data: object | string = {}): Promise<T>
```

## License
[MIT License](LICENSE)

---
_Source: https://npm.io/package/lcinterface · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
