本文整理汇总了C++中DummyCard::addSubcard方法的典型用法代码示例。如果您正苦于以下问题:C++ DummyCard::addSubcard方法的具体用法?C++ DummyCard::addSubcard怎么用?C++ DummyCard::addSubcard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DummyCard
的用法示例。
在下文中一共展示了DummyCard::addSubcard方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pattern
const Card *Card::Parse(const QString &str){
if(str.startsWith(QChar('@'))){
// skill card
static QRegExp pattern("@(\\w+)=(.+)");
pattern.indexIn(str);
QStringList texts = pattern.capturedTexts();
QString card_name = texts.at(1);
QStringList subcard_ids;
QString subcard_str = texts.at(2);
if(subcard_str != ".")
subcard_ids = subcard_str.split("+");
SkillCard *card = Sanguosha->cloneSkillCard(card_name);
if(card == NULL)
return NULL;
foreach(QString subcard_id, subcard_ids)
card->addSubcard(subcard_id.toInt());
// skill name
QString skill_name = card_name.remove("Card").toLower();
card->setSkillName(skill_name);
return card;
}else if(str.startsWith(QChar('$'))){
QString copy = str;
copy.remove(QChar('$'));
QStringList card_strs = copy.split("+");
DummyCard *dummy = new DummyCard;
foreach(QString card_str, card_strs){
dummy->addSubcard(card_str.toInt());
}
示例2: throwAllEquips
void ServerPlayer::throwAllEquips() {
QList<const Card *> equips = getEquips();
if (equips.isEmpty()) return;
DummyCard *card = new DummyCard;
foreach (const Card *equip, equips) {
if (!isJilei(card))
card->addSubcard(equip);
}
if (card->subcardsLength() > 0)
room->throwCard(card, this);
delete card;
}
示例3: throwAllCards
void ServerPlayer::throwAllCards() {
DummyCard *card = isKongcheng() ? new DummyCard : wholeHandCards();
QList<const Card *> equips = getEquips();
foreach (const Card *equip, equips)
card->addSubcard(equip);
if (card->subcardsLength() != 0)
room->throwCard(card, this);
delete card;
QList<const Card *> tricks = getJudgingArea();
foreach (const Card *trick, tricks) {
CardMoveReason reason(CardMoveReason::S_REASON_THROW, this->objectName());
room->throwCard(trick, reason, NULL);
}
示例4: trigger
virtual bool trigger(TriggerEvent, Room *room, ServerPlayer *caopi, QVariant &data) const{
DeathStruct death = data.value<DeathStruct>();
ServerPlayer *player = death.who;
if (player->isNude() || caopi == player)
return false;
if (caopi->isAlive() && room->askForSkillInvoke(caopi, objectName(), data)) {
bool isCaoCao = player->getGeneralName().contains("caocao");
room->broadcastSkillInvoke(objectName(), (isCaoCao ? 3 : (player->isMale() ? 1 : 2)));
DummyCard *dummy = new DummyCard;
QList <const Card *> handcards = player->getHandcards();
foreach (const Card *card, handcards)
dummy->addSubcard(card);
QList <const Card *> equips = player->getEquips();
foreach (const Card *card, equips)
dummy->addSubcard(card);
if (dummy->subcardsLength() > 0) {
CardMoveReason reason(CardMoveReason::S_REASON_RECYCLE, caopi->objectName());
room->obtainCard(caopi, dummy, reason, false);
}
delete dummy;
}
示例5: throwAllEquips
void ServerPlayer::throwAllEquips(){
QList<const Card *> equips = getEquips();
if(equips.isEmpty())
return;
DummyCard *card = new DummyCard;
foreach(const Card *equip, equips)
card->addSubcard(equip);
room->throwCard(card);
CardStar card_star = card;
QVariant data = QVariant::fromValue(card_star);
room->getThread()->trigger(CardDiscarded, this, data);
card->deleteLater();
}
示例6: onPhaseChange
virtual bool onPhaseChange(ServerPlayer *target) const{
Room *room = target->getRoom();
if (target->getPhase() == Player::Finish && target->isWounded() && target->askForSkillInvoke(objectName())) {
room->broadcastSkillInvoke(objectName(), 1);
QStringList draw_num;
for (int i = 1; i <= target->getLostHp(); draw_num << QString::number(i++)) {}
int num = room->askForChoice(target, "miji_draw", draw_num.join("+")).toInt();
target->drawCards(num, objectName());
if (!target->isKongcheng()) {
int n = 0;
forever {
int original_handcardnum = target->getHandcardNum();
if (n < num && !target->isKongcheng()) {
QList<int> handcards = target->handCards();
if (!room->askForYiji(target, handcards, objectName(), false, false, false, num - n))
break;
n += original_handcardnum - target->getHandcardNum();
} else {
break;
}
}
// give the rest cards randomly
if (n < num && !target->isKongcheng()) {
int rest_num = num - n;
forever {
QList<int> handcard_list = target->handCards();
qShuffle(handcard_list);
int give = qrand() % rest_num + 1;
rest_num -= give;
QList<int> to_give = handcard_list.length() < give ? handcard_list : handcard_list.mid(0, give);
ServerPlayer *receiver = room->getOtherPlayers(target).at(qrand() % (target->aliveCount() - 1));
DummyCard *dummy = new DummyCard;
foreach (int id, to_give)
dummy->addSubcard(id);
room->obtainCard(receiver, dummy, false);
delete dummy;
if (rest_num == 0 || target->isKongcheng())
break;
}
}
示例7: onPhaseChange
bool onPhaseChange(ServerPlayer *player) const
{
if (player->getPhase() == Player::Start) {
Room *room = player->getRoom();
player->setMark("juao", 0);
LogMessage log;
log.type = "#JuaoObtain";
log.from = player;
log.arg = objectName();
room->sendLog(log);
DummyCard *dummy = new DummyCard;
foreach (int card_id, player->getPile("hautain")) {
dummy->addSubcard(card_id);
}
player->obtainCard(dummy, false);
delete dummy;
player->skip(Player::Draw);
}