Exemple #1
0
async def mp_start(p: Player, m: Match, msg: Sequence[str]) -> str:
    for s in m.slots:
        if s.status & SlotStatus.has_player \
        and not s.status & SlotStatus.no_map:
            s.status = SlotStatus.playing

    m.in_progress = True
    m.enqueue(packets.matchStart(m))
    return 'Good luck!'
Exemple #2
0
class MatchStart(ClientPacket, type=ClientPacketType.MATCH_START):
    async def handle(self, p: Player) -> None:
        if not (m := p.match):
            return

        for s in m.slots:
            if s.status & SlotStatus.ready:
                s.status = SlotStatus.playing

        m.in_progress = True
        m.enqueue(packets.matchStart(m))
Exemple #3
0
    def start(self) -> None:
        no_map: list[Player] = []

        for s in self.slots:
            # start each player who has the map.
            if s.status & SlotStatus.has_player:
                if s.status != SlotStatus.no_map:
                    s.status = SlotStatus.playing
                else:
                    no_map.append(s.player.id)

        self.in_progress = True
        self.enqueue(packets.matchStart(self), immune=no_map)
Exemple #4
0
    m.enqueue(packets.updateMatch(m))


# PacketID: 44
@bancho_packet(Packet.c_matchStart)
def matchStart(p: Player, pr: PacketReader) -> None:
    if not (m := p.match):
        printlog(f'{p} tried starting match outside of a match?')
        return

    for s in m.slots:
        if s.status & SlotStatus.ready:
            s.status = SlotStatus.playing

    m.in_progress = True
    m.enqueue(packets.matchStart(m))


# PacketID: 48
@bancho_packet(Packet.c_matchScoreUpdate)
def matchScoreUpdate(p: Player, pr: PacketReader) -> None:
    if not (m := p.match):
        printlog(f'{p} sent a scoreframe outside of a match?')
        return

    # Read 37 bytes if using scorev2,
    # otherwise only read 29 bytes.
    size = 37 if pr.data[28] else 29
    data = pr.data[:size]
    data[4] = m.get_slot_id(p)