You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
/*
|
|
|
|
|
* @file Класс
|
|
|
|
|
* @version 2022.2.6
|
|
|
|
|
* @author Verevkin S.A.
|
|
|
|
|
* @copyright Verevkin S.A.
|
|
|
|
|
*/
|
|
|
|
|
import tool from '../tool';
|
|
|
|
|
import { Game } from '../../model/Game';
|
|
|
|
|
import { IGameDto } from '../../model/GameDto';
|
|
|
|
|
import { Mapper } from '../mapper';
|
|
|
|
|
|
|
|
|
|
const service = {
|
|
|
|
|
// region Публичные функции
|
|
|
|
|
async getGame(): Promise<Game | undefined> {
|
|
|
|
|
const resultPromise = tool.get<IGameDto>('/game', {});
|
|
|
|
|
return resultPromise.then((response: IGameDto | undefined): (Game | undefined) => {
|
|
|
|
|
if (!response) return;
|
|
|
|
|
return Mapper.fromGame(response);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async gameTurn(gameGuid: string, witchGuid: string): Promise<Game | undefined> {
|
|
|
|
|
const resultPromise = tool.get<IGameDto>('/turn', {
|
|
|
|
|
gameGuid, witchGuid
|
|
|
|
|
});
|
|
|
|
|
return resultPromise.then((response: IGameDto | undefined): (Game | undefined) => {
|
|
|
|
|
if (!response) return;
|
|
|
|
|
return Mapper.fromGame(response);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async getVersion(): Promise<string | undefined> {
|
|
|
|
|
return tool.get<string>('/version', {});
|
|
|
|
|
}
|
|
|
|
|
// endregion
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default service;
|