Example #1
0
    def send_room_actions(self, room):
        if len(room.actions) == 0:
            actionsstring = i18n(
                self.lang, {
                    "en": "There is nothing you can do here, sorry...",
                    "de": "Hier kannst Du leider nichts tun..."
                })
        else:
            actionsstring = ""
            for a in room.actions:
                actionsstring = actionsstring + i18n(self.lang,
                                                     a['description']) + "\r\n"

        self.send_text("\r\n\r\n" + i18n(self.lang, room.description) +
                       "\r\n" + actionsstring)
        ans = {"cmd": "html", "data": i18n(self.lang, room.webview)}
        self.wsclient.write_message(ans)
        if room.videoview:
            ans = {
                "cmd": "video",
                "enabled": True,
                "data": i18n(self.lang, room.videoview)
            }
            self.wsclient.write_message(ans)
        else:
            ans = {"cmd": "video", "enabled": False}
            self.wsclient.write_message(ans)
Example #2
0
 def action_help(self, a, msg, parameter):
     if len(msg.split()) < 2:
         self.send_text(i18n(self.lang, a['description']))
         return
     for a in Player.actions:
         if msg[5:].startswith(i18n(self.lang, a['command'])):
             self.send_text(i18n(self.lang, a['help']))
             return
Example #3
0
    def action_rename(self, a, msg, parameter):
        newname = msg[len(i18n(self.lang, a['command'])) + 1:]
        if len(newname) < 3:
            self.send_text(
                i18n(self.lang, {
                    "en": "Thats to short...",
                    "de": "Das ist zu kurz..."
                }))
            return

        for p in self.room.player:
            p.send_text(self.name + " " + i18n(p.lang, a['description']) +
                        " '" + newname + "'")
        self.name = newname
Example #4
0
 def action_language(self, a, msg, parameter):
     if parameter == "en":
         self.lang = "en"
     if parameter == "de":
         self.lang = "de"
     self.send_player_new_command_list()
     self.send_text(i18n(self.lang, a['description']))
Example #5
0
    def enter_room(self, roomaction):

        roomid = roomaction['roomid']
        newroom = Room.get_room_by_id(roomid)
        if self in self.room.player:
            self.room.player.remove(self)
        for p in self.room.player:
            p.send_text(
                i18n(
                    p.lang, {
                        "en":
                        "" + self.name + " leaves the room..." +
                        i18n(self.lang, roomaction['command'])
                    }))

        # enter the room, first notification then enter
        enteraction = None
        for a in newroom.actions:
            if 'roomid' in a and a['roomid'] == self.room.roomid:
                enteraction = a
        if enteraction is None:
            for p in newroom.player:
                p.send_text(
                    i18n(
                        p.lang, {
                            "en":
                            "" + self.name +
                            " enters the room with a puff of smoke..."
                        }))
        else:
            for p in newroom.player:
                p.send_text(
                    i18n(
                        p.lang, {
                            "en":
                            "" + self.name + " enters the room..." +
                            i18n(self.lang, enteraction['command'])
                        }))

        newroom.player.append(self)

        self.send_room_actions(newroom)
        self.room = newroom
        self.send_player_new_command_list()
        self.send_other_players_in_room(self.room)
        self.send_is_room_admin()
Example #6
0
 def send_player_new_command_list(self):
     commands = []
     for a in Player.actions:
         commands.append(i18n(self.lang, a['command']))
     ans = {"cmd": "newcommandlist", "type": "player", "data": commands}
     self.wsclient.write_message(ans)
     commands = self.room.get_room_command_list(self)
     ans = {"cmd": "addcommandlist", "type": "room", "data": commands}
     self.wsclient.write_message(ans)
Example #7
0
    def parse_user_command(wsclient, jsonmsg):
        
        lang = wsclient.player.lang
        
        if jsonmsg['cmd']=='user':
            #wsclient.player.parse_user_command(jsonmsg['data'])
            answered = False
            msg = jsonmsg['data']
            for a in Player.actions:
                if msg.startswith(i18n(lang,a['command'])):
                    parameter = msg[ len(i18n(lang,a['command']))+1:]
                    getattr(wsclient.player,a['function'])(a,msg, parameter)
                    answered = True
    
            if not answered:
                answered = wsclient.player.room.parse_user_command(wsclient.player, msg)
            if not answered:
                wsclient.player.send_text(i18n(lang,{ "en":"What you mean by '","de":"Was meinst Du mit '"})+msg+i18n(lang,{"en":"'? Try 'help' and remember: The TAB-key has always been your friend!","de":"'? Versuche 'hilfe' und erinnere Dich: Die TAB-Taste war schon immer Dein bester Freund!"}))

        elif jsonmsg['cmd']=='getroom':
            wsclient.write_message(wsclient.player.room.toJSON)
Example #8
0
 def send_other_players_in_room(self, room):
     if len(room.player) == 1:
         self.send_text(
             i18n(
                 self.lang, {
                     "en": "You are here on your own...",
                     "de": "Du bist hier ganz alleine..."
                 }))
     elif len(room.player) < 10:
         playerstr = ""
         numberofplayers = 0
         for p in room.player:
             if p.name != self.name:
                 playerstr = playerstr + p.name + " "
                 numberofplayers = numberofplayers + 1
         if numberofplayers == 1:
             self.send_text(
                 i18n(
                     self.lang, {
                         "en": playerstr + "is idling here...",
                         "de": playerstr + "steht hier rum..."
                     }))
         else:
             self.send_text(
                 i18n(
                     self.lang, {
                         "en": playerstr + "are idling here...",
                         "dn": playerstr + "stehen hier rum..."
                     }))
     else:
         self.send_text(
             i18n(
                 self.lang, {
                     "en": "Many people are idling here...",
                     "de": "Ein Haufen Leute steht hier rum..."
                 }))
Example #9
0
 def parse_user_command(self, player, msg):
     for a in self.actions:
         if msg.startswith(i18n(player.lang,a['command'])):
             self.execute_action(player,a)
             return True
     if msg.startswith("roomeditor"):
         if Area.get_area_by_id(self.areaid).are_ids_in_chain(player.admin_for_area):
             data = { "roomid" : self.roomid,
                "areaid": self.areaid,
                "actions" : self.actions,
                "name" : self.name,
                "description" : self.description,
                "items" : self.items,
                "capacity" : self.capacity,
                "webview" : self.webview,
                "videoview" : self.videoview
              }
             ans = { "cmd": "editroom",
                    "data": data }
             player.wsclient.write_message(ans)
             return True
     return False
Example #10
0
 def ws_disconnect(self):
     for p in self.room.player:
         p.send_text(
             i18n(p.lang, {"en": "" + self.name + " disconnects..."}))
     log.debug("player " + self.name + " disconnects.")
     self.room.player.remove(self)
Example #11
0
 def action_sleep(self, a, msg, parameter):
     self.send_text(i18n(self.lang, a['description']))
Example #12
0
 def action_say(self, a, msg, parameter):
     for p in self.room.player:
         p.send_text(self.name + " " + i18n(p.lang, a['description']) +
                     " '" + msg[len(i18n(self.lang, a['command'])) + 1:] +
                     "'")
Example #13
0
 def get_room_command_list(self,player):
     commands = []
     for a in self.actions:
         commands.append(i18n(player.lang,a['command']))
     return commands