Permalink
Browse files

Merge branch 'master' of https://github.com/Moligaloo/QSanguosha

  • Loading branch information...
2 parents 604201b + 8f6a7a7 commit c641809a68eddb5e7a88557d6282faf42ff27c18 @ubun ubun committed Jun 10, 2012
View
Binary file not shown.
View
@@ -195,7 +195,14 @@ sgs.ai_skill_use_func.DaheCard=function(card,use,self)
for _, enemy in ipairs(self.enemies) do
if not (enemy:hasSkill("kongcheng") and enemy:getHandcardNum() == 1 and enemy:getHp() > self.player:getHp())
and not enemy:isKongcheng() and self.player:canSlash(enemy, true) then
- if max_point > 10 then
+ local enemy_max_card = self:getMaxCard(enemy)
+ local allknown = 0
+ if self:getKnownNum(enemy) == enemy:getHandcardNum() then
+ allknown = allknown + 1
+ end
+ if (enemy_max_card and max_point > enemy_max_card:getNumber() and allknown > 0)
+ or (enemy_max_card and max_point > enemy_max_card:getNumber() and allknown < 1 and max_point > 10)
+ or (not enemy_max_card and max_point > 10) then
use.card = sgs.Card_Parse("@DaheCard=" .. max_card:getId())
if use.to then use.to:append(enemy) end
return
View
@@ -598,7 +598,7 @@ qixi_skill.getTurnUseCard=function(self,inclusive)
local has_weapon=false
for _,card in ipairs(cards) do
- if card:inherits("Weapon") and card:isRed() then has_weapon=true end
+ if card:inherits("Weapon") and card:isBlack() then has_weapon=true end
end
for _,card in ipairs(cards) do
View
@@ -246,18 +246,9 @@ sgs.ai_card_intention.XuanhuoCard = -30
sgs.ai_chaofeng.fazheng = -3
-function sgs.ai_skill_invoke.xuanfeng(self, data)
- local enemynum = 0
- for _, enemy in ipairs(self.enemies) do
- if not self:needKongcheng(enemy) then
- enemynum = enemynum + 1
- end
- end
- return enemynum > 0
-end
sgs.ai_skill_choice.xuanfeng = function(self, choices)
- return "discard"
+ return "first"
end
sgs.ai_skill_playerchosen.xuanfeng = function(self, targets)
View
@@ -11,7 +11,7 @@ GongxinCard::GongxinCard(){
}
bool GongxinCard::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{
- return targets.isEmpty() && !to_select->isKongcheng();
+ return targets.isEmpty() && !to_select->isKongcheng() && to_select != Self ;
}
void GongxinCard::onEffect(const CardEffectStruct &effect) const{
@@ -512,7 +512,7 @@ WuqianCard::WuqianCard(){
}
bool WuqianCard::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{
- return targets.isEmpty();
+ return targets.isEmpty() && to_select != Self ;
}
void WuqianCard::onEffect(const CardEffectStruct &effect) const{
@@ -326,7 +326,7 @@ void BawangCard::onEffect(const CardEffectStruct &effect) const{
class BawangViewAsSkill: public ZeroCardViewAsSkill{
public:
- BawangViewAsSkill():ZeroCardViewAsSkill("tuxi"){
+ BawangViewAsSkill():ZeroCardViewAsSkill("bawang"){
}
virtual const Card *viewAs() const{
@@ -43,7 +43,7 @@ class Yizhong: public TriggerSkill{
class Luoying: public TriggerSkill{
public:
Luoying():TriggerSkill("luoying"){
- events << CardDiscarded << CardUsed << FinishJudge;
+ events << CardGotOnePiece << FinishJudge;
frequency = Frequent;
default_choice = "no";
}
@@ -56,66 +56,31 @@ class Luoying: public TriggerSkill{
return ! target->hasSkill(objectName());
}
- QList<const Card *> getClubs(const Card *card) const{
- QList<const Card *> clubs;
-
- if(!card->isVirtualCard()){
- if(card->getSuit() == Card::Club)
- clubs << card;
-
- return clubs;
- }
-
- foreach(int card_id, card->getSubcards()){
- const Card *c = Sanguosha->getCard(card_id);
- if(c->getSuit() == Card::Club)
- clubs << c;
- }
-
- return clubs;
- }
-
virtual bool trigger(TriggerEvent event, Room* room, ServerPlayer *player, QVariant &data) const{
- QList<const Card *> clubs;
-
- if(event == CardUsed){
- CardUseStruct use = data.value<CardUseStruct>();
- const SkillCard *skill_card = qobject_cast<const SkillCard *>(use.card);
- if(skill_card &&
- skill_card->subcardsLength() > 0 &&
- skill_card->willThrow() &&
- !skill_card->isOwnerDiscarded()){
- clubs = getClubs(skill_card);
- }
- }else if(event == CardDiscarded){
- const Card *card = data.value<CardStar>();
- clubs = getClubs(card);
- }else if(event == FinishJudge){
+ ServerPlayer *caozhi = room->findPlayerBySkillName(objectName());
+ if(event == FinishJudge){
JudgeStar judge = data.value<JudgeStar>();
if(room->getCardPlace(judge->card->getEffectiveId()) == Player::DiscardPile
&& judge->card->getSuit() == Card::Club)
- clubs << judge->card;
+ caozhi->obtainCard(judge->card);
}
-
- ServerPlayer *caozhi = room->findPlayerBySkillName(objectName());
- foreach(const Card* card, clubs)
- if(card->objectName() == "shit")
- if(caozhi && room->askForChoice(caozhi, objectName(), "yes+no") == "no")
- clubs.removeOne(card);
-
- if(clubs.isEmpty())
- return false;
-
- if(caozhi && caozhi->askForSkillInvoke(objectName(), data)){
- if(player->getGeneralName() == "zhenji")
- room->playSkillEffect("luoying", 2);
- else
- room->playSkillEffect("luoying", 1);
-
- foreach(const Card *club, clubs)
- caozhi->obtainCard(club);
+ else if(event == CardGotOnePiece){
+ CardMoveStar move = data.value<CardMoveStar>();
+ if(move->to_place == Player::DiscardPile &&
+ (move->reason.m_reason & CardMoveReason::S_MASK_BASIC_REASON) == CardMoveReason::S_REASON_DISCARD){
+ if(Sanguosha->getCard(move->card_id)->getSuit() == Card::Club && caozhi &&
+ room->getCardPlace(move->card_id) == Player::DiscardPile && caozhi->askForSkillInvoke(objectName(), data)){
+ if(Sanguosha->getCard(move->card_id)->objectName() == "shit")
+ if(caozhi && room->askForChoice(caozhi, objectName(), "yes+no") == "no")
+ return false;
+ if(player->getGeneralName() == "zhenji")
+ room->playSkillEffect("luoying", 2);
+ else
+ room->playSkillEffect("luoying", 1);
+ caozhi->obtainCard(Sanguosha->getCard(move->card_id));
+ }
+ }
}
-
return false;
}
};
@@ -471,10 +436,55 @@ class Huilei: public TriggerSkill{
}
};
+XuanfengCard::XuanfengCard(){
+}
+
+bool XuanfengCard::targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const{
+ if(targets.length() >= 2)
+ return false;
+
+ if(to_select == Self)
+ return false;
+
+ return true;
+}
+
+bool XuanfengCard::targetsFeasible(const QList<const Player *> &targets, const Player *) const{
+ return targets.length() == 2;
+}
+
+void XuanfengCard::onEffect(const CardEffectStruct &effect) const{
+ Room *room = effect.from->getRoom();
+ if(!effect.to->isNude()){
+ int card_id = room->askForCardChosen(effect.from, effect.to, "he", "xuanfeng");
+ room->throwCard(card_id, effect.to);
+ }
+}
+
+class XuanfengViewAsSkill: public ZeroCardViewAsSkill{
+public:
+ XuanfengViewAsSkill():ZeroCardViewAsSkill("xuanfeng"){
+ }
+
+ virtual const Card *viewAs() const{
+ return new XuanfengCard;
+ }
+
+protected:
+ virtual bool isEnabledAtPlay(const Player *player) const{
+ return false;
+ }
+
+ virtual bool isEnabledAtResponse(const Player *player, const QString &pattern) const{
+ return pattern == "@@xuanfeng";
+ }
+};
+
class Xuanfeng: public TriggerSkill{
public:
Xuanfeng():TriggerSkill("xuanfeng"){
events << CardLostOnePiece << CardLostOneTime << PhaseChange;
+ view_as_skill = new XuanfengViewAsSkill;
}
virtual QString getDefaultChoice(ServerPlayer *) const{
@@ -502,33 +512,42 @@ class Xuanfeng: public TriggerSkill{
{
lingtong->tag.remove("InvokeXuanfeng");
Room *room = lingtong->getRoom();
- QString choice = room->askForChoice(lingtong, objectName(), "discard+nothing");
-
-
- if(choice == "discard")
- {
- room->playSkillEffect(objectName());
- QList<ServerPlayer *> targets;
- foreach(ServerPlayer *target, room->getOtherPlayers(lingtong)){
- if(!target->isNude())
- targets << target;
+ bool can_invoke = false;
+ QList<ServerPlayer *> other_players = room->getOtherPlayers(lingtong);
+ foreach(ServerPlayer *player, other_players){
+ if(!player->isNude()){
+ can_invoke = true;
+ break;
}
-
- ServerPlayer *first = room->askForPlayerChosen(lingtong, targets, "xuanfeng");
- ServerPlayer *second = NULL;
- int first_id = -1;
- int second_id = -1;
- if(first != NULL){
- first_id = room->askForCardChosen(lingtong, first, "he", "xuanfeng");
- room->throwCard(first_id, first);
- if(first->isNude())
- targets.removeOne(first);
+ }
+ QStringList choicelist;
+ if(can_invoke){
+ choicelist << "first";
+ if (room->getOtherPlayers(lingtong).length() > 1)
+ choicelist << "second";
+ choicelist << "nothing";
+ QString choice = room->askForChoice(lingtong, objectName(), choicelist.join("+"));
+
+ if(choice == "first")
+ {
+ room->playSkillEffect(objectName());
+ QList<ServerPlayer *> targets;
+ foreach(ServerPlayer *target, room->getOtherPlayers(lingtong)){
+ if(!target->isNude())
+ targets << target;
+ }
+
+ ServerPlayer *target = room->askForPlayerChosen(lingtong, targets, "xuanfeng");
+ int card_id = room->askForCardChosen(lingtong, target, "he", "xuanfeng");
+ room->throwCard(card_id, target);
+
+ if(!target->isNude()){
+ card_id = room->askForCardChosen(lingtong, target, "he", "xuanfeng");
+ room->throwCard(card_id, target);
+ }
}
- if(room->askForSkillInvoke(lingtong, objectName()))
- second = room->askForPlayerChosen(lingtong, targets, "xuanfeng");
- if(second != NULL){
- second_id = room->askForCardChosen(lingtong, second, "he", "xuanfeng");
- room->throwCard(second_id, second);
+ else if(choice == "second"){
+ room->askForUseCard(lingtong, "@@xuanfeng", "@xuanfeng-card");
}
}
}
@@ -1165,6 +1184,7 @@ YJCMPackage::YJCMPackage():Package("YJCM"){
addMetaObject<GanluCard>();
addMetaObject<XianzhenCard>();
addMetaObject<XianzhenSlashCard>();
+ addMetaObject<XuanfengCard>();
addMetaObject<XuanhuoCard>();
addMetaObject<XinzhanCard>();
addMetaObject<JujianCard>();
View
@@ -51,6 +51,16 @@ class XianzhenCard: public SkillCard{
virtual void onEffect(const CardEffectStruct &effect) const;
};
+class XuanfengCard: public SkillCard{
+ Q_OBJECT
+
+public:
+ Q_INVOKABLE XuanfengCard();
+ virtual bool targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const;
+ virtual bool targetsFeasible(const QList<const Player *> &targets, const Player *Self) const;
+ virtual void onEffect(const CardEffectStruct &effect) const;
+};
+
class JujianCard: public SkillCard{
Q_OBJECT
View
@@ -3011,7 +3011,8 @@ void Room::moveCardsAtomic(QList<CardsMoveStruct> cards_moves, bool forceMoveVis
moveOneTimeStruct.to_place = cards_move.to_place;
CardsMoveOneTimeStar lose_star = &moveOneTimeStruct;
QVariant data = QVariant::fromValue(lose_star);
- thread->trigger(CardLostOneTime, this, (ServerPlayer*)lose_star->from, data);
+ if(lose_star->from)
+ thread->trigger(CardLostOneTime, this, (ServerPlayer*)lose_star->from, data);
}
if (cards_move.countAsOneTime) moveOneTimeStruct = CardsMoveOneTimeStruct();
}
@@ -3028,6 +3029,12 @@ void Room::moveCardsAtomic(QList<CardsMoveStruct> cards_moves, bool forceMoveVis
QVariant data = QVariant::fromValue(move_star);
thread->trigger(CardGotOnePiece, this, (ServerPlayer*)cards_move.to, data);
}
+ else if(cards_move.to_place == Player::DiscardPile){
+ CardMoveStar move_star = &moves[j];
+ QVariant data = QVariant::fromValue(move_star);
+ if(cards_move.from)
+ thread->trigger(CardGotOnePiece, this, (ServerPlayer*)cards_move.from, data);
+ }
}
moveOneTimeStruct.card_ids.append(cards_move.card_ids);
for (int i = 0; i < cards_move.card_ids.size(); i++)
@@ -3037,7 +3044,8 @@ void Room::moveCardsAtomic(QList<CardsMoveStruct> cards_moves, bool forceMoveVis
moveOneTimeStruct.to_place = cards_move.to_place;
CardsMoveOneTimeStar move_star = &moveOneTimeStruct;
QVariant data = QVariant::fromValue(move_star);
- thread->trigger(CardGotOneTime, this, (ServerPlayer*)cards_move.to, data);
+ if(cards_move.to)
+ thread->trigger(CardGotOneTime, this, (ServerPlayer*)cards_move.to, data);
}
if (cards_move.countAsOneTime) moveOneTimeStruct = CardsMoveOneTimeStruct();
}
@@ -3147,7 +3155,8 @@ void Room::_moveCards(QList<CardsMoveStruct> cards_moves, bool forceMoveVisible,
moveOneTimeStruct.to_place = cards_move.to_place;
CardsMoveOneTimeStar lose_star = &moveOneTimeStruct;
QVariant data = QVariant::fromValue(lose_star);
- thread->trigger(CardLostOneTime, this, (ServerPlayer*)lose_star->from, data);
+ if(lose_star->from)
+ thread->trigger(CardLostOneTime, this, (ServerPlayer*)lose_star->from, data);
}
if (cards_move.countAsOneTime) moveOneTimeStruct = CardsMoveOneTimeStruct();
}
@@ -3213,6 +3222,12 @@ void Room::_moveCards(QList<CardsMoveStruct> cards_moves, bool forceMoveVisible,
QVariant data = QVariant::fromValue(move_star);
thread->trigger(CardGotOnePiece, this, (ServerPlayer*)cards_move.to, data);
}
+ else if(cards_move.to_place == Player::DiscardPile){
+ CardMoveStar move_star = &moves[j];
+ QVariant data = QVariant::fromValue(move_star);
+ if(cards_move.from)
+ thread->trigger(CardGotOnePiece, this, (ServerPlayer*)cards_move.from, data);
+ }
Sanguosha->getCard(card_id)->onMove(moves[j]);
}
moveOneTimeStruct.card_ids.append(cards_move.card_ids);
@@ -3223,7 +3238,8 @@ void Room::_moveCards(QList<CardsMoveStruct> cards_moves, bool forceMoveVisible,
moveOneTimeStruct.to_place = cards_move.to_place;
CardsMoveOneTimeStar move_star = &moveOneTimeStruct;
QVariant data = QVariant::fromValue(move_star);
- thread->trigger(CardGotOneTime, this, (ServerPlayer*)cards_move.to, data);
+ if(cards_move.to)
+ thread->trigger(CardGotOneTime, this, (ServerPlayer*)cards_move.to, data);
}
if (cards_move.countAsOneTime) moveOneTimeStruct = CardsMoveOneTimeStruct();
}

0 comments on commit c641809

Please sign in to comment.