import Role from '../model/enums/Role' ; import GameCreationResult from '../model/server/GameCreationResult' ; import GameInfo from '../model/server/GameInfo' ; import GameSettings from '../model/server/GameSettings' ; import HostInfo from '../model/server/HostInfo' ; import PackageKey from '../model/server/PackageKey' ; import Slice from '../model/server/Slice' ; import IGameServerClient from './IGameServerClient' ; /** Represents a connection to a SIGame Server. */ export default class GameServerClient implements IGameServerClient { /**
     * Initializes a new instance of  GameServerClient .
     *  param connection constructor ( private connection ) { } getComputerAccountsAsync ( ) { return this . connection . invoke < string [ ] > ( 'GetComputerAccounts' ) ; } getGameHostInfoAsync ( ) { return this . connection . invoke < HostInfo > ( 'GetGamesHostInfo' ) ; } getGamesSliceAsync ( fromId ) { return this . connection . invoke < Slice < GameInfo > > ( 'GetGamesSlice' , fromId ) ; } getUsersAsync ( ) { return this . connection . invoke < string [ ] > ( 'GetUsers' ) ; } getNewsAsync ( ) { return this . connection . invoke < string | null > ( 'GetNews' ) ; } sayInLobbyAsync ( text ) { return this . connection . invoke ( 'Say' , text ) ; } hasPackageAsync ( packageKey ) { return this . connection . invoke < boolean > ( 'HasPackage' , packageKey ) ; } createAndJoinGameAsync ( gameSettings , packageKey , isMale ) { return this . connection . invoke < GameCreationResult > ( 'CreateAndJoinGameNew' , gameSettings , packageKey , [ ] , isMale ) ; } createAutomaticGameAsync ( login , isMale ) { return this . connection . invoke < GameCreationResult > ( 'CreateAutomaticGameNew' , login , isMale ) ; } joinGameAsync ( gameId , role , isMale , password ) { return this . connection . invoke < GameCreationResult > ( 'JoinGameNew' , gameId , role , isMale , password ) ; } sendMessageToServerAsync ( message ) { return this . connection . invoke ( 'SendMessage' , { Text : message , IsSystem : true , Receiver : '@' } ) ; } msgAsync ( ... args ) { return this . sendMessageToServerAsync ( args . join ( '\n' ) ) ; } sayAsync ( message ) { return this . connection . invoke ( 'SendMessage' , { Text : message , IsSystem : false , Receiver : '*' } ) ; } /** Leaves the game and returns to the lobby. */ leaveGameAsync ( ) { return this . connection . invoke ( 'LeaveGame' ) ; } logOutAsync ( ) { return this . connection . invoke ( 'LogOut' ) ; } }