示例#1
0
void BattleInput::receiveData(QByteArray inf)
{
    if (inf.isEmpty()) {
        if (paused()) {
            delayedCommands.push_back(inf);
            return;
        }

        /* An empty array means raw Command */
        if (commands.size() > 0) {
            AbstractCommand *command = *commands.begin();
            commands.pop_front();
            command->apply();
            delete command;
            return;
        }
    }

    if (paused() && inf[0] != char(BC::BattleChat) && inf[0] != char(BC::SpectatorChat) && inf[0] != char(BC::ClockStart)
            && inf[0] != char(BC::ClockStop)
            && inf[0] != char(BC::Spectating)) {
        delayedCommands.push_back(inf);
        return;
    }

    DataStream in (&inf, QIODevice::ReadOnly);

    uchar command;
    qint8 player;

    in >> command >> player;

    dealWithCommandInfo(in, command, player);
}
void RegularBattleScene::unpause()
{
    pauseCount -= 1;

    if (pauseCount == 0 && !unpausing) {
        unpausing = true;
        while (commands.size() > 0) {
            AbstractCommand *command = *commands.begin();
            commands.pop_front();
            command->apply();
            delete command;
        }
        unpausing = false;
    }

    baseClass::unpause();
}
示例#3
0
void BattleScene::useCommand()
{
    if (commands.size() > 0) {
        AbstractCommand *command = *commands.begin();

        int val = command->val();

        if (!onPeek(val)) {
            return;
        }

        commands.pop_front();
        command->apply();
        delete command;

        if (replayCount > 0 && misReplayingCommands) {
            replayCount --;

            if (replayCount == 0) {
                misReplayingCommands = false;
            }
        }
    }
}