@ezgdev/game-composite-connector
v2.0.2
Published
<p align="center"> <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a> </p>
Downloads
76
Readme
Description
Operator interface library for Online Player service connection
Installation
$ yarn add @ezgdev/game-composite-connector
Getting Started
register library into module
import { Module } from '@nestjs/common';
import { OnlinePlayerModule } from '@ezgdev/game-composite-connector';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [
OnlinePlayerModule.register({
appId: process.env.APPID,
url: process.env.GAME_COMPOSITE_URL,
waterPercent: 10, // optional: value 0 - 100 %
providerId: process.env.PROVIDER_ID,
providerSecret: process.env.PROVIDER_SECRET,
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Implement OnlinePlayerClient to service
import { Injectable } from '@nestjs/common';
import { OnlinePlayerService } from '@ezgdev/game-composite-connector';
@Injectable()
export class AppService {
constructor(
private onlinePlayer: OnlinePlayerClient,
private gamePlayer: GamePlayerClient
) {}
async login(authToken: string) {
const authData = await this.onlinePlayer.auth(authToken);
const { accessToken } = authData;
const playerInfo = await this.onlinePlayer.getInfo(accessToken);
const balance = await this.onlinePlayer.getCash(accessToken);
return {
name: playerInfo.name,
money: balance.currentMoney,
};
}
}
Implement GamePlayerClient to service
export class AppService {
constructor(
private onlinePlayer: OnlinePlayerClient,
private gamePlayer: GamePlayerClient
) {}
async pay(...args[]) {
...
...
const balance = await this.gamePlayer.win(uuid, betId, matchId, amount, bets, results, gameData)
return balance;
}
}