Skip to content

Commit

Permalink
lirang and bifa's bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ubun committed Feb 5, 2013
1 parent e380657 commit 97eed72
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 23 deletions.
11 changes: 9 additions & 2 deletions lua/ai/sp-ai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,17 @@ sgs.ai_card_intention.YuanhuCard = -30
sgs.ai_skill_use["@@bifa"] = function(self, prompt)
if #self.enemies == 0 then return "." end
self:sort(self.enemies)
local target
for _, p in ipairs(self.enemies) do
if p:getPile("#pencil"):isEmpty() then
target = p
break
end
end
local cards = sgs.QList2Table(self.player:getCards("h"))
self:sortByUseValue(cards, true)
if self:getUseValue(cards[1]) < 5 then
return "@BifaCard=" .. cards[1]:getEffectiveId() .. "->" .. self.enemies[1]:objectName()
if self:getUseValue(cards[1]) < 5 and target then
return "@BifaCard=" .. cards[1]:getEffectiveId() .. "->" .. target:objectName()
end
return "."
end
Expand Down
4 changes: 3 additions & 1 deletion lua/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ scenario = { -- 非身份局模式下的一些设置
},
couple_lord = "caocao", -- 夫妻鞋展:设置主公
couple_spouse = { -- 设置新的夫妻
-- "simayi+guojia",
"simayi+guojia",
"ganfuren+liubei",
"hanxiandi+fushi",
},
}
ban_list = { -- 初始禁表设置
Expand Down
5 changes: 3 additions & 2 deletions src/core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ int Engine::getGeneralCount(bool include_banned) const{
total--;

else if( (ServerInfo.GameMode.endsWith("p") ||
ServerInfo.GameMode.endsWith("pd"))
ServerInfo.GameMode.endsWith("pd") ||
ServerInfo.GameMode.endsWith("pz"))
&& Config.value("Banlist/Roles").toStringList().contains(general->objectName()))
total--;

Expand Down Expand Up @@ -609,7 +610,7 @@ QStringList Engine::getRandomGenerals(int count, const QSet<QString> &ban_set) c
if(Config.EnableHegemony)
general_set = general_set.subtract(Config.value("Banlist/Hegemony", "").toStringList().toSet());

if(ServerInfo.GameMode.endsWith("p") || ServerInfo.GameMode.endsWith("pd"))
if(ServerInfo.GameMode.endsWith("p") || ServerInfo.GameMode.endsWith("pd") || ServerInfo.GameMode.endsWith("pz"))
general_set.subtract(Config.value("Banlist/Roles", "").toStringList().toSet());

all_generals = general_set.subtract(ban_set).toList();
Expand Down
2 changes: 2 additions & 0 deletions src/core/skill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ SPConvertSkill::SPConvertSkill(const QString &name, const QString &from, const Q

bool SPConvertSkill::triggerable(const ServerPlayer *target) const{
if (target == NULL) return false;
if(!ServerInfo.GameMode.endsWith("p") && !ServerInfo.GameMode.endsWith("pd") && !ServerInfo.GameMode.endsWith("pz"))
return false;
QString package = Sanguosha->getGeneral(to)->getPackage();
if(Sanguosha->getBanPackages().contains(package)) return false;
return GameStartSkill::triggerable(target) && target->getGeneralName() == from;
Expand Down
1 change: 1 addition & 0 deletions src/package/hegemony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ class Lirang: public TriggerSkill{
if(card && room->askForUseCard(player, "@@lirang", "@lirang")){
PlayerStar target = player->tag["LirangTarget"].value<PlayerStar>();
target->obtainCard(card);
return true;
}
return false;
}
Expand Down
30 changes: 13 additions & 17 deletions src/scenario/couple-scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class CoupleScenarioRule: public ScenarioRule{
break;
}
//get one wife's multi husband
QStringList cps = scenario->getBoats(scenario->getSpouse(player)->getGeneralName());
ServerPlayer *other = scenario->getSpouse(player);
if(!other)
break;
QStringList cps = scenario->getBoats(other->getGeneralName());
if(cps.length() != 2)
break;
if(cps.contains(player->getGeneralName())){
Expand Down Expand Up @@ -118,11 +121,11 @@ CoupleScenario::CoupleScenario()
rule = new CoupleScenarioRule(this);

map["caopi"] = "zhenji";
//map["guojia"] = "simayi";
map["liubei"] = "sunshangxiang";
map["guojia"] = "simayi";
map["sunshangxiang"] = "liubei";
map["zhugeliang"] = "huangyueying";
map["menghuo"] = "zhurong";
map["zhouyu"] = "xiaoqiao";
map["xiaoqiao"] = "zhouyu";
map["lvbu"] = "diaochan";
map["zhangfei"] = "xiahoujuan";
map["sunjian"] = "wuguotai";
Expand All @@ -133,7 +136,7 @@ CoupleScenario::CoupleScenario()
full_map["dongzhuo"] = "diaochan";
full_map["wolong"] = "huangyueying";
full_map["caozhi"] = "zhenji";
full_map["zhouyu"] = "huanggai";
full_map["huanggai"] = "zhouyu";
}

QMap<QString, QString> CoupleScenario::mappy(QMap<QString, QString> mapr) const{
Expand All @@ -148,19 +151,12 @@ QMap<QString, QString> CoupleScenario::mappy(QMap<QString, QString> mapr) const{
}

QStringList CoupleScenario::getBoats(const QString &name) const{
QStringList results;
QMap<QString, QString> final_map = mappy(full_map);
foreach(QString husband_name, final_map.keys()){
QString wife_name = final_map.value(husband_name, QString());
if(wife_name == name)
results << husband_name;
}
foreach(QString wife_name, final_map.values()){
QString husband_name = final_map.key(QString(), wife_name);
if(husband_name == name)
results << wife_name;
}
return results;
QStringList wife_names = final_map.values(name);
QStringList husband_names = final_map.keys(name);
if(wife_names.length() + husband_names.length() == 2)
return husband_names + wife_names;
return QStringList();
}

void CoupleScenario::marryAll(Room *room) const{
Expand Down
3 changes: 2 additions & 1 deletion src/server/serverplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ QString ServerPlayer::findReasonable(const QStringList &generals, bool no_unreas
if(ban_list.contains(name))continue;
}
if((Config.GameMode.endsWith("p") ||
Config.GameMode.endsWith("pd")))
Config.GameMode.endsWith("pd") ||
Config.GameMode.endsWith("pz")))
{
QStringList ban_list = Config.value("Banlist/Roles").toStringList();

Expand Down

0 comments on commit 97eed72

Please sign in to comment.