Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
retrieve ai for old YJCM generals
  • Loading branch information
clarkcyt committed Apr 30, 2012
1 parent 527c32d commit 4783fbf
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lang/zh_CN/FirePackage.lua
Expand Up @@ -21,7 +21,7 @@ return {
[":qiangxi"] = "出牌阶段,你可以失去1点体力或弃置一张武器牌,并对你攻击范围内的一名角色造成1点伤害。每阶段限一次",

["#wolong"] = "卧龙",
["wolong"] = "诸葛亮",
["wolong"] = "小诸葛",
["bazhen"] = "八阵",
[":bazhen"] = "<b>锁定技</b>,若你的装备区没有防具牌,视为你装备着【八卦阵】\
★装备任何防具都会失去“八阵”的效果",
Expand Down
4 changes: 2 additions & 2 deletions lang/zh_CN/SPPackage.lua
Expand Up @@ -95,10 +95,10 @@ return {
["Hulaopass"] = "虎牢关模式",

["#shenlvbu1"] = "最强神话",
["shenlvbu1"] = "神吕布(1)",
["shenlvbu1"] = "虎牢关吕布",
["illustrator:shenlvbu1"] = "LiuHeng",
["#shenlvbu2"] = "暴怒的战神",
["shenlvbu2"] = "神吕布(2)",
["shenlvbu2"] = "虎牢关吕布",
["illustrator:shenlvbu2"] = "LiuHeng",
["xiuluo"] = "修罗",
[":xiuluo"] = "回合开始阶段,你可以弃置一张手牌来将你判定区里的一张延时类锦囊置入弃牌堆(必须花色相同)。",
Expand Down
36 changes: 18 additions & 18 deletions lua/ai/maneuvering-ai.lua
Expand Up @@ -264,28 +264,28 @@ function SmartAI:useCardIronChain(card, use)
table.insert(enemytargets, enemy)
end
end

if #friendtargets > 1 then
if use.to then use.to:append(friendtargets[1]) end
if use.to then use.to:append(friendtargets[2]) end
elseif #friendtargets == 1 then
if #enemytargets > 0 then
if use.to then use.to:append(friendtargets[1]) end
if use.to then use.to:append(enemytargets[1]) end
elseif yangxiu and self:isFriend(yangxiu) then
if not self.player:hasSkill("nos_wuyan") then
if #friendtargets > 1 then
if use.to then use.to:append(friendtargets[1]) end
if use.to then use.to:append(yangxiu) end
end
elseif #enemytargets > 1 then
if use.to then use.to:append(enemytargets[1]) end
if use.to then use.to:append(enemytargets[2]) end
elseif #friendtargets == 1 then
if yangxiu and self:isFriend(yangxiu) then
if use.to then use.to:append(friendtargets[2]) end
elseif #friendtargets == 1 then
if #enemytargets > 0 then
if use.to then use.to:append(friendtargets[1]) end
if use.to then use.to:append(enemytargets[1]) end
elseif yangxiu and self:isFriend(yangxiu) then
if use.to then use.to:append(friendtargets[1]) end
if use.to then use.to:append(yangxiu) end
end
elseif #enemytargets > 1 then
if use.to then use.to:append(enemytargets[1]) end
if use.to then use.to:append(yangxiu) end
if use.to then use.to:append(enemytargets[2]) end
elseif #friendtargets == 1 then
if yangxiu and self:isFriend(yangxiu) then
if use.to then use.to:append(enemytargets[1]) end
if use.to then use.to:append(yangxiu) end
end
end
end

if use.to then assert(use.to:length() < 3) end
end

Expand Down
196 changes: 195 additions & 1 deletion lua/ai/nostalgia-ai.lua
@@ -1,2 +1,196 @@
sgs.weapon_range.MoonSpear = 3
sgs.ai_use_priority.MoonSpear = 2.635
sgs.ai_use_priority.MoonSpear = 2.635

nos_jujian_skill={}
nos_jujian_skill.name="nos_jujian"
table.insert(sgs.ai_skills,nos_jujian_skill)
nos_jujian_skill.getTurnUseCard=function(self)
if not self.player:hasUsed("NosJujianCard") then return sgs.Card_Parse("@NosJujianCard=.") end
end

sgs.ai_skill_use_func.NosJujianCard = function(card, use, self)
local abandon_handcard = {}
local index = 0
local hasPeach = (self:getCardsNum("Peach") > 0)

local trick_num, basic_num, equip_num = 0, 0, 0
if not hasPeach and self.player:isWounded() and self.player:getHandcardNum() >=3 then
local cards = self.player:getHandcards()
cards=sgs.QList2Table(cards)
self:sortByUseValue(cards, true)
for _, card in ipairs(cards) do
if card:getTypeId() == sgs.Card_Trick and not card:inherits("ExNihilo") then trick_num = trick_num + 1
elseif card:getTypeId() == sgs.Card_Basic then basic_num = basic_num + 1
elseif card:getTypeId() == sgs.Card_Equip then equip_num = equip_num + 1
end
end
local result_class
if trick_num >= 3 then result_class = "TrickCard"
elseif equip_num >= 3 then result_class = "EquipCard"
elseif basic_num >= 3 then result_class = "BasicCard"
end
local f
for _, friend in ipairs(self.friends_noself) do
if (friend:getHandcardNum()<2) or (friend:getHandcardNum()<friend:getHp()+1) and not friend:hasSkill("manjuan") then
for _, fcard in ipairs(cards) do
if fcard:inherits(result_class) and not fcard:inherits("ExNihilo") then
table.insert(abandon_handcard, fcard:getId())
index = index + 1
end
if index == 3 then f = friend break end
end
end
end
if index == 3 then
if use.to then use.to:append(f) end
use.card = sgs.Card_Parse("@NosJujianCard=" .. table.concat(abandon_handcard, "+"))
return
end
end
abandon_handcard = {}
local cards = self.player:getHandcards()
cards=sgs.QList2Table(cards)
self:sortByUseValue(cards, true)
local slash_num = self:getCardsNum("Slash")
local jink_num = self:getCardsNum("Jink")
for _, friend in ipairs(self.friends_noself) do
if (friend:getHandcardNum()<2) or (friend:getHandcardNum()<friend:getHp()+1) or self.player:isWounded() then
for _, card in ipairs(cards) do
if #abandon_handcard >= 3 then break end
if not card:inherits("Nullification") and not card:inherits("EquipCard") and
not card:inherits("Peach") and not card:inherits("Jink") and
not card:inherits("Indulgence") and not card:inherits("SupplyShortage") then
table.insert(abandon_handcard, card:getId())
index = 5
elseif card:inherits("Slash") and slash_num > 1 then
if (self.player:getWeapon() and not self.player:getWeapon():objectName()=="crossbow") or
not self.player:getWeapon() then
table.insert(abandon_handcard, card:getId())
index = 5
slash_num = slash_num - 1
end
elseif card:inherits("Jink") and jink_num > 1 then
table.insert(abandon_handcard, card:getId())
index = 5
jink_num = jink_num - 1
end
end
if index == 5 then
use.card = sgs.Card_Parse("@NosJujianCard=" .. table.concat(abandon_handcard, "+"))
if use.to then use.to:append(friend) end
return
end
end
end
if #self.friends_noself>0 and self:getOverflow()>0 then
self:sort(self.friends_noself, "handcard")
local discard = self:askForDiscard("gamerule", math.min(self:getOverflow(),3))
use.card = sgs.Card_Parse("@NosJujianCard=" .. table.concat(discard, "+"))
if use.to then use.to:append(self.friends_noself[1]) end
return
end
end

sgs.ai_use_priority.NosJujianCard = 4.5
sgs.ai_use_value.NosJujianCard = 6.7

sgs.ai_card_intention.NosJujianCard = -100

sgs.dynamic_value.benefit.NosJujianCard = true

sgs.ai_skill_cardask["@enyuanheart"] = function(self)
local cards = self.player:getHandcards()
for _, card in sgs.qlist(cards) do
if card:getSuit() == sgs.Card_Heart and not (card:inherits("Peach") or card:inherits("ExNihilo")) then
return card:getEffectiveId()
end
end
return "."
end

function sgs.ai_slash_prohibit.nos_enyuan(self)
if self:isWeak() then return true end
end

nos_xuanhuo_skill={}
nos_xuanhuo_skill.name="nos_xuanhuo"
table.insert(sgs.ai_skills,nos_xuanhuo_skill)
nos_xuanhuo_skill.getTurnUseCard=function(self)
if not self.player:hasUsed("NosXuanhuoCard") then
return sgs.Card_Parse("@NosXuanhuoCard=.")
end
end

sgs.ai_skill_use_func.NosXuanhuoCard = function(card, use, self)
local cards = self.player:getHandcards()
cards=sgs.QList2Table(cards)
self:sortByUseValue(cards,true)

local target
for _, friend in ipairs(self.friends_noself) do
if self:hasSkills(sgs.lose_equip_skill, friend) and not friend:getEquips():isEmpty() then
for _, card in ipairs(cards) do
if card:getSuit() == sgs.Card_Heart and self.player:getHandcardNum() > 1 then
use.card = sgs.Card_Parse("@NosXuanhuoCard=" .. card:getEffectiveId())
target = friend
break
end
end
end
if target then break end
end
if not target then
for _, enemy in ipairs(self.enemies) do
if not enemy:isKongcheng() then
for _, card in ipairs(cards)do
if card:getSuit() == sgs.Card_Heart and not card:inherits("Peach") and self.player:getHandcardNum() > 1 then
use.card = sgs.Card_Parse("@NosXuanhuoCard=" .. card:getEffectiveId())
target = enemy
break
end
end
end
if target then break end
end
end

if target then
self.room:setPlayerFlag(target, "xuanhuo_target")
if use.to then
use.to:append(target)
end
end
end

sgs.ai_skill_playerchosen.nos_xuanhuo = function(self, targets)
for _, player in sgs.qlist(targets) do
if (player:getHandcardNum() <= 2 or player:getHp() < 2) and self:isFriend(player)
and not player:hasFlag("xuanhuo_target") and not self:needKongcheng(player) and not player:hasSkill("manjuan") then
return player
end
end
end

sgs.nos_fazheng_suit_value =
{
heart = 3.9
}

sgs.ai_chaofeng.nos_fazheng = -3

sgs.ai_skill_choice.nos_xuanfeng = function(self, choices)
self:sort(self.enemies, "defense")
local slash = sgs.Card_Parse(("slash[%s:%s]"):format(sgs.Card_NoSuit, 0))
for _, enemy in ipairs(self.enemies) do
if self.player:distanceTo(enemy)<=1 then
return "damage"
elseif not self:slashProhibit(slash ,enemy) then
return "slash"
end
end
return "nothing"
end

sgs.ai_skill_playerchosen.nos_xuanfeng_damage = sgs.ai_skill_playerchosen.damage

sgs.ai_skill_playerchosen.nos_xuanfeng_slash = sgs.ai_skill_playerchosen.zero_card_as_slash
21 changes: 19 additions & 2 deletions lua/ai/smart-ai.lua
Expand Up @@ -70,7 +70,7 @@ function setInitialTables()
sgs.target = {loyalist = nil, rebel = nil, renegade = nil } -- obsolete
sgs.discard_pile = global_room:getDiscardPile()
sgs.draw_pile = global_room:getDrawPile()
sgs.lose_equip_skill = "xiaoji|xuanfeng"
sgs.lose_equip_skill = "xiaoji|xuanfeng|nos_xuanfeng"
sgs.need_kongcheng = "lianying|kongcheng"
sgs.masochism_skill = "fankui|jieming|yiji|ganglie|enyuan|fangzhu|guixin"
sgs.wizard_skill = "guicai|guidao|jilve|tiandu"
Expand Down Expand Up @@ -324,6 +324,14 @@ function SmartAI:getUsePriority(card)
end
if v then return v else return sgs.ai_use_priority[class_name] end
end
if self.player:hasSkill("nos_wuyan") then
if card:inherits("Slash") then
v = 4

elseif card:inherits("Collateral") or card:inherits("Dismantlement") or card:inherits("Snatch") or card:inherits("IronChain") then v = 0
end
if v then return v else return sgs.ai_use_priority[class_name] end
end
if self.player:hasSkill("qingnang") then
if card:inherits("Dismantlement") then v = 3.8
elseif card:inherits("Collateral") then v = 3.9
Expand Down Expand Up @@ -3263,6 +3271,10 @@ function SmartAI:aoeIsEffective(card, to)
return false
end

if self.player:hasSkill("nos_wuyan") then
return false
end

if card:inherits("SavageAssault") then
if to:hasSkill("huoshou") or to:hasSkill("juxiang") then
return false
Expand Down Expand Up @@ -3454,7 +3466,7 @@ end
function SmartAI:hasTrickEffective(card, player)
if player then
if self.room:isProhibited(self.player, player, card) then return false end
if (player:hasSkill("zhichi") and self.room:getTag("Zhichi"):toString() == player:objectName()) then
if (player:hasSkill("zhichi") and self.room:getTag("Zhichi"):toString() == player:objectName()) or player:hasSkill("nos_wuyan") then
if card and not (card:inherits("Indulgence") or card:inherits("SupplyShortage")) then return false end
end
if player:hasSkill("wuyan") then
Expand All @@ -3469,6 +3481,11 @@ function SmartAI:hasTrickEffective(card, player)
(card:inherits("Duel") or card:inherits("FireAttack") or card:inherits("ArcheryAttack") or card:inherits("SavageAssault")) then
return false end
end
if self.player:hasSkill("nos_wuyan") then
if card:inherits("TrickCard") and not
(card:inherits("DelayedTrick") or card:inherits("GodSalvation") or card:inherits("AmazingGrace")) then
return false end
end
end
return true
end
Expand Down
14 changes: 11 additions & 3 deletions lua/ai/standard_cards-ai.lua
Expand Up @@ -678,6 +678,8 @@ function SmartAI:useCardAmazingGrace(card, use)
if #self.friends >= #self.enemies or (self:hasSkills(sgs.need_kongcheng) and self.player:getHandcardNum() == 1)
or self.player:hasSkill("jizhi") then
use.card = card
elseif self.player:hasSkill("nos_wuyan") then
use.card = card
end
end

Expand All @@ -687,6 +689,10 @@ sgs.ai_use_priority.AmazingGrace = 1

function SmartAI:useCardGodSalvation(card, use)
local good, bad = 0, 0
if self.player:hasSkill("nos_wuyan") and self.player:isWounded() then
use.card = card
return
end

for _, friend in ipairs(self.friends) do
if friend:isWounded() then
Expand Down Expand Up @@ -852,21 +858,21 @@ function SmartAI:getValuableCard(who)
self:sort(self.friends, "hp")
local friend
if #self.friends > 0 then friend = self.friends[1] end
if friend and self:isWeak(friend) and who:inMyAttackRange(friend) and not who:hasSkill("xuanfeng") then
if friend and self:isWeak(friend) and who:inMyAttackRange(friend) and not who:hasSkill("nos_xuanfeng") then
if weapon and who:distanceTo(friend) > 1 and not
(weapon and weapon:inherits("MoonSpear") and who:hasSkill("keji") and who:getHandcardNum() > 5) then return weapon:getEffectiveId() end
if offhorse and who:distanceTo(friend) > 1 then return offhorse:getEffectiveId() end
end

if defhorse and not who:hasSkill("xuanfeng") then
if defhorse and not who:hasSkill("nos_xuanfeng") then
for _,friend in ipairs(self.friends) do
if friend:distanceTo(who) == friend:getAttackRange()+1 then
return defhorse:getEffectiveId()
end
end
end

if armor and self:evaluateArmor(armor,who)>3 and not who:hasSkill("xuanfeng") then
if armor and self:evaluateArmor(armor,who)>3 and not who:hasSkill("nos_xuanfeng") then
return armor:getEffectiveId()
end

Expand Down Expand Up @@ -917,6 +923,7 @@ end

function SmartAI:useCardSnatchOrDismantlement(card, use)
local name = card:objectName()
if self.player:hasSkill("nos_wuyan") then return end
local players = self.room:getOtherPlayers(self.player)
local tricks
players = self:exclude(players, card)
Expand Down Expand Up @@ -1077,6 +1084,7 @@ end
sgs.dynamic_value.control_card.Dismantlement = true

function SmartAI:useCardCollateral(card, use)
if self.player:hasSkill("nos_wuyan") then return end
self:sort(self.enemies,"threat")

for _, friend in ipairs(self.friends_noself) do
Expand Down
4 changes: 2 additions & 2 deletions src/core/settings.cpp
Expand Up @@ -62,8 +62,8 @@ void Settings::init(){

if(!contains("BanPackages")){
QStringList banlist;
banlist << "nostalgia" << "yitian" << "wisdom" << "test"
<< "disaster" << "god" << "YJCM" << "yitian_cards"
banlist << "nostalgia" << "nostal_general" << "yitian" << "wisdom"
<< "disaster" << "god" << "YJCM" << "yitian_cards" << "test"
<< "sp" << "sp_cards" << "BGM" << "YJCM2012" << "Special3v3"
<< "joy" << "joy_equip" ;

Expand Down

0 comments on commit 4783fbf

Please sign in to comment.