Client::Client(QObject *parent, const QString &filename) :QObject(parent), refusable(true), status(NotActive), alive_count(1), nullification_dialog(NULL) { ClientInstance = this; callbacks["checkVersion"] = &Client::checkVersion; callbacks["setup"] = &Client::setup; callbacks["addPlayer"] = &Client::addPlayer; callbacks["removePlayer"] = &Client::removePlayer; callbacks["startInXs"] = &Client::startInXs; callbacks["arrangeSeats"] = &Client::arrangeSeats; callbacks["startGame"] = &Client::startGame; callbacks["hpChange"] = &Client::hpChange; callbacks["playSkillEffect"] = &Client::playSkillEffect; callbacks["closeNullification"] = &Client::closeNullification; callbacks["playCardEffect"] = &Client::playCardEffect; callbacks["clearPile"] = &Client::clearPile; callbacks["setPileNumber"] = &Client::setPileNumber; callbacks["gameOver"] = &Client::gameOver; callbacks["killPlayer"] = &Client::killPlayer; callbacks["gameOverWarn"] = &Client::gameOverWarn; callbacks["showCard"] = &Client::showCard; callbacks["setMark"] = &Client::setMark; callbacks["log"] = &Client::log; callbacks["speak"] = &Client::speak; callbacks["increaseSlashCount"] = &Client::increaseSlashCount; callbacks["attachSkill"] = &Client::attachSkill; callbacks["detachSkill"] = &Client::detachSkill; callbacks["moveFocus"] = &Client::moveFocus; callbacks["setEmotion"] = &Client::setEmotion; callbacks["skillInvoked"] = &Client::skillInvoked; callbacks["acquireSkill"] = &Client::acquireSkill; callbacks["moveNCards"] = &Client::moveNCards; callbacks["moveCard"] = &Client::moveCard; callbacks["drawCards"] = &Client::drawCards; callbacks["drawNCards"] = &Client::drawNCards; // interactive methods callbacks["activate"] = &Client::activate; callbacks["doChooseGeneral"] = &Client::doChooseGeneral; callbacks["doGuanxing"] = &Client::doGuanxing; callbacks["doGongxin"] = &Client::doGongxin; callbacks["askForDiscard"] = &Client::askForDiscard; callbacks["askForSuit"] = &Client::askForSuit; callbacks["askForKingdom"] = &Client::askForKingdom; callbacks["askForSinglePeach"] = &Client::askForSinglePeach; callbacks["askForCardChosen"] = &Client::askForCardChosen; callbacks["askForCard"] = &Client::askForCard; callbacks["askForUseCard"] = &Client::askForUseCard; callbacks["askForSkillInvoke"] = &Client::askForSkillInvoke; callbacks["askForChoice"] = &Client::askForChoice; callbacks["askForNullification"] = &Client::askForNullification; callbacks["askForCardShow"] = &Client::askForCardShow; callbacks["askForPindian"] = &Client::askForPindian; callbacks["askForYiji"] = &Client::askForYiji; callbacks["askForPlayerChosen"] = &Client::askForPlayerChosen; callbacks["fillAG"] = &Client::fillAG; callbacks["askForAG"] = &Client::askForAG; callbacks["takeAG"] = &Client::takeAG; callbacks["clearAG"] = &Client::clearAG; ask_dialog = NULL; use_card = false; Self = new ClientPlayer(this); Self->setScreenName(Config.UserName); Self->setProperty("avatar", Config.UserAvatar); connect(Self, SIGNAL(turn_started()), this, SLOT(clearTurnTag())); connect(Self, SIGNAL(role_changed(QString)), this, SLOT(notifyRoleChange(QString))); if(!filename.isEmpty()){ socket = NULL; recorder = NULL; replayer = new Replayer(this, filename); // connect(replayer, SIGNAL(command_parsed(char*)), this, SLOT(processReply(char*))); connect(replayer, SIGNAL(command_parsed(QString)), this, SLOT(processCommand(QString))); }else{ socket = new NativeClientSocket; socket->setParent(this); connect(socket, SIGNAL(message_got(char*)), this, SLOT(processReply(char*))); connect(socket, SIGNAL(error_message(QString)), this, SIGNAL(error_message(QString))); socket->connectToHost(); recorder = new Recorder(this); connect(socket, SIGNAL(message_got(char*)), recorder, SLOT(record(char*))); replayer = NULL; } }
Client::Client(QObject *parent, const QString &filename) :QObject(parent), refusable(true), status(NotActive), alive_count(1), slash_count(0) { ClientInstance = this; callbacks["checkVersion"] = &Client::checkVersion; callbacks["setup"] = &Client::setup; callbacks["addPlayer"] = &Client::addPlayer; callbacks["removePlayer"] = &Client::removePlayer; callbacks["startInXs"] = &Client::startInXs; callbacks["arrangeSeats"] = &Client::arrangeSeats; callbacks["startGame"] = &Client::startGame; callbacks["hpChange"] = &Client::hpChange; callbacks["clearPile"] = &Client::clearPile; callbacks["setPileNumber"] = &Client::setPileNumber; callbacks["gameOver"] = &Client::gameOver; callbacks["killPlayer"] = &Client::killPlayer; callbacks["revivePlayer"] = &Client::revivePlayer; callbacks["warn"] = &Client::warn; callbacks["showCard"] = &Client::showCard; callbacks["setMark"] = &Client::setMark; callbacks["log"] = &Client::log; callbacks["speak"] = &Client::speak; callbacks["increaseSlashCount"] = &Client::increaseSlashCount; callbacks["attachSkill"] = &Client::attachSkill; callbacks["detachSkill"] = &Client::detachSkill; callbacks["moveFocus"] = &Client::moveFocus; callbacks["setEmotion"] = &Client::setEmotion; callbacks["skillInvoked"] = &Client::skillInvoked; callbacks["acquireSkill"] = &Client::acquireSkill; callbacks["addProhibitSkill"] = &Client::addProhibitSkill; callbacks["animate"] = &Client::animate; callbacks["setPrompt"] = &Client::setPrompt; callbacks["jilei"] = &Client::jilei; callbacks["judgeResult"] = &Client::judgeResult; callbacks["setScreenName"] = &Client::setScreenName; callbacks["setFixedDistance"] = &Client::setFixedDistance; callbacks["pile"] = &Client::pile; callbacks["transfigure"] = &Client::transfigure; callbacks["playSkillEffect"] = &Client::playSkillEffect; callbacks["playCardEffect"] = &Client::playCardEffect; callbacks["playAudio"] = &Client::playAudio; callbacks["moveNCards"] = &Client::moveNCards; callbacks["moveCard"] = &Client::moveCard; callbacks["drawCards"] = &Client::drawCards; callbacks["drawNCards"] = &Client::drawNCards; // interactive methods callbacks["activate"] = &Client::activate; callbacks["doChooseGeneral"] = &Client::doChooseGeneral; callbacks["doChooseGeneral2"] = &Client::doChooseGeneral2; callbacks["doGuanxing"] = &Client::doGuanxing; callbacks["doGongxin"] = &Client::doGongxin; callbacks["askForDiscard"] = &Client::askForDiscard; callbacks["askForExchange"] = &Client::askForExchange; callbacks["askForSuit"] = &Client::askForSuit; callbacks["askForKingdom"] = &Client::askForKingdom; callbacks["askForSinglePeach"] = &Client::askForSinglePeach; callbacks["askForCardChosen"] = &Client::askForCardChosen; callbacks["askForCard"] = &Client::askForCard; callbacks["askForUseCard"] = &Client::askForUseCard; callbacks["askForSkillInvoke"] = &Client::askForSkillInvoke; callbacks["askForChoice"] = &Client::askForChoice; callbacks["askForNullification"] = &Client::askForNullification; callbacks["askForCardShow"] = &Client::askForCardShow; callbacks["askForPindian"] = &Client::askForPindian; callbacks["askForYiji"] = &Client::askForYiji; callbacks["askForPlayerChosen"] = &Client::askForPlayerChosen; callbacks["askForGeneral"] = &Client::askForGeneral; callbacks["fillAG"] = &Client::fillAG; callbacks["askForAG"] = &Client::askForAG; callbacks["takeAG"] = &Client::takeAG; callbacks["clearAG"] = &Client::clearAG; // 3v3 mode & 1v1 mode callbacks["fillGenerals"] = &Client::fillGenerals; callbacks["askForGeneral3v3"] = &Client::askForGeneral3v3; callbacks["askForGeneral1v1"] = &Client::askForGeneral3v3; callbacks["takeGeneral"] = &Client::takeGeneral; callbacks["startArrange"] = &Client::startArrange; callbacks["askForOrder"] = &Client::askForOrder; callbacks["askForDirection"] = &Client::askForDirection; callbacks["recoverGeneral"] = &Client::recoverGeneral; callbacks["revealGeneral"] = &Client::revealGeneral; ask_dialog = NULL; use_card = false; Self = new ClientPlayer(this); Self->setScreenName(Config.UserName); Self->setProperty("avatar", Config.UserAvatar); connect(Self, SIGNAL(phase_changed()), this, SLOT(clearTurnTag())); connect(Self, SIGNAL(role_changed(QString)), this, SLOT(notifyRoleChange(QString))); if(!filename.isEmpty()){ socket = NULL; recorder = NULL; replayer = new Replayer(this, filename); connect(replayer, SIGNAL(command_parsed(QString)), this, SLOT(processCommand(QString))); }else{ socket = new NativeClientSocket; socket->setParent(this); recorder = new Recorder(this); connect(socket, SIGNAL(message_got(char*)), recorder, SLOT(record(char*))); connect(socket, SIGNAL(message_got(char*)), this, SLOT(processReply(char*))); connect(socket, SIGNAL(error_message(QString)), this, SIGNAL(error_message(QString))); connect(socket, SIGNAL(connected()), this, SLOT(signup())); socket->connectToHost(); replayer = NULL; } lines_doc = new QTextDocument(this); prompt_doc = new QTextDocument(this); prompt_doc->setTextWidth(350); prompt_doc->setDefaultFont(QFont("SimHei")); }
Client::Client(QObject *parent, const QString &filename) :QObject(parent), is_discard_action_refusable(true), status(NotActive), alive_count(1), swap_pile(0) { ClientInstance = this; is_game_over = false; callbacks[BP::CheckVersion] = &Client::checkVersion; /*oldcallbacks["roomBegin"] = &Client::roomBegin; oldcallbacks["room"] = &Client::room; oldcallbacks["roomEnd"] = &Client::roomEnd; oldcallbacks["roomCreated"] = &Client::roomCreated; oldcallbacks["roomError"] = &Client::roomError; oldcallbacks["hallEntered"] = &Client::hallEntered;*/ callbacks[BP::Setup] = &Client::setup; callbacks[BP::NetworkDelayTest] = &Client::networkDelayTest; callbacks[BP::AddPlayer] = &Client::addPlayer; callbacks[BP::RemovePlayer] = &Client::removePlayer; callbacks[BP::StartInXSeconds] = &Client::startInXSeconds; callbacks[BP::ArrangeSeats] = &Client::arrangeSeats; callbacks[BP::Warn] = &Client::warn; callbacks[BP::StartGame] = &Client::startGame; callbacks[BP::GameOver] = &Client::gameOver; callbacks[BP::HpChange] = &Client::hpChange; callbacks[BP::KillPlayer] = &Client::killPlayer; callbacks[BP::RevivePlayer] = &Client::revivePlayer; callbacks[BP::AskForCardShow] = &Client::showCard; callbacks[BP::SetMark] = &Client::setMark; callbacks[BP::DoFilter] = &Client::doFilter;//deprecated? callbacks[BP::Log] = &Client::log; callbacks[BP::Speak] = &Client::speak; callbacks[BP::AcquireSkill] = &Client::acquireSkill; callbacks[BP::AttachSkill] = &Client::attachSkill; callbacks[BP::DetachSkill] = &Client::detachSkill; callbacks[BP::MoveFocus] = &Client::moveFocus; callbacks[BP::SetEmotion] = &Client::setEmotion; callbacks[BP::SkillInvoke] = &Client::skillInvoked; callbacks[BP::ShowAllCards] = &Client::askForGongxin; callbacks[BP::AskForGongxin] = &Client::askForGongxin; callbacks[BP::AddHistory] = &Client::addHistory; callbacks[BP::Animate] = &Client::animate; callbacks[BP::JudgeResult] = &Client::judgeResult; callbacks[BP::SetScreenName] = &Client::setScreenName; callbacks[BP::SetFixedDistance] = &Client::setFixedDistance; callbacks[BP::Transfigure] = &Client::transfigure; //callbacks[BP::Jilei] = &Client::jilei; callbacks[BP::CardLock] = &Client::cardLock; callbacks[BP::Pile] = &Client::pile; callbacks[BP::UpdateStateItem] = &Client::updateStateItem; callbacks[BP::PlaySkillEffect] = &Client::playSkillEffect; callbacks[BP::PlayCardEffect] = &Client::playCardEffect; callbacks[BP::PlayAudio] = &Client::playAudio; callbacks[BP::GetCard] = &Client::getCards; callbacks[BP::LoseCard] = &Client::loseCards; callbacks[BP::ClearPile] = &Client::resetPiles; callbacks[BP::SetPileNumber] = &Client::setPileNumber; callbacks[BP::SetStatistics] = &Client::setStatistics; callbacks[BP::SetCardFlag] = &Client::setCardFlag; callbacks[BP::SetPlayerProperty] = &Client::setPlayerProperty; // interactive methods interactions[BP::AskForGeneral] = &Client::askForGeneral; interactions[BP::AskForPlayerChosen] = &Client::askForPlayerChosen; interactions[BP::AskForAssign] = &Client::askForAssign; interactions[BP::AskForDirection] = &Client::askForDirection; interactions[BP::AskForExchange] = &Client::askForExchange; interactions[BP::AskForSingleWine] = &Client::askForSingleWine; interactions[BP::AskForGuanxing] = &Client::askForGuanxing; interactions[BP::AskForGongxin] = &Client::askForGongxin; interactions[BP::AskForYiji] = &Client::askForYiji; interactions[BP::Activate] = &Client::activate; interactions[BP::AskForDiscard] = &Client::askForDiscard; interactions[BP::AskForSuit] = &Client::askForSuit; interactions[BP::AskForKingdom] = &Client::askForKingdom; interactions[BP::AskForCard] = &Client::askForCard; interactions[BP::AskForUseCard] = &Client::askForUseCard; interactions[BP::SkillInvoke] = &Client::askForSkillInvoke; interactions[BP::AskForChoice] = &Client::askForChoice; interactions[BP::AskForNullification] = &Client::askForNullification; interactions[BP::AskForCardShow] = &Client::askForCardShow; interactions[BP::AskForAG] = &Client::askForAG; interactions[BP::AskForPindian] = &Client::askForPindian; interactions[BP::AskForCardChosen] = &Client::askForCardChosen; interactions[BP::AskForOrder] = &Client::askForOrder; interactions[BP::AskForRole3v3] = &Client::askForRole3v3; interactions[BP::AskForSurrender] = &Client::askForSurrender; callbacks[BP::FillAG] = &Client::fillAG; callbacks[BP::TakeAG] = &Client::takeAG; callbacks[BP::ClearAG] = &Client::clearAG; // 3v3 mode & 1v1 mode callbacks[BP::FillGenerals] = &Client::fillGenerals; callbacks[BP::AskForGeneral3v3] = &Client::askForGeneral3v3; callbacks[BP::AskForGeneral1v1] = &Client::askForGeneral3v3; callbacks[BP::TakeGeneral] = &Client::takeGeneral; callbacks[BP::StartArrange] = &Client::startArrange; callbacks[BP::RecoverGeneral] = &Client::recoverGeneral; callbacks[BP::RevealGeneral] = &Client::revealGeneral; m_isUseCard = false; Self = new ClientPlayer(this); Self->setScreenName(Config.UserName); Self->setProperty("avatar", Config.UserAvatar); connect(Self, SIGNAL(phase_changed()), this, SLOT(clearTurnTag())); connect(Self, SIGNAL(role_changed(QString)), this, SLOT(notifyRoleChange(QString))); players << Self; if(!filename.isEmpty()){ socket = NULL; recorder = NULL; replayer = new Replayer(this, filename); connect(replayer, SIGNAL(command_parsed(QString)), this, SLOT(processServerPacket(QString))); }else{ socket = new ClientSocket; socket->setParent(this); socket->listen(); recorder = new Recorder(this); connect(socket, SIGNAL(message_got(QByteArray)), recorder, SLOT(record(QByteArray))); connect(socket, SIGNAL(message_got(QByteArray)), this, SLOT(processServerPacket(QByteArray))); connect(socket, SIGNAL(error_message(QString)), this, SIGNAL(error_message(QString))); socket->connectToHost(); replayer = NULL; } lines_doc = new QTextDocument(this); prompt_doc = new QTextDocument(this); prompt_doc->setTextWidth(350); prompt_doc->setDefaultFont(QFont("SimHei")); }