import { Player } from "@uno-game/protocols" ; import PlayerRepository from "@/Repositories/PlayerRepository" ; import CryptUtil from "@/Utils/CryptUtil" ; class PlayerService { async setPlayerData ( playerData ) { const player = { id : playerData . id || CryptUtil . makeUUID ( ) , name : playerData . name , } ; await PlayerRepository . setPlayerData ( player ) ; return player ; } async getPlayerData ( playerId ) { return await PlayerRepository . getPlayerData ( playerId ) ; } async playerExists ( playerId ) { const player = await PlayerRepository . getPlayerData ( playerId ) ; if ( player ) { return true ; } else { return false ; } } async getAllPlayerIds ( ) { const playerIds = await PlayerRepository . getAllPlayerIds ( ) ; return playerIds ; } } export default new PlayerService ( ) ;