Example #1
0
    async def handle(self, p: Player) -> None:
        # TODO: match validation..?
        if p.silenced:
            p.enqueue(packets.matchJoinFail() + packets.notification(
                'Multiplayer is not available while silenced.'))
            return

        if not glob.matches.append(self.match):
            # failed to create match (match slots full).
            p.send('Failed to create match (no slots available).',
                   sender=glob.bot)
            p.enqueue(packets.matchJoinFail())
            return

        # create the channel and add it
        # to the global channel list as
        # an instanced channel.
        chan = Channel(name=f'#multi_{self.match.id}',
                       topic=f"MID {self.match.id}'s multiplayer channel.",
                       auto_join=False,
                       instance=True)

        glob.channels.append(chan)
        self.match.chat = chan

        await p.update_latest_activity()
        p.join_match(self.match, self.match.passwd)
        log(f'{p} created a new multiplayer match.')
Example #2
0
    async def handle(self, p: Player) -> None:
        if not 0 <= self.match_id < 64:
            if self.match_id >= 64:
                # NOTE: this function is unrelated to mp.
                await check_menu_option(p, self.match_id)

            p.enqueue(packets.matchJoinFail())
            return

        if not (m := glob.matches[self.match_id]):
            log(f'{p} tried to join a non-existant mp lobby?')
            p.enqueue(packets.matchJoinFail())
            return
Example #3
0
    def join_match(self, m: Match, passwd: str) -> bool:
        if self.match:
            printlog(f'{self} tried to join multiple matches?')
            self.enqueue(packets.matchJoinFail(m))
            return False

        if m.chat:  # Match already exists, we're simply joining.
            if passwd != m.passwd:  # eff: could add to if? or self.create_m..
                printlog(f'{self} tried to join {m} with incorrect passwd.')
                self.enqueue(packets.matchJoinFail(m))
                return False
            if (slotID := m.get_free()) is None:
                printlog(f'{self} tried to join a full match.')
                self.enqueue(packets.matchJoinFail(m))
                return False
Example #4
0
class MatchJoin(BanchoPacket, type=Packets.OSU_JOIN_MATCH):
    match_id: osuTypes.i32
    match_passwd: osuTypes.string

    async def handle(self, p: Player) -> None:
        if not 0 <= self.match_id < 64:
            if self.match_id >= 64:
                # NOTE: this function is unrelated to mp.
                await check_menu_option(p, self.match_id)

            p.enqueue(packets.matchJoinFail())
            return

        if not (m := glob.matches[self.match_id]):
            log(f'{p} tried to join a non-existant mp lobby?')
            p.enqueue(packets.matchJoinFail())
            return

        if p.silenced:
            p.enqueue(packets.matchJoinFail() + packets.notification(
                'Multiplayer is not available while silenced.'))
            return

        await p.update_latest_activity()
        p.join_match(m, self.match_passwd)
Example #5
0
File: cho.py Project: Mxnuuel/gulag
    async def handle(self, p: Player) -> None:
        if not glob.matches.append(self.match):
            # failed to create match (match slots full).
            await p.send(glob.bot,
                         'Failed to create match (no slots available).')
            p.enqueue(packets.matchJoinFail())
            return

        # create the channel and add it
        # to the global channel list as
        # an instanced channel.
        chan = Channel(name=f'#multi_{self.match.id}',
                       topic=f"MID {self.match.id}'s multiplayer channel.",
                       auto_join=False,
                       instance=True)

        glob.channels.append(chan)
        self.match.chat = chan

        await p.update_latest_activity()
        await p.join_match(self.match, self.match.passwd)
        log(f'{p} created a new multiplayer match.')