Open WolfPRAcc7 opened 4 days ago
todo for pr, i'll work on it tommorow just as a note but this should be implemented
roomaddress
@sio.on(2) async def onReceive(roomAddress: str, team: int, maps: any): await r.triggerEvent(Event("CREATED_ROOM", {'roomAddress': roomAddress, 'team':team, 'maps':maps})) server.roomAddress = roomAddress
mostly the roomaddress part.
player_host_left @sio.on(6) async def onReceive(oldHost: int, newHost: int, unknown_2): newHostPlayer = server.getPlayer(newHost) await r.triggerEvent(Event("PLAYER_HOST_LEFT", {'oldHost': server.getPlayer(oldHost), 'newHost':newHostPlayer, 'closedRoom': newHostPlayer == None, 'UNKNOWN_2':unknown_2})) server.freePlayer(oldHost) game.host = newHostPlayer
this too, for the host leaving.
and error fix: in
@self.__socket_client.on(5) async def on_player_left(short_id: int, w) -> None: left_player = [player for player in self.players if player.short_id == short_id][0] self.players.remove(left_player) self.__event_emitter.emit("player_left", self, left_player)
as short_id may be null,none and in that case the player was removed by host, so a null check si needed in place
theres also no input parsing this could be a good starter class:
class PlayerInput: inputMapping: dict[str, int] = { 'left': Input.LEFT.value, 'right': Input.RIGHT.value, 'up': Input.UP.value, 'down': Input.DOWN.value, 'action': Input.ACTION.value, 'heavy': Input.ACTION.value, 'action2': Input.ACTION2.value, 'special': Input.ACTION2.value } def __init__(self, inputBits: int = 0, frame: int = 0, sequenceNumber: int = 0): self.inputBits: int = inputBits self.frame: int = frame self.sequenceNumber: int = sequenceNumber def isDown(self, inputName: str) -> bool: return (self.inputBits & PlayerInput.inputMapping.get(inputName.lower(), 0)) != 0 def unset(self, inputName: str) -> 'PlayerInput': newInputBits = self.inputBits & ~(self.inputMapping[inputName.lower()]) return PlayerInput(newInputBits, self.frame, self.sequenceNumber) def set(self, inputName: str) -> 'PlayerInput': newInputBits = self.inputBits | self.inputMapping.get(inputName.lower(), 0) return PlayerInput(newInputBits, self.frame, self.sequenceNumber) def clear(self) -> 'PlayerInput': return PlayerInput(0, self.frame, self.sequenceNumber) def serialize(self, raw: bool = True) -> dict[str, int]: if raw: return {"i":self.inputBits, 'f':self.frame, 'c':self.sequenceNumber} return {"inputBits":self.inputBits, 'frame':self.frame, 'sequenceNumber':self.sequenceNumber} def getInputsDown(self) -> list[str]: return [inputName for inputName in PlayerInput.inputMapping.keys() if self.isDown(inputName)]
just make sure with input parsing to watch out for modded inputs like bonk commands sends
ready reset isnt parsed so that means the is_ready flag for players can be invalid after its reset for everyone see
@sio.on(9) async def onReceive(): for player in server.getPlayersFromPart("*a"): player.ready = False await r.triggerEvent(Event("READY_RESET", {}))
also not implemented:
@sio.on(27) async def onReceive(wl: int): await r.triggerEvent(Event("ROUNDS_CHANGED", {'WL': wl})) game.wl = wl
both not implemented:
@sio.on(33) async def onReceive(_map: str, sid: int): await r.triggerEvent(Event("MAP_SUGGEST", {'player': server.getPlayer(sid), 'mapRaw':_map, 'map': LZStringDecoder().decodeMap(_map)})) @sio.on(34) async def onReceive(mapName: str, mapAuthor: str, sid: int): await r.triggerEvent(Event("MAP_SUGGEST_CLIENT", {'mapName': mapName, 'mapAuthor':mapAuthor, 'player':server.getPlayer(sid)}))
also not implemented: (only GAME_MODE_CHANGED aka 26 is)
@sio.on(35) async def onReceive(mode: str): game.mode['mode'] = Mode(mode) if (mode == "f"): game.mode['game'] = GameEngine("f") else: game.mode['game'] = GameEngine("b") await r.triggerEvent(Event("MODE_CHANGED", {'mode': mode}))
all these are also not implemented
@sio.on(32) async def onReceive(*data): await r.triggerEvent(Event("AFK_WARN", {})) @sio.on(40) async def onReceive(sid: int): await r.triggerEvent(Event("REPLAY_SAVED", {'player': server.getPlayer(sid)})) @sio.on(42) async def onReceive(sid: int): await r.triggerEvent(Event("FRIEND_REQUEST", {'player': server.getPlayer(sid)})) @sio.on(43) async def onReceive(number: int): await r.triggerEvent(Event("COUNTDOWN_STARTING", {'number': number})) @sio.on(44) async def onReceive(*data): await r.triggerEvent(Event("COUNTDOWN_ABORTED", {})) @sio.on(45) async def onReceive(data: dict[str, int]): player = server.getPlayer(data['sid']) oldLevel = player.level player.level = data['lv'] await r.triggerEvent(Event("PLAYER_LEVELED_UP", {'oldLevel': oldLevel, 'newLevel':player.level, 'player':player})) @sio.on(46) async def onReceive(data: dict[str, int|str]): newXp: int = {'newXP': data['newXp']} newLevel: None|int = data.get("newLevel") if(newLevel): await r.triggerEvent(Event("LOCAL_LEVELED_UP", newXp.update({'newLevel': newLevel, 'newToken': data['newToken']}))) else: await r.triggerEvent(Event("LOCAL_GAINED_XP", newXp)) @sio.on(47) async def onReceive(*data): await r.triggerEvent(Event("LOCAL_REVERT", {'data': data})) @sio.on(48) async def onReceive(*data): await r.triggerEvent(Event("RECEIVE_IN_GAME", {'data': data}))
also implement: LZStringDecoder decode,encode, LZStringDecoder decodeMap,encodeMap
bro 💀
todo for pr, i'll work on it tommorow just as a note but this should be implemented
roomaddress
mostly the roomaddress part.
this too, for the host leaving.
and error fix: in
as short_id may be null,none and in that case the player was removed by host, so a null check si needed in place
theres also no input parsing this could be a good starter class:
just make sure with input parsing to watch out for modded inputs like bonk commands sends
ready reset isnt parsed so that means the is_ready flag for players can be invalid after its reset for everyone see
also not implemented:
both not implemented:
also not implemented: (only GAME_MODE_CHANGED aka 26 is)
all these are also not implemented
also implement: LZStringDecoder decode,encode, LZStringDecoder decodeMap,encodeMap