# Coverage for client/parts/room.py : 100%

## 43 statements 43 run 0 missing 2 excluded 0 partial

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1# -*- coding: utf-8 -*-

2 from __future__ import annotations

3

4# -- stdlib --

5 from typing import TYPE_CHECKING, Any

6 import logging

7

8# -- third party --

9# -- own --

10 from utils.events import EventHub

11 import wire

12

13# -- typing --

14 if TYPE_CHECKING:

15 from client.core import Core # noqa: F401

16

17

18# -- code --

19 log = logging.getLogger('client.parts.Room')

20 STOP = EventHub.STOP_PROPAGATION

21

22

23 class Room(object):

24 def __init__(self, core: Core):

25 self.core = core

26

27 # ---- Reactions -----

28

29 # ----- Public Method -----

30 def create(self, name: str, mode: str, flags: wire.CreateRoomFlags) -> None:

31 core = self.core

32 core.server.write(wire.CreateRoom(name=name, mode=mode, flags=flags))

33

34 def join(self, gid: int, slot: int = None) -> None:

35 core = self.core

36 core.server.write(wire.JoinRoom(gid=gid, slot=slot))

37

38 def leave(self) -> None:

39 core = self.core

40 core.server.write(wire.LeaveRoom())

41

42 def get_ready(self) -> None:

43 core = self.core

44 core.server.write(wire.GetReady())

45

46 def cancel_ready(self) -> None:

47 core = self.core

48 core.server.write(wire.CancelReady())

49

50 def change_location(self, loc: int) -> None:

51 core = self.core

52 core.server.write(wire.ChangeLocation(loc=loc))

53

54 def get_room_users(self, gid: int) -> None:

55 core = self.core

56 core.server.write(wire.GetRoomUsers(gid=gid))

57

58 def set_game_param(self, gid: int, key: str, value: Any) -> None:

59 core = self.core

60 core.server.write(wire.SetGameParam(gid=gid, key=key, value=value))

61

62 def use_item(self, sku: str) -> None:

63 core = self.core

64 core.server.write(wire.UseItem(sku=sku))

65

66 def invite(self, uid: int) -> None:

67 core = self.core

68 core.server.write(wire.Invite(uid=uid))

69

70 def kick(self, uid: int) -> None:

71 core = self.core

72 core.server.write(wire.Kick(uid=uid))