void GameRule::onPhaseChange(ServerPlayer *player) const{ Room *room = player->getRoom(); switch(player->getPhase()){ case Player::Start: { if(player->hasFlag("drank")) room->setPlayerFlag(player, "-drank"); break; } case Player::Judge: { QStack<const DelayedTrick *> tricks = player->delayedTricks(); while(!tricks.isEmpty() && player->isAlive()){ const DelayedTrick *trick = tricks.pop(); bool on_effect = room->cardEffect(trick, NULL, player); if(!on_effect) trick->onNullified(player); } break; } case Player::Draw: { player->drawCards(2, false); break; } case Player::Play: { while(player->isAlive()){ CardUseStruct card_use; room->activate(player, card_use); if(card_use.isValid()) room->useCard(card_use); else break; } break; } case Player::Discard:{ int discard_num = player->getHandcardNum() - player->getMaxCards(); if(discard_num > 0) room->askForDiscard(player, discard_num); break; } case Player::Finish: break; case Player::NotActive: return; } }
void GameRule::onPhaseChange(ServerPlayer *player) const{ Room *room = player->getRoom(); switch(player->getPhase()){ case Player::RoundStart:{ break; } case Player::Start: { player->setMark("SlashCount", 0); break; } case Player::Judge: { QList<const DelayedTrick *> tricks = player->delayedTricks(); while(!tricks.isEmpty() && player->isAlive()){ const DelayedTrick *trick = tricks.takeLast(); bool on_effect = room->cardEffect(trick, NULL, player); if(!on_effect) trick->onNullified(player); } break; } case Player::Draw: { QVariant num = 2; if(room->getTag("FirstRound").toBool()){ room->setTag("FirstRound", false); if(room->getMode() == "02_1v1") num = 1; } room->getThread()->trigger(DrawNCards, room, player, num); int n = num.toInt(); if(n > 0) player->drawCards(n, false); break; } case Player::Play: { player->clearHistory(); while(player->isAlive()){ CardUseStruct card_use; room->activate(player, card_use); if(card_use.isValid()){ room->useCard(card_use); }else break; } break; } case Player::Discard:{ while (player->getHandcardNum() > player->getMaxCards()) { int discard_num = player->getHandcardNum() - player->getMaxCards(); if(player->hasFlag("jilei")){ QSet<const Card *> jilei_cards; QList<const Card *> handcards = player->getHandcards(); foreach(const Card *card, handcards){ if(player->isJilei(card)) jilei_cards << card; } if(jilei_cards.size() > player->getMaxCards()){ // show all his cards room->showAllCards(player); DummyCard *dummy_card = new DummyCard; foreach(const Card *card, handcards.toSet() - jilei_cards){ dummy_card->addSubcard(card); } room->throwCard(dummy_card, player); return; } } if(discard_num > 0) { room->askForDiscard(player, "gamerule", discard_num, 1); } } break; }
void GameRule::onPhaseChange(ServerPlayer *player) const{ Room *room = player->getRoom(); switch(player->getPhase()){ case Player::Start: { player->setMark("SlashCount", 0); break; } case Player::Judge: { QStack<const DelayedTrick *> tricks = player->delayedTricks(); while(!tricks.isEmpty() && player->isAlive()){ const DelayedTrick *trick = tricks.pop(); bool on_effect = room->cardEffect(trick, NULL, player); if(!on_effect) trick->onNullified(player); } break; } case Player::Draw: { QVariant num = 2; room->getThread()->trigger(DrawNCards, player, num); int n = num.toInt(); if(n > 0) player->drawCards(n, false); break; } case Player::Play: { while(player->isAlive()){ CardUseStruct card_use; room->activate(player, card_use); if(card_use.isValid()) room->useCard(card_use); else break; } break; } case Player::Discard:{ int discard_num = player->getHandcardNum() - player->getMaxCards(); if(player->hasFlag("jilei")){ QList<const Card *> jilei_cards; QList<const Card *> handcards = player->getHandcards(); foreach(const Card *card, handcards){ if(card->inherits("BasicCard")){ if(player->hasFlag("jileiB")) jilei_cards << card; }else if(card->inherits("EquipCard")){ if(player->hasFlag("jileiE")) jilei_cards << card; }else if(card->inherits("TrickCard")){ if(player->hasFlag("jileiT")) jilei_cards << card; } } if(jilei_cards.length() > player->getMaxCards()){ // show all his cards QStringList handcards_str; foreach(const Card *card, handcards) handcards_str << QString::number(card->getId()); QString gongxin_str = QString("%1!:%2").arg(player->objectName()).arg(handcards_str.join("+")); room->broadcastInvoke("doGongxin", gongxin_str, player); QList<const Card *> other_cards = handcards.toSet().subtract(jilei_cards.toSet()).toList(); foreach(const Card *card, other_cards){ room->throwCard(card); } return; } }
void GameRule::onPhaseChange(ServerPlayer *player) const{ Room *room = player->getRoom(); switch(player->getPhase()){ case Player::RoundStart:{ break; } case Player::Start: { player->setMark("SlashCount", 0); if(room->getMode() == "05_2v3") if(player->isLord() || player->getRole() == "loyalist"){ int card_id = room->drawCard(); room->showCard(player, card_id); room->getThread()->delay(); player->addToPile("Angers", card_id); LogMessage log; log.type = "$Juqi"; log.from = player; log.card_str = QString::number(card_id); room->sendLog(log); if(player->getPile("Angers").length() > 4){ const QList<int> angs = player->getPile("Angers"); room->fillAG(angs, player); int card_id = room->askForAG(player, angs, false, "cbangercollect"); if(card_id < 0) card_id = player->getPile("Angers").first(); room->throwCard(card_id); player->invoke("clearAG"); } } break; } case Player::Judge: { QList<const DelayedTrick *> tricks = player->delayedTricks(); while(!tricks.isEmpty() && player->isAlive()){ const DelayedTrick *trick = tricks.takeLast(); bool on_effect = room->cardEffect(trick, NULL, player); if(!on_effect) trick->onNullified(player); } break; } case Player::Draw: { QVariant num = 2; if(room->getTag("FirstRound").toBool()){ room->setTag("FirstRound", false); if(room->getMode() == "02_1v1") num = 1; } room->getThread()->trigger(DrawNCards, player, num); int n = num.toInt(); if(n > 0) player->drawCards(n, false); room->getThread()->trigger(DrawNCardsDone, player, num); break; } case Player::Play: { player->clearHistory(); while(player->isAlive()){ CardUseStruct card_use; room->activate(player, card_use); if(card_use.isValid()){ room->useCard(card_use); }else break; } break; } case Player::Discard:{ int discard_num = player->getHandcardNum() - player->getMaxCards(); if(player->hasFlag("jilei")){ QSet<const Card *> jilei_cards; QList<const Card *> handcards = player->getHandcards(); foreach(const Card *card, handcards){ if(player->isJilei(card)) jilei_cards << card; } if(jilei_cards.size() > player->getMaxCards()){ // show all his cards room->showAllCards(player); DummyCard *dummy_card = new DummyCard; foreach(const Card *card, handcards.toSet() - jilei_cards){ dummy_card->addSubcard(card); } room->throwCard(dummy_card, player); return; } } if(discard_num > 0) room->askForDiscard(player, "gamerule", discard_num); break; }