예제 #1
0
파일: bancho.py 프로젝트: cmyui/Asahi
async def join_match(user: Player, p: bytes) -> None:
    d = reader.handle_packet(p, (('id', osuTypes.i32), ('pw', osuTypes.string),))
    _id = d['id']
    pw = d['pw']

    if _id >= 1000:
        if not (menu := glob.menus.get(_id)): # TODO: use pw instead of id
            return user.enqueue(writer.matchJoinFail())

        ret = await menu.handle(user)

        # if we don't return a join failure also, its gonna think we are still in lobby
        if isinstance(ret, str): # return string message?
            user.enqueue(
                writer.sendMessage(
                    fromname = glob.bot.name,
                    msg = ret,
                    tarname = user.name,
                    fromid = glob.bot.id
                )
            )

            return user.enqueue(writer.matchJoinFail())

        user.enqueue(writer.matchJoinFail())
        return ret
예제 #2
0
    def join_match(self, match: Match, pw: str) -> None:
        if self.match:
            self.enqueue(writer.matchJoinFail())
            return

        if self is not match.host:
            if pw != match.pw:
                log(f'{self.name} tried to join multiplayer {match.name} with incorrect password', Ansi.LRED)
                self.enqueue(writer.matchJoinFail())
                return

            if not (id := match.next_free()):
                self.enqueue(writer.matchJoinFail())
                return
예제 #3
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)
예제 #4
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.")
예제 #5
0
파일: bancho.py 프로젝트: cmyui/Asahi
            user.enqueue(
                writer.sendMessage(
                    fromname = glob.bot.name,
                    msg = ret,
                    tarname = user.name,
                    fromid = glob.bot.id
                )
            )

            return user.enqueue(writer.matchJoinFail())

        user.enqueue(writer.matchJoinFail())
        return ret

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

    if match.clan_battle and user.clan not in (match.clan_1, match.clan_2) or match.battle_ready:
            return user.enqueue(writer.matchJoinFail())

    user.join_match(match, pw)

    if match.clan_battle:
        total = []
        for slot in match.slots:
            if slot.status & slotStatus.has_player:
                total.append(slot.player)

        battle = glob.clan_battles[user.clan]
        if set(total) == set(battle['total']):
            await match.strat_battle()