def value(self, entity: str) -> float: try: value = self._cache[entity] LogCat.log(f'ValueComponent.value entity: {entity} value: {value}') except KeyError: LogCat.log(f'ValueComponent.value entity: {entity} keyError') value = 0 return value
def _on_sign_in(self, guest, **kwargs): LogCat.log(f"id: {kwargs['user_id']} passwd {kwargs['passwd']}") print(f"id: {kwargs['user_id']} passwd {kwargs['passwd']}") guest.set_user(kwargs["user_id"]) guest.send_msg( Message(Message.WELCOME, who="MUTE", guest=kwargs["user_id"], text="welcome"))
def _check_input(self) -> None: try: e = self._window.get_wch() if e == 'q': Event.trigger(Event(Event.EXIT, self)) elif e == curses.KEY_MOUSE: _, x, y, _, _ = curses.getmouse() Event.trigger( Event(Event.CLICK, self._window_manager, x=x, y=y)) elif type(e) == str: LogCat.log(f'keypressed: {e}') # elif e > 0: Event.trigger( Event(Event.KEY_PRESSED, self._window_manager.focus, key=e)) else: Event.trigger(Event(e, self._window_manager.focus)) except curses.error: pass self._in_stream()
def _on_death(self, e: Event, entity: str = '') -> None: LogCat.log(f' ----------- ogt death event -=-----')
def move_cursor(self, x: int, y: int) -> None: self._win.move(y, x) y, x = self._win.getyx() LogCat.log(f' move_cursor: x- {x} y- {y}')
def _on_msg_chat(self, from_who, who, text): LogCat.log(f"_on_msg_chat: from- {from_who} who- {who} text- {text}") for guest in self._guests: guest.send_msg(Message(Message.CHAT, who=who, text=text))