コード例 #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.')
コード例 #2
0
ファイル: bancho.py プロジェクト: cmyui/Asahi
async def create_match(user: Player, p: bytes) -> None:
    match = (reader.handle_packet(p, (('match', osuTypes.match),)))['match']

    glob.matches[match.id] = match
    if not glob.matches.get(match.id):
        return user.enqueue(writer.matchJoinFail())

    mp_chan = Channel(name='#multiplayer', desc=f'Multiplayer channel for match ID {match.id}', auto=False, perm=False)
    glob.channels[f'#multi_{match.id}'] = mp_chan
    match.chat = mp_chan

    user.join_match(match, match.pw)
    log(f'{user.name} created a new multiplayer lobby.', Ansi.LBLUE)
コード例 #3
0
async def create_match(user: Player, p: bytes) -> None:
    match = (reader.handle_packet(p, (("match", osuTypes.match),)))["match"]

    glob.matches[match.id] = match
    if not glob.matches.get(match.id):
        return user.enqueue(writer.matchJoinFail())

    mp_chan = Channel(
        name="#multiplayer",
        desc=f"Multiplayer channel for match ID {match.id}",
        auto=False,
        perm=False,
    )
    glob.channels[f"#multi_{match.id}"] = mp_chan
    match.chat = mp_chan

    user.join_match(match, match.pw)
    base_info(f"{user.name} created a new multiplayer lobby.")
コード例 #4
0
ファイル: bancho.py プロジェクト: kingdom5500/gulag
def matchCreate(p: Player, pr: PacketReader) -> None:
    m = pr.read(osuTypes.match)[0]

    m.host = p
    p.join_match(m, m.passwd)
    printlog(f'{p} created a new multiplayer match.')
コード例 #5
0
ファイル: bancho.py プロジェクト: kingdom5500/gulag
    p.join_match(m, m.passwd)
    printlog(f'{p} created a new multiplayer match.')


# PacketID: 32
@bancho_packet(Packet.c_joinMatch)
def matchJoin(p: Player, pr: PacketReader) -> None:
    m_id, passwd = pr.read(osuTypes.i32, osuTypes.string)
    if m_id not in range(64):
        return

    if not (m := glob.matches.get_by_id(m_id)):
        printlog(f'{p} tried to join a non-existant mp lobby?')
        return

    p.join_match(m, passwd)


# PacketID: 33
@bancho_packet(Packet.c_partMatch)
def matchPart(p: Player, pr: PacketReader) -> None:
    p.leave_match()


# PacketID: 38
@bancho_packet(Packet.c_matchChangeSlot)
def matchChangeSlot(p: Player, pr: PacketReader) -> None:
    if not (m := p.match):
        printlog(f'{p} tried changing slot outside of a match?')
        return