本文整理汇总了C++中DummyCard类的典型用法代码示例。如果您正苦于以下问题:C++ DummyCard类的具体用法?C++ DummyCard怎么用?C++ DummyCard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DummyCard类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
virtual const Card *viewAs(const QList<CardItem *> &cards) const{
if(cards.length() != 2)
return NULL;
DummyCard *card = new DummyCard;
card->setSkillName(objectName());
card->addSubcards(cards);
return card;
}
示例3:
virtual const Card *viewAs(const QList<CardItem *> &cards) const{
int x = Self->getMark("BlackArmor");
if(cards.length() != x)
return NULL;
DummyCard *card = new DummyCard;
card->setSkillName(objectName());
card->addSubcards(cards);
return card;
}
示例4: wholeHandCards
void ServerPlayer::throwAllHandCards(){
DummyCard *card = wholeHandCards();
if(card == NULL)
return;
room->throwCard(card);
CardStar card_star = card;
QVariant data = QVariant::fromValue(card_star);
room->getThread()->trigger(CardDiscarded, this, data);
card->deleteLater();
}
示例5: getEquips
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;
}
示例6: isKongcheng
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);
}
示例7: getEquips
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();
}
示例8: onDamaged
virtual void onDamaged(ServerPlayer *target, const DamageStruct &damage) const{
Room *room = target->getRoom();
if (!target->askForSkillInvoke(objectName(), QVariant::fromValue(damage))) return;
room->broadcastSkillInvoke(objectName());
QList<int> card_ids = room->getNCards(4);
room->fillAG(card_ids);
QList<int> to_get, to_throw;
while (true) {
int sum = 0;
foreach (int id, to_get)
sum += Sanguosha->getCard(id)->getNumber();
foreach (int id, card_ids) {
if (sum + Sanguosha->getCard(id)->getNumber() >= 13) {
room->takeAG(NULL, id, false);
card_ids.removeOne(id);
to_throw << id;
}
}
if (card_ids.isEmpty()) break;
int card_id = room->askForAG(target, card_ids, card_ids.length() < 4, objectName());
if (card_id == -1) break;
card_ids.removeOne(card_id);
to_get << card_id;
room->takeAG(target, card_id, false);
if (card_ids.isEmpty()) break;
}
DummyCard *dummy = new DummyCard;
if (!to_get.isEmpty()) {
dummy->addSubcards(to_get);
target->obtainCard(dummy);
}
dummy->clearSubcards();
if (!to_throw.isEmpty() || !card_ids.isEmpty()) {
dummy->addSubcards(to_throw + card_ids);
CardMoveReason reason(CardMoveReason::S_REASON_NATURAL_ENTER, target->objectName(), objectName(), QString());
room->throwCard(dummy, reason, NULL);
}
delete dummy;
room->clearAG();
}
示例9: 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)) {
room->broadcastSkillInvoke(objectName());
DummyCard *dummy = new DummyCard(player->handCards());
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;
}
示例10: 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;
}
}
示例11: 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);
}