bool ChallengeModeRule::trigger(TriggerEvent event, ServerPlayer *player, QVariant &data) const{ if(event == Death){ static const QString attack = "rebel+renegade"; static const QString defense = "lord+loyalist"; Room *room = player->getRoom(); QStringList alive_roles = room->aliveRoles(player); QString victim_role = player->getRole(); if(attack.contains(victim_role)){ if(!alive_roles.contains("rebel") && !alive_roles.contains("renegade")){ room->gameOver(defense); return true; } }else{ if(!alive_roles.contains("lord") && !alive_roles.contains("loyalist")){ room->gameOver(attack); return true; } } return false; } return GameRule::trigger(event, player, data); }
bool MiniSceneRule::trigger(TriggerEvent event, ServerPlayer *player, QVariant &data) const { Room* room = player->getRoom(); if(event == PhaseChange) { if(player->getPhase()==Player::Start && this->players.first()["beforeNext"] != NULL ) { if(player->tag["playerHasPlayed"].toBool()) room->gameOver(this->players.first()["beforeNext"]); else player->tag["playerHasPlayed"] = true; } if(player->getPhase() != Player::NotActive)return false; if(player->getState() == "robot" || this->players.first()["singleTurn"] == NULL) return false; room->gameOver(this->players.first()["singleTurn"]); } if(player->getRoom()->getTag("WaitForPlayer").toBool()) return true; QList<ServerPlayer*> players = room->getAllPlayers(); while(players.first()->getState() == "robot") players.append(players.takeFirst()); QStringList cards= setup.split(","); foreach(QString id,cards) { room->moveCardTo(Sanguosha->getCard(id.toInt()),NULL,Player::Special,true); room->moveCardTo(Sanguosha->getCard(id.toInt()),NULL,Player::DrawPile,true); room->broadcastInvoke("addHistory","pushPile"); }