更新修改2

This commit is contained in:
notify 2023-09-21 23:21:28 +08:00 committed by DESKTOP-C7UTUBQ\32064
parent 203736e38e
commit 099ce2d83a
37 changed files with 5265 additions and 3174 deletions

View File

@ -139,7 +139,7 @@ Item {
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: Backend.translate("Room List").arg(roomModel.count)
text: Backend.translate("Room List")
}
ListView {
id: roomList

View File

@ -59,7 +59,7 @@ Item {
id: bgm
source: config.bgmFile
loops: MediaPlayer.Infinite
// loops: MediaPlayer.Infinite
onPlaybackStateChanged: {
if (playbackState == MediaPlayer.StoppedState && roomScene.isStarted)
play();

View File

@ -1070,31 +1070,6 @@ callbacks["AskForCardsChosen"] = (jsonData) => {
});
}
callbacks["AskForPoxi"] = (jsonData) => {
const { type, data } = JSON.parse(jsonData);
roomScene.state = "replying";
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/PoxiBox.qml");
const box = roomScene.popupBox.item;
box.poxi_type = type;
box.card_data = data;
for (let d of data) {
const arr = [];
const ids = d[1];
ids.forEach(id => {
const card_data = JSON.parse(Backend.callLuaFunction("GetCardData", [id]));
arr.push(card_data);
});
box.addCustomCards(d[0], arr);
}
roomScene.popupBox.moveToCenter();
box.cardsSelected.connect((ids) => {
replyToServer(JSON.stringify(ids));
});
}
callbacks["AskForMoveCardInBoard"] = (jsonData) => {
const data = JSON.parse(jsonData);
const { cards, cardsPosition, generalNames, playerIds } = data;

View File

@ -62,12 +62,7 @@ Item {
}
if (mark_name.startsWith('@$')) {
let data = mark_extra.split(',');
if (!Object.is(parseInt(data[0]), NaN)) {
params.ids = data.map(s => parseInt(s));
} else {
params.cardNames = data;
}
params.cardNames = mark_extra.split(',');
} else {
let data = JSON.parse(Backend.callLuaFunction("GetPile", [root.parent.playerid, mark_name]));
data = data.filter((e) => e !== -1);

View File

@ -31,13 +31,11 @@ Item {
property string color: "" // only use when suit is empty
property string footnote: "" // footnote, e.g. "A use card to B"
property bool footnoteVisible: false
property string prohibitReason: ""
property bool known: true // if false it only show a card back
property bool enabled: true // if false the card will be grey
property alias card: cardItem
property alias glow: glowItem
property var mark: ({})
property alias chosenInBox: chosen.visible
function getColor() {
if (suit != "")
@ -90,7 +88,6 @@ Item {
visible: false
}
Image {
id: cardItem
source: known ? SkinBank.getCardPicture(cid || name)
@ -220,15 +217,6 @@ Item {
}
}
Image {
id: chosen
visible: false
source: SkinBank.CARD_DIR + "chosen"
anchors.horizontalCenter: parent.horizontalCenter
y: 90
scale: 1.25
}
Rectangle {
visible: !root.selectable
anchors.fill: parent
@ -236,24 +224,6 @@ Item {
opacity: 0.7
}
Text {
id: prohibitText
visible: !root.selectable
anchors.centerIn: parent
font.family: fontLibian.name
font.pixelSize: 18
opacity: 0.9
horizontalAlignment: Text.AlignHCenter
lineHeight: 18
lineHeightMode: Text.FixedHeight
color: "snow"
width: 20
wrapMode: Text.WrapAnywhere
style: Text.Outline
styleColor: "red"
text: prohibitReason
}
TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.NoButton
gesturePolicy: TapHandler.WithinBounds

View File

@ -166,35 +166,17 @@ RowLayout {
const ids = [];
let cards = handcardAreaItem.cards;
for (let i = 0; i < cards.length; i++) {
cards[i].prohibitReason = "";
if (cardValid(cards[i].cid, cname)) {
ids.push(cards[i].cid);
} else {
const prohibitReason = Backend.callLuaFunction(
"GetCardProhibitReason",
[cards[i].cid, roomScene.respond_play ? "response" : "use", cname]
);
if (prohibitReason) {
cards[i].prohibitReason = prohibitReason;
}
}
}
cards = self.equipArea.getAllCards();
cards.forEach(c => {
c.prohibitReason = "";
if (cardValid(c.cid, cname)) {
ids.push(c.cid);
if (!expanded_piles["_equip"]) {
expandPile("_equip");
}
} else {
const prohibitReason = Backend.callLuaFunction(
"GetCardProhibitReason",
[c.cid, roomScene.respond_play ? "response" : "use", cname]
);
if (prohibitReason) {
c.prohibitReason = prohibitReason;
}
}
});
@ -220,7 +202,6 @@ RowLayout {
const ids = [], cards = handcardAreaItem.cards;
for (let i = 0; i < cards.length; i++) {
cards[i].prohibitReason = "";
if (JSON.parse(Backend.callLuaFunction("CanUseCard", [cards[i].cid, Self.id]))) {
ids.push(cards[i].cid);
} else {
@ -233,14 +214,6 @@ RowLayout {
break;
}
}
// still cannot use? show message on card
if (!ids.includes(cards[i].cid)) {
const prohibitReason = Backend.callLuaFunction("GetCardProhibitReason", [cards[i].cid, "play"]);
if (prohibitReason) {
cards[i].prohibitReason = prohibitReason;
}
}
}
}
handcardAreaItem.enableCards(ids)
@ -399,11 +372,6 @@ RowLayout {
item.enabled = item.pressed;
}
const cards = handcardAreaItem.cards;
for (let i = 0; i < cards.length; i++) {
cards[i].prohibitReason = "";
}
updatePending();
}

View File

@ -48,7 +48,6 @@ Item {
card.selectable = false;
card.showDetail = false;
card.selectedChanged.disconnect(adjustCards);
card.prohibitReason = "";
}
return result;
}

View File

@ -78,10 +78,10 @@ GraphicsBox {
}
onSelectedChanged: {
if (selected) {
chosenInBox = true;
virt_name = "$Selected";
root.selected_ids.push(cid);
} else {
chosenInBox = false;
virt_name = "";
root.selected_ids.splice(root.selected_ids.indexOf(cid), 1);
}
root.selected_ids = root.selected_ids;
@ -122,6 +122,38 @@ GraphicsBox {
return ret;
}
function addHandcards(cards) {
let handcards = findAreaModel('$Hand').areaCards;
if (cards instanceof Array) {
for (let i = 0; i < cards.length; i++)
handcards.append(cards[i]);
} else {
handcards.append(cards);
}
}
function addEquips(cards)
{
let equips = findAreaModel('$Equip').areaCards;
if (cards instanceof Array) {
for (let i = 0; i < cards.length; i++)
equips.append(cards[i]);
} else {
equips.append(cards);
}
}
function addDelayedTricks(cards)
{
let delayedTricks = findAreaModel('$Judge').areaCards;
if (cards instanceof Array) {
for (let i = 0; i < cards.length; i++)
delayedTricks.append(cards[i]);
} else {
delayedTricks.append(cards);
}
}
function addCustomCards(name, cards) {
let area = findAreaModel(name).areaCards;
if (cards instanceof Array) {

View File

@ -23,17 +23,9 @@ Item {
x: -13 - 120 * 0.166
y: -6 - 55 * 0.166
scale: 0.66
source: {
if (type === "notactive") {
return "";
}
let ret = AppPath + "/image/button/skill/" + type + "/";
let suffix = enabled ? (pressed ? "pressed" : "normal") : "disabled";
if (enabled && type === "active" && orig.endsWith("&")) {
suffix += "-attach";
}
return ret + suffix;
}
source: type === "notactive" ? ""
: AppPath + "/image/button/skill/" + type + "/"
+ (enabled ? (pressed ? "pressed" : "normal") : "disabled")
}
Image {

View File

@ -63,9 +63,3 @@ ___
## 许可证
本仓库使用GPLv3作为许可证。详见`LICENSE`文件。
___
## 点一下小星星呗!
[![Star History Chart](https://api.star-history.com/svg?repos=Qsgs-Fans/FreeKill&type=Date)](https://star-history.com/#Qsgs-Fans/FreeKill&Date)

14
lua/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
"editor.renderLineHighlight": "none",
"Lua.diagnostics.disable": [
"undefined-field",
"inject-field",
"return-type-mismatch",
"cast-local-type",
"param-type-mismatch",
"invisible",
"missing-fields",
"assign-type-mismatch",
"undefined-doc-name"
]
}

View File

@ -1,14 +1,14 @@
-- SPDX-License-Identifier: GPL-3.0-or-later
-- All functions in this file are used by Qml
function Translate(src)
return Fk:translate(src)
end
function GetGeneralData(name)
local general = Fk.generals[name]
if general == nil then general = Fk.generals["diaochan"] end
if general == nil then
general = Fk.generals["diaochan"]
end
return json.encode {
package = general.package.name,
extension = general.package.extensionName,
@ -18,13 +18,15 @@ function GetGeneralData(name)
maxHp = general.maxHp,
shield = general.shield,
hidden = general.hidden,
total_hidden = general.total_hidden,
total_hidden = general.total_hidden
}
end
function GetGeneralDetail(name)
local general = Fk.generals[name]
if general == nil then general = Fk.generals["diaochan"] end
if general == nil then
general = Fk.generals["diaochan"]
end
local ret = {
package = general.package.name,
extension = general.package.extensionName,
@ -79,20 +81,23 @@ local cardSubtypeStrings = {
[Card.SubtypeArmor] = "armor",
[Card.SubtypeDefensiveRide] = "defensive_horse",
[Card.SubtypeOffensiveRide] = "offensive_horse",
[Card.SubtypeTreasure] = "treasure",
[Card.SubtypeTreasure] = "treasure"
}
function GetCardData(id, virtualCardForm)
local card = Fk:getCardById(id)
if card == nil then return json.encode{
if card == nil then
return json.encode {
cid = id,
known = false
} end
}
end
local mark = {}
for k, v in pairs(card.mark) do
if k and k:startsWith("@") and v and v ~= 0 then
table.insert(mark, {
k = k, v = v,
k = k,
v = v
})
end
end
@ -162,7 +167,9 @@ end
function SearchGenerals(pack_name, word)
local ret = {}
if word == "" then return GetGenerals(pack_name) end
if word == "" then
return GetGenerals(pack_name)
end
for _, g in ipairs(Fk.packages[pack_name].generals) do
if not g.total_hidden and string.find(Fk:translate(g.name), word) then
table.insert(ret, g.name)
@ -190,8 +197,7 @@ function GetAvailableGeneralsNum()
local availableGenerals = {}
for _, general in pairs(generalPool) do
if not table.contains(except, general.name) then
if (not general.hidden and not general.total_hidden) and
#table.filter(availableGenerals, function(g)
if (not general.hidden and not general.total_hidden) and #table.filter(availableGenerals, function(g)
return g.trueName == general.trueName
end) == 0 then
ret = ret + 1
@ -243,7 +249,7 @@ function GetPlayerSkills(id)
return json.encode(table.map(p.player_skills, function(s)
return s.visible and {
name = s.name,
description = Fk:getDescription(s.name),
description = Fk:getDescription(s.name)
} or nil
end))
end
@ -367,7 +373,9 @@ end
function GetSkillData(skill_name)
local skill = Fk.skills[skill_name]
if not skill then return "null" end
if not skill then
return "null"
end
local freq = "notactive"
if skill:isInstanceOf(ActiveSkill) or skill:isInstanceOf(ViewAsSkill) then
freq = "active"
@ -387,7 +395,7 @@ function GetSkillData(skill_name)
freq = freq,
frequency = frequency,
switchSkillName = skill.switchSkillName,
isViewAsSkill = skill:isInstanceOf(ViewAsSkill),
isViewAsSkill = skill:isInstanceOf(ViewAsSkill)
}
end
@ -414,7 +422,9 @@ function ActiveCanUse(skill_name)
local c = Fk:cloneCard(n)
c.skillName = skill_name
ret = c.skill:canUse(Self, c)
if ret then break end
if ret then
break
end
end
end
end
@ -562,10 +572,12 @@ end
function GetVirtualEquip(player, cid)
local c = ClientInstance:getPlayerById(player):getVirualEquip(cid)
if not c then return "null" end
if not c then
return "null"
end
return json.encode {
name = c.name,
cid = c.subcards[1],
cid = c.subcards[1]
}
end
@ -581,10 +593,12 @@ function GetGameModes()
name = Fk:translate(v.name),
orig_name = v.name,
minPlayer = v.minPlayer,
maxPlayer = v.maxPlayer,
maxPlayer = v.maxPlayer
})
end
table.sort(ret, function(a, b) return a.name > b.name end)
table.sort(ret, function(a, b)
return a.name > b.name
end)
return json.encode(ret)
end
@ -604,20 +618,17 @@ function SetInteractionDataOfSkill(skill_name, data)
end
function ChangeSelf(pid)
local c = ClientInstance
c.client:changeSelf(pid) -- for qml
Self = c:getPlayerById(pid)
ClientInstance.client:changeSelf(pid) -- for qml
Self = ClientInstance:getPlayerById(pid)
end
function GetPlayerHandcards(pid)
local c = ClientInstance
local p = c:getPlayerById(pid)
local p = ClientInstance:getPlayerById(pid)
return json.encode(p.player_cards[Player.Hand])
end
function GetPlayerEquips(pid)
local c = ClientInstance
local p = c:getPlayerById(pid)
local p = ClientInstance:getPlayerById(pid)
return json.encode(p.player_cards[Player.Equip])
end
@ -647,9 +658,10 @@ function GetRoomConfig()
end
function GetPlayerGameData(pid)
local c = ClientInstance
local p = c:getPlayerById(pid)
if not p then return "[0, 0, 0]" end
local p = ClientInstance:getPlayerById(pid)
if not p then
return "[0, 0, 0]"
end
local raw = p.player:getGameData()
local ret = {}
for _, i in fk.qlist(raw) do
@ -659,8 +671,7 @@ function GetPlayerGameData(pid)
end
function SetPlayerGameData(pid, data)
local c = ClientInstance
local p = c:getPlayerById(pid)
local p = ClientInstance:getPlayerById(pid)
p.player:setGameData(table.unpack(data))
table.insert(data, 1, pid)
ClientInstance:notifyUI("UpdateGameData", json.encode(data))
@ -684,52 +695,4 @@ function SaveRecord()
c.client:saveRecord(json.encode(c.record), c.record[2])
end
function GetCardProhibitReason(cid, method, pattern)
local card = Fk:getCardById(cid)
if not card then return "" end
if method == "play" and not card.skill:canUse(Self, card) then return "" end
if method ~= "play" and not card:matchPattern(pattern) then return "" end
if method == "play" then method = "use" end
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
local s
for _, skill in ipairs(status_skills) do
local fn = method == "use" and skill.prohibitUse or skill.prohibitResponse
if fn(skill, Self, card) then
s = skill
break
end
end
if not s then return "" end
-- try to return a translated string
local skillName = s.name
local ret = Fk:translate(skillName)
if ret ~= skillName then
-- TODO: translate
return ret .. "" .. (method == "use" and "使用" or "打出")
elseif skillName:endsWith("_prohibit") and skillName:startsWith("#") then
return Fk:translate(skillName:sub(2, -10)) .. "" .. (method == "use" and "使用" or "打出")
end
end
function PoxiPrompt(poxi_type, data)
local poxi = Fk.poxi_methods[poxi_type]
if not poxi or not poxi.prompt then return "" end
if type(poxi.prompt) == "string" then return Fk:translate(poxi.prompt) end
return poxi.prompt(data)
end
function PoxiFilter(poxi_type, to_select, selected, data)
local poxi = Fk.poxi_methods[poxi_type]
if not poxi then return "false" end
return json.encode(poxi.card_filter(to_select, selected, data))
end
function PoxiFeasible(poxi_type, selected, data)
local poxi = Fk.poxi_methods[poxi_type]
if not poxi then return "false" end
return json.encode(poxi.feasible(selected, data))
end
dofile "lua/client/i18n/init.lua"

View File

@ -2,7 +2,7 @@
Fk:loadTranslationTable({
-- Lobby
["Room List"] = "Room List (currently have %1 rooms)",
-- ["Room List"] = "房间列表",
-- ["Enter"] = "进入",
-- ["Observe"] = "旁观",

View File

@ -2,7 +2,7 @@
Fk:loadTranslationTable{
-- Lobby
["Room List"] = "房间列表 (共%1个房间)",
["Room List"] = "房间列表",
["Enter"] = "进入",
["Observe"] = "旁观",

View File

@ -25,7 +25,6 @@
---@field public filtered_cards table<integer, Card> @ 被锁视技影响的卡牌
---@field public printed_cards table<integer, Card> @ 被某些房间现场打印的卡牌id都是负数且从-2开始
---@field private _custom_events any[] @ 自定义事件列表
---@field public poxi_methods table<string, PoxiSpec> @ “魄袭”框操作方法表
local Engine = class("Engine")
--- Engine的构造函数。
@ -56,7 +55,6 @@ function Engine:initialize()
self.game_mode_disabled = {}
self.kingdoms = {}
self._custom_events = {}
self.poxi_methods = {}
self:loadPackages()
self:loadDisabled()
@ -336,16 +334,6 @@ function Engine:addGameEvent(name, pfunc, mfunc, cfunc, efunc)
table.insert(self._custom_events, { name = name, p = pfunc, m = mfunc, c = cfunc, e = efunc })
end
---@param spec PoxiSpec
function Engine:addPoxiMethod(spec)
assert(type(spec.name) == "string")
assert(type(spec.card_filter) == "function")
assert(type(spec.feasible) == "function")
self.poxi_methods[spec.name] = spec
spec.default_choice = spec.default_choice or function() return {} end
spec.post_select = spec.post_select or function(s) return s end
end
--- 从已经开启的拓展包中,随机选出若干名武将。
---
--- 对于同名武将不会重复选取。

View File

@ -136,8 +136,10 @@ function Player:setGeneral(general, setHp, addSkills)
end
function Player:getGeneralMaxHp()
local general = Fk.generals[type(self:getMark("__heg_general")) == "string" and self:getMark("__heg_general") or self.general]
local deputy = Fk.generals[type(self:getMark("__heg_deputy")) == "string" and self:getMark("__heg_deputy") or self.deputyGeneral]
local general = Fk.generals
[type(self:getMark("__heg_general")) == "string" and self:getMark("__heg_general") or self.general]
local deputy = Fk.generals
[type(self:getMark("__heg_deputy")) == "string" and self:getMark("__heg_deputy") or self.deputyGeneral]
if not deputy then
return general.maxHp + general.mainMaxHpAdjustedValue
@ -329,12 +331,18 @@ end
function Player:getCardIds(playerAreas, specialName)
local rightAreas = { Player.Hand, Player.Equip, Player.Judge }
playerAreas = playerAreas or rightAreas
local cardIds = {}
if type(playerAreas) == "string" then
local str = playerAreas
playerAreas = {}
if str:find("h") then
table.insert(playerAreas, Player.Hand)
end
if str:find("&") then
for k, v in pairs(self.special_cards) do
if k:endsWith("&") then table.insertTable(cardIds, v) end
end
end
if str:find("e") then
table.insert(playerAreas, Player.Equip)
end
@ -346,7 +354,6 @@ function Player:getCardIds(playerAreas, specialName)
local areas = type(playerAreas) == "table" and playerAreas or { playerAreas }
local rightAreas = { Player.Hand, Player.Equip, Player.Judge, Player.Special }
local cardIds = {}
for _, area in ipairs(areas) do
assert(table.contains(rightAreas, area))
assert(area ~= Player.Special or type(specialName) == "string")
@ -510,7 +517,8 @@ function Player:distanceTo(other, mode, ignore_dead)
if temp ~= other then
print("Distance malfunction: start and end does not matched.")
end
local left = #(ignore_dead and Fk:currentRoom().players or Fk:currentRoom().alive_players) - right - #table.filter(Fk:currentRoom().alive_players, function(p) return p:isRemoved() end)
local left = #(ignore_dead and Fk:currentRoom().players or Fk:currentRoom().alive_players) - right -
#table.filter(Fk:currentRoom().alive_players, function(p) return p:isRemoved() end)
local ret = 0
if mode == "left" then
ret = left
@ -731,7 +739,6 @@ function Player:hasSkill(skill, ignoreNullified, ignoreAlive)
if self:isInstanceOf(ServerPlayer) and -- isInstanceOf(nil) will return false
table.contains(self._fake_skills, skill) and
table.contains(self.prelighted_skills, skill) then
return true
end
@ -844,8 +851,7 @@ end
---@param to Player @ 特定玩家
---@param card Card @ 特定牌
function Player:isProhibited(to, card)
local r = Fk:currentRoom()
if type(card) == "number" then card = Fk:getCardById(card) end
if card.type == Card.TypeEquip and #to:getAvailableEquipSlots(card.sub_type) == 0 then
return true
end
@ -855,7 +861,12 @@ function Player:isProhibited(to, card)
return true
end
local status_skills = r.status_skills[ProhibitSkill] or Util.DummyTable
if fk.useMustTargets and
not table.contains(fk.useMustTargets, to.id) then
return true
end
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
for _, skill in ipairs(status_skills) do
if skill:isProhibited(self, to, card) then
return true
@ -928,9 +939,11 @@ fk.SwitchYin = 1
---@return number|string @ 转换技状态
function Player:getSwitchSkillState(skillName, afterUse, inWord)
if afterUse then
return self:getMark(MarkEnum.SwithSkillPreName .. skillName) < 1 and (inWord and "yin" or fk.SwitchYin) or (inWord and "yang" or fk.SwitchYang)
return self:getMark(MarkEnum.SwithSkillPreName .. skillName) < 1 and (inWord and "yin" or fk.SwitchYin) or
(inWord and "yang" or fk.SwitchYang)
else
return self:getMark(MarkEnum.SwithSkillPreName .. skillName) < 1 and (inWord and "yang" or fk.SwitchYang) or (inWord and "yin" or fk.SwitchYin)
return self:getMark(MarkEnum.SwithSkillPreName .. skillName) < 1 and (inWord and "yang" or fk.SwitchYang) or
(inWord and "yin" or fk.SwitchYin)
end
end

View File

@ -588,13 +588,3 @@ function fk.CreateGameMode(spec)
end
return ret
end
-- other
---@class PoxiSpec
---@field name string
---@field card_filter fun(to_select: int, selected: int[], data: any): bool
---@field feasible fun(selected: int[], data: any): bool
---@field post_select nil | fun(selected: int[], data: any): int[]
---@field default_choice nil | fun(data: any): int[]
---@field prompt nil | string | fun(data: any): string

View File

@ -7,7 +7,6 @@
---@alias null nil
---@alias bool boolean | nil
---@alias int integer
---@class fk
---FreeKill's lua API

View File

@ -0,0 +1,45 @@
拓展包ai文件写法
按照包文件夹名+_ai例如standard_cards是standard_cards_ai.lua直接放在init.lua同位置下。
分辨敌我:
设置反值内值同时设置技能和牌的身份值例如杀的值为100主公或跳身份的忠被杀时来源反值+100当一名角色反值大于50时将识别为反贼当跳反者杀反贼或跳忠者杀主忠他内值就+100内值大于50的将被识别为内奸当然标记身份是以最高值开始标记身份例如场上两名角色为400和300的最高反值但是反贼只剩下一个那么就只将400的标记为反贼其余身份也是如此。优先针对虚弱相同虚弱再优先仇恨。
要让身份值加给角色就需要在使用技能或牌时接入ai接口所以我在触发时机函数的最后加了接口用于获取此时触发时机的数据例如1号位杀2号位此时触发了指定目标时机就可以通过接口接入ai然后让来源反值+100。但是N神不想这样增加接口但我还不了解怎么通过其他方式同步获取使用技能或牌的数据......
空闲点ai出牌
先定义阶段技或卡牌的优先度然后获取角色所有可用的阶段技和卡牌按照优先度进行排序再进行for列表逐一检测是否可使用可使用则检测是否有使用函数有则执行使用函数在使用函数里进行定义self.use_id和给self.use_tos添加角色id然后系统检测有self.use_id则输出使用如果是使用卡则self.use_id=卡id阶段技是self.use_id=子卡表{})同时可以给self.use_tos添加角色id做为牌或技能的目标会同步输出。
请求ai使用牌
包含请求无懈,请求桃,借刀请求杀等
请求无懈有正无懈和反无懈系统根据生效锦囊牌名定位请求代码之后可以增加来源和目标技能名来修正是否使用例如要通过伤害锦囊卖血时可以通过技能名阻止友方使用无懈同时请求代码会带有正反无懈的参数根据这个参数进行分类讨论请求代码需定义self.use_id为将要使用的无懈id当然也可以定义self.use_id=true这样就会根据卡牌优先度选择第一个无懈使用。因为要区分正反无懈我在room里的请求无懈时增加了fk.askNullification和fk.askNullificationData前者用来区分正反无懈后者记录要无懈的锦囊数据因为直接获取使用数据可能会是上个无懈的数据而不是最初锦囊的数据当然我并不知道其他的识别正反无懈和获取源锦囊生效数据的方法只能是手动增加记录的这个样子来实现.....
请求桃默认给友军使用,但是可以通过来源和目标的技能来修正来源是否要使用桃
剩下的请求牌根据提示信息名进行决策,兜底决策是套用空闲点出牌代码,所以说请求使用牌和空闲点使用牌的的函数是相通的,如果请求使用牌没有定义函数,就会调用空闲点使用牌的函数来兜底。
技能转化牌:
急救桃、倾国闪等
也是通过技能名定位转化代码也需要定义self.use_id为技能子卡表{}就行,如果没有子卡就定义空表{},如果不定义就表示不使用转化技。
请求ai打出牌
杀响应决斗南蛮等
根据牌名或技能名来分别决策同时优先以技能名决策用于卖血技兜底决策是默认不响应因为有部分是技能请求响应例如鬼才改判打出。响应牌依旧是将要响应的卡的id定义为self.use_id懒得再定义个新参数
请求ai弃置牌
给每个牌名定义保留值,然后排序并优先弃置低保留值的牌。
请求ai发动技能
直接按照技能名分别决策。
技能请求选择角色是给self.use_tos添加目标id例如突袭
既请求选择角色又请求选择牌就再增加定义self.use_id为技能子卡表{}
请求ai选择角色区域牌
按照提示信息名分别决策,同时设置兜底决策,对敌军优先选择其重要的牌。
依旧是定义self.use_id为技能子卡表{}不论选择一张牌还是多张牌都是将牌id添加到表然后定义给self.use_id。
请求ai选择选项
按照提示信息名分别决策,同时兜底决策是随机选择。
这个就直接返回需要选择的选项就行。

View File

@ -3,25 +3,3 @@
AI = require "server.ai.ai"
TrustAI = require "server.ai.trust_ai"
RandomAI = require "server.ai.random_ai"
SmartAI = require "server.ai.smart_ai"
-- load ai module from packages
local directories = FileIO.ls("packages")
require "packages.standard.ai"
require "packages.standard_cards.ai"
require "packages.maneuvering.ai"
table.removeOne(directories, "standard")
table.removeOne(directories, "standard_cards")
table.removeOne(directories, "maneuvering")
local _disable_packs = json.decode(fk.GetDisabledPacks())
for _, dir in ipairs(directories) do
if (not string.find(dir, ".disabled")) and not table.contains(_disable_packs, dir)
and FileIO.isDir("packages/" .. dir)
and FileIO.exists("packages/" .. dir .. "/ai/init.lua") then
require(string.format("packages.%s.ai", dir))
end
end

View File

@ -1,5 +1,4 @@
-- SPDX-License-Identifier: GPL-3.0-or-later
---@class RandomAI: AI
local RandomAI = AI:subclass("RandomAI")
@ -12,7 +11,9 @@ local function useActiveSkill(self, skill, card)
local filter_func = skill.cardFilter
if card then
filter_func = function() return false end
filter_func = function()
return false
end
end
if self.command == "PlayCard" and (not skill:canUse(player, card) or player:prohibitUse(card)) then
@ -27,7 +28,9 @@ local function useActiveSkill(self, skill, card)
local min_card = skill:getMinCardNum()
local max_card = skill:getMaxCardNum()
for _ = 0, max_try_times do
if skill:feasible(selected_targets, selected_cards, self.player, card) then break end
if skill:feasible(selected_targets, selected_cards, self.player, card) then
break
end
local avail_targets = table.filter(self.room:getAlivePlayers(), function(p)
local ret = skill:targetFilter(p.id, selected_targets, selected_cards, card or Fk:cloneCard 'zixing')
if ret and card then
@ -37,12 +40,16 @@ local function useActiveSkill(self, skill, card)
end
return ret
end)
avail_targets = table.map(avail_targets, function(p) return p.id end)
avail_targets = table.map(avail_targets, function(p)
return p.id
end)
local avail_cards = table.filter(player:getCardIds{Player.Hand, Player.Equip}, function(id)
return filter_func(skill, id, selected_cards, selected_targets)
end)
if #avail_targets == 0 and #avail_cards == 0 then break end
if #avail_targets == 0 and #avail_cards == 0 then
break
end
table.insertIfNeed(selected_targets, table.random(avail_targets))
table.insertIfNeed(selected_cards, table.random(avail_cards))
end
@ -50,9 +57,9 @@ local function useActiveSkill(self, skill, card)
local ret = json.encode {
card = card and card.id or json.encode {
skill = skill.name,
subcards = selected_cards,
subcards = selected_cards
},
targets = selected_targets,
targets = selected_targets
}
-- print(ret)
return ret
@ -69,25 +76,35 @@ local function useVSSkill(self, skill, pattern, cancelable, extra_data)
if self.command == "PlayCard" then
precondition = skill:enabledAtPlay(player)
if not precondition then return nil end
if not precondition then
return nil
end
local exp = Exppattern:Parse(skill.pattern)
local cnames = {}
for _, m in ipairs(exp.matchers) do
if m.name then table.insertTable(cnames, m.name) end
if m.name then
table.insertTable(cnames, m.name)
end
end
for _, n in ipairs(cnames) do
local c = Fk:cloneCard(n)
precondition = c.skill:canUse(Self, c)
if precondition then break end
if precondition then
break
end
end
else
precondition = skill:enabledAtResponse(player)
if not precondition then return nil end
if not precondition then
return nil
end
local exp = Exppattern:Parse(pattern)
precondition = exp:matchExp(skill.pattern)
end
if (not precondition) or math.random() < 0.2 then return nil end
if (not precondition) or math.random() < 0.2 then
return nil
end
local selected_cards = {}
local max_try_time = 100
@ -96,12 +113,14 @@ local function useVSSkill(self, skill, pattern, cancelable, extra_data)
local avail_cards = table.filter(player:getCardIds{Player.Hand, Player.Equip}, function(id)
return skill:cardFilter(id, selected_cards)
end)
if #avail_cards == 0 then break end
if #avail_cards == 0 then
break
end
table.insert(selected_cards, table.random(avail_cards))
if skill:viewAs(selected_cards) then
return {
skill = skill.name,
subcards = selected_cards,
subcards = selected_cards
}
end
end
@ -114,7 +133,9 @@ random_cb.AskForUseActiveSkill = function(self, jsonData)
local data = json.decode(jsonData)
local skill = Fk.skills[data[1]]
local cancelable = data[3]
if cancelable and math.random() < 0.25 then return "" end
if cancelable and math.random() < 0.25 then
return ""
end
local extra_data = json.decode(data[4])
for k, v in pairs(extra_data) do
skill[k] = v
@ -138,9 +159,14 @@ random_cb.AskForUseCard = function(self, jsonData)
return exp:match(Fk:getCardById(id)) and not player:prohibitUse(Fk:getCardById(id))
end)
if #avail_cards > 0 then
if math.random() < 0.25 then return "" end
if math.random() < 0.25 then
return ""
end
avail_cards = table.map(avail_cards, function(id)
return Fk:getCardById(id)
end)
for _, card in ipairs(avail_cards) do
local skill = Fk:getCardById(card).skill
local skill = card.skill
local max_try_times = 100
local selected_targets = {}
local min = skill:getMinTargetNum()
@ -148,21 +174,26 @@ random_cb.AskForUseCard = function(self, jsonData)
local min_card = skill:getMinCardNum()
local max_card = skill:getMaxCardNum()
for _ = 0, max_try_times do
if skill:feasible(selected_targets, {card}, self.player, card) then break end
if skill:feasible(selected_targets, {card.id}, self.player, card) then
break
end
local avail_targets = table.filter(self.room:getAlivePlayers(), function(p)
local ret = skill:targetFilter(p.id, selected_targets, {card}, card or Fk:cloneCard 'zixing')
return ret
end)
avail_targets = table.map(avail_targets, function(p) return p.id end)
avail_targets = table.map(avail_targets, function(p)
return p.id
end)
if #avail_targets == 0 and #avail_cards == 0 then break end
table.insertIfNeed(selected_targets, table.random(avail_targets))
table.insertIfNeed({card}, table.random(avail_cards))
if #avail_targets + #avail_cards < 1 then
break
end
if skill:feasible(selected_targets, {card}, self.player, card) then
table.insertIfNeed(selected_targets, table.random(avail_targets))
end
if skill:feasible(selected_targets, {card.id}, self.player, card) then
return json.encode {
card = table.random(avail_cards),
targets = selected_targets,
targets = selected_targets
}
end
end
@ -179,18 +210,21 @@ random_cb.AskForResponseCard = function(self, jsonData)
local avail_cards = table.filter(self.player:getCardIds{Player.Hand, Player.Equip}, function(id)
return exp:match(Fk:getCardById(id))
end)
if #avail_cards > 0 then return json.encode{
if #avail_cards > 0 then
return json.encode {
card = table.random(avail_cards),
targets = {},
} end
targets = {}
}
end
-- TODO: vs skill
return ""
end
---@param self RandomAI
random_cb.PlayCard = function(self, jsonData)
local cards = table.map(self.player:getCardIds(Player.Hand),
function(id) return Fk:getCardById(id) end)
local cards = table.map(self.player:getCardIds(Player.Hand), function(id)
return Fk:getCardById(id)
end)
local actives = table.filter(self.player:getAllSkills(), function(s)
return s:isInstanceOf(ActiveSkill)
end)
@ -207,7 +241,9 @@ random_cb.PlayCard = function(self, jsonData)
local skill = card.skill ---@type ActiveSkill
if math.random() > 0.15 then
local ret = useActiveSkill(self, skill, card)
if ret ~= "" then return ret end
if ret ~= "" then
return ret
end
table.removeOne(cards, card)
else
table.removeOne(cards, card)
@ -216,7 +252,9 @@ random_cb.PlayCard = function(self, jsonData)
local active = sth
if math.random() > 0.30 then
local ret = useActiveSkill(self, active, nil)
if ret ~= "" then return ret end
if ret ~= "" then
return ret
end
end
table.removeOne(cards, active)
else

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,18 @@
-- SPDX-License-Identifier: GPL-3.0-or-later
local playCardEmotionAndSound = function(room, player, card)
if card.type ~= Card.TypeEquip then
local anim_path = "./packages/" .. card.package.extensionName .. "/image/anim/" .. card.name
if not FileIO.exists(anim_path) then
for _, dir in ipairs(FileIO.ls("./packages/")) do
anim_path = "./packages/" .. dir .. "/image/anim/" .. card.name
if FileIO.exists(anim_path) then break end
if FileIO.exists(anim_path) then
break
end
end
if FileIO.exists(anim_path) then room:setEmotion(player, anim_path) end
end
if FileIO.exists(anim_path) then
room:setEmotion(player, anim_path)
end
end
local soundName
@ -25,13 +28,15 @@ local playCardEmotionAndSound = function(room, player, card)
soundName = "./audio/card/common/" .. subTypeStr
else
soundName = "./packages/" .. card.package.extensionName .. "/audio/card/"
.. (player.gender == General.Male and "male/" or "female/") .. card.name
soundName = "./packages/" .. card.package.extensionName .. "/audio/card/" ..
(player.gender == General.Male and "male/" or "female/") .. card.name
if not FileIO.exists(soundName .. ".mp3") then
for _, dir in ipairs(FileIO.ls("./packages/")) do
soundName = "./packages/" .. dir .. "/audio/card/"
.. (player.gender == General.Male and "male/" or "female/") .. card.name
if FileIO.exists(soundName .. ".mp3") then break end
soundName = "./packages/" .. dir .. "/audio/card/" ..
(player.gender == General.Male and "male/" or "female/") .. card.name
if FileIO.exists(soundName .. ".mp3") then
break
end
end
end
end
@ -49,7 +54,9 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
local card = _card
---[[
if not _card:isVirtual() then
local temp = { card = _card }
local temp = {
card = _card
}
Fk:filterCard(_card.id, room:getPlayerById(from), temp)
card = temp.card
end
@ -59,7 +66,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
playCardEmotionAndSound(room, room:getPlayerById(from), card)
room:doAnimate("Indicate", {
from = from,
to = cardUseEvent.tos or Util.DummyTable,
to = cardUseEvent.tos or Util.DummyTable
})
local useCardIds = card:isVirtual() and card.subcards or { card.id }
@ -75,7 +82,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
type = "#UseV0CardToTargets",
from = from,
to = to,
arg = card:toLogString(),
arg = card:toLogString()
}
else
room:sendLog {
@ -83,7 +90,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
from = from,
to = to,
card = useCardIds,
arg = card:toLogString(),
arg = card:toLogString()
}
end
else
@ -103,7 +110,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
type = "#CardUseCollaborator",
from = t[1],
to = temp,
arg = card.name,
arg = card.name
}
end
end
@ -114,7 +121,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
type = "#UseV0CardToCard",
from = from,
arg = cardUseEvent.toCard.name,
arg2 = card:toLogString(),
arg2 = card:toLogString()
}
else
room:sendLog {
@ -122,7 +129,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
from = from,
card = useCardIds,
arg = cardUseEvent.toCard.name,
arg2 = card:toLogString(),
arg2 = card:toLogString()
}
end
else
@ -130,7 +137,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
type = "#UseCardToCard",
from = from,
card = useCardIds,
arg = cardUseEvent.toCard.name,
arg = cardUseEvent.toCard.name
}
end
else
@ -139,32 +146,36 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
room:sendLog {
type = "#UseV0Card",
from = from,
arg = card:toLogString(),
arg = card:toLogString()
}
else
room:sendLog {
type = "#UseVCard",
from = from,
card = useCardIds,
arg = card:toLogString(),
arg = card:toLogString()
}
end
else
room:sendLog {
type = "#UseCard",
from = from,
card = useCardIds,
card = useCardIds
}
end
end
if #useCardIds == 0 then return end
if #useCardIds == 0 then
return
end
if cardUseEvent.tos and #cardUseEvent.tos > 0 and #cardUseEvent.tos <= 2 then
local tos = table.map(cardUseEvent.tos, function(e) return e[1] end)
local tos = table.map(cardUseEvent.tos, function(e)
return e[1]
end)
room:sendFootnote(useCardIds, {
type = "##UseCardTo",
from = from,
to = tos,
to = tos
})
if card:isVirtual() then
room:sendCardVirtName(useCardIds, card.name)
@ -172,7 +183,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
else
room:sendFootnote(useCardIds, {
type = "##UseCard",
from = from,
from = from
})
if card:isVirtual() then
room:sendCardVirtName(useCardIds, card.name)
@ -185,16 +196,18 @@ GameEvent.functions[GameEvent.UseCard] = function(self)
local room = self.room
local logic = room.logic
room:moveCardTo(cardUseEvent.card, Card.Processing, nil, fk.ReasonUse)
if cardUseEvent.card.skill then
cardUseEvent.card.skill:onUse(room, cardUseEvent)
end
if logic:trigger(fk.PreCardUse, room:getPlayerById(cardUseEvent.from), cardUseEvent) then
cardUseEvent.breakEvent = true
self.data = { cardUseEvent }
logic:breakEvent()
end
room:moveCardTo(cardUseEvent.card, Card.Processing, nil, fk.ReasonUse)
sendCardEmotionAndLog(room, cardUseEvent)
if not cardUseEvent.extraUse then
@ -205,7 +218,6 @@ GameEvent.functions[GameEvent.UseCard] = function(self)
cardUseEvent.responseToEvent.cardsResponded = cardUseEvent.responseToEvent.cardsResponded or {}
table.insertIfNeed(cardUseEvent.responseToEvent.cardsResponded, cardUseEvent.card)
end
for _, event in ipairs({ fk.AfterCardUseDeclared, fk.AfterCardTargetDeclared, fk.CardUsing }) do
if not cardUseEvent.toCard and #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
break
@ -229,7 +241,7 @@ GameEvent.cleaners[GameEvent.UseCard] = function(self)
room:moveCards({
ids = leftRealCardIds,
toArea = Card.DiscardPile,
moveReason = fk.ReasonUse,
moveReason = fk.ReasonUse
})
end
end
@ -238,6 +250,13 @@ GameEvent.functions[GameEvent.RespondCard] = function(self)
local cardResponseEvent = table.unpack(self.data)
local room = self.room
local logic = room.logic
if logic:trigger(fk.PreCardRespond, room:getPlayerById(cardResponseEvent.from), cardResponseEvent) then
cardResponseEvent.breakEvent = true
self.data = { cardResponseEvent }
logic:breakEvent()
end
local from = cardResponseEvent.customFrom or cardResponseEvent.from
local card = cardResponseEvent.card
local cardIds = room:getSubcardsByRule(card)
@ -247,41 +266,38 @@ GameEvent.functions[GameEvent.RespondCard] = function(self)
room:sendLog {
type = "#ResponsePlayV0Card",
from = from,
arg = card:toLogString(),
arg = card:toLogString()
}
else
room:sendLog {
type = "#ResponsePlayVCard",
from = from,
card = cardIds,
arg = card:toLogString(),
arg = card:toLogString()
}
end
else
room:sendLog {
type = "#ResponsePlayCard",
from = from,
card = cardIds,
card = cardIds
}
end
room:moveCardTo(card, Card.Processing, nil, fk.ReasonResonpse)
if #cardIds > 0 then
room:sendFootnote(cardIds, {
type = "##ResponsePlayCard",
from = from,
from = from
})
if card:isVirtual() then
room:sendCardVirtName(cardIds, card.name)
end
end
if logic:trigger(fk.PreCardRespond, room:getPlayerById(cardResponseEvent.from), cardResponseEvent) then
logic:breakEvent()
end
if cardResponseEvent.retrial ~= true then
playCardEmotionAndSound(room, room:getPlayerById(from), card)
end
logic:trigger(fk.CardResponding, room:getPlayerById(cardResponseEvent.from), cardResponseEvent)
self.data = { cardResponseEvent }
end
GameEvent.cleaners[GameEvent.RespondCard] = function(self)
@ -295,7 +311,7 @@ GameEvent.cleaners[GameEvent.RespondCard] = function(self)
room:moveCards({
ids = realCardIds,
toArea = Card.DiscardPile,
moveReason = fk.ReasonResonpse,
moveReason = fk.ReasonResonpse
})
end
end
@ -315,13 +331,9 @@ GameEvent.functions[GameEvent.CardEffect] = function(self)
end
end
if
not cardEffectEvent.toCard and
(
not (room:getPlayerById(cardEffectEvent.to):isAlive() and cardEffectEvent.to)
or #room:deadPlayerFilter(TargetGroup:getRealTargets(cardEffectEvent.tos)) == 0
)
then
if not cardEffectEvent.toCard and
(not (room:getPlayerById(cardEffectEvent.to):isAlive() and cardEffectEvent.to) or
#room:deadPlayerFilter(TargetGroup:getRealTargets(cardEffectEvent.tos)) == 0) then
logic:breakEvent()
end

View File

@ -73,13 +73,6 @@ function GameEvent:addExitFunc(f)
table.insert(self.extra_exit_funcs, f)
end
function GameEvent:prependExitFunc(f)
if self.extra_exit_funcs == Util.DummyTable then
self.extra_exit_funcs = {}
end
table.insert(self.extra_exit_funcs, 1, f)
end
function GameEvent:findParent(eventType, includeSelf)
if includeSelf and self.event == eventType then return self end
local e = self.parent

View File

@ -1,5 +1,4 @@
-- SPDX-License-Identifier: GPL-3.0-or-later
---@class GameLogic: Object
---@field public room Room
---@field public skill_table table<Event, TriggerSkill[]>
@ -24,16 +23,11 @@ function GameLogic:initialize(room)
self.event_recorder = {}
self.current_event_id = 0
self.role_table = {
{ "lord" },
{ "lord", "rebel" },
{ "lord", "rebel", "renegade" },
{ "lord", "loyalist", "rebel", "renegade" },
{ "lord", "loyalist", "rebel", "rebel", "renegade" },
self.role_table = {{"lord"}, {"lord", "rebel"}, {"lord", "rebel", "renegade"},
{"lord", "loyalist", "rebel", "renegade"}, {"lord", "loyalist", "rebel", "rebel", "renegade"},
{"lord", "loyalist", "rebel", "rebel", "rebel", "renegade"},
{"lord", "loyalist", "loyalist", "rebel", "rebel", "rebel", "renegade"},
{ "lord", "loyalist", "loyalist", "rebel", "rebel", "rebel", "rebel", "renegade" },
}
{"lord", "loyalist", "loyalist", "rebel", "rebel", "rebel", "rebel", "renegade"}}
end
function GameLogic:run()
@ -62,7 +56,6 @@ local function execGameEvent(type, ...)
return ret
end
function GameLogic:assignRoles()
local room = self.room
local n = #room.players
@ -95,11 +88,9 @@ function GameLogic:chooseGenerals()
local lordpools = {}
if room.settings.gameMode == "aaa_role_mode" then
for _, general in pairs(Fk:getAllGenerals()) do
if (not general.hidden and not general.total_hidden) and
table.find(general.skills, function(s)
if (not general.hidden and not general.total_hidden) and table.find(general.skills, function(s)
return s.lordSkill
end) and
not table.find(lordlist, function(g)
end) and not table.find(lordlist, function(g)
return g.trueName == general.trueName
end) then
table.insert(lordlist, general)
@ -108,13 +99,17 @@ function GameLogic:chooseGenerals()
lordlist = table.random(lordlist, 3) or {}
end
table.insertTable(generals, Fk:getGeneralsRandomly(generalNum, Fk:getAllGenerals(), nil, function(g)
return table.contains(table.map(lordlist, function(g) return g.trueName end), g.trueName)
return table.contains(table.map(lordlist, function(g)
return g.trueName
end), g.trueName)
end))
for i = 1, #generals do
generals[i] = generals[i].name
end
lordpools = table.simpleClone(generals)
table.insertTable(lordpools, table.map(lordlist, function(g) return g.name end))
table.insertTable(lordpools, table.map(lordlist, function(g)
return g.name
end))
lord_generals = room:askForGeneral(lord, lordpools, n)
local lord_general, deputy
if type(lord_generals) == "table" then
@ -269,7 +264,9 @@ function GameLogic:prepareForStart()
self:addTriggerSkill(trig)
end
self.room:sendLog{ type = "$GameStart" }
self.room:sendLog{
type = "$GameStart"
}
end
function GameLogic:action()
@ -280,7 +277,9 @@ function GameLogic:action()
while true do
execGameEvent(GameEvent.Round)
if room.game_finished then break end
if room.game_finished then
break
end
end
end
@ -324,16 +323,16 @@ function GameLogic:addTriggerSkill(skill)
end
end
if not table.contains(self.skill_priority_table[event],
skill.priority_table[event]) then
if not table.contains(self.skill_priority_table[event], skill.priority_table[event]) then
table.insert(self.skill_priority_table[event],
skill.priority_table[event])
table.insert(self.skill_priority_table[event], skill.priority_table[event])
end
end
if skill.visible then
if (Fk.related_skills[skill.name] == nil) then return end
if (Fk.related_skills[skill.name] == nil) then
return
end
for _, s in ipairs(Fk.related_skills[skill.name]) do
if (s.class == TriggerSkill) then
self:addTriggerSkill(s)
@ -352,8 +351,9 @@ function GameLogic:trigger(event, target, data, refresh_only)
local skills_to_refresh = self.refresh_skill_table[event] or Util.DummyTable
local _target = room.current -- for iteration
local player = _target
if #skills_to_refresh > 0 then repeat do
if #skills_to_refresh > 0 then
repeat
do
-- refresh skills. This should not be broken
for _, skill in ipairs(skills_to_refresh) do
if skill:canRefresh(event, target, player, data) then
@ -361,56 +361,70 @@ function GameLogic:trigger(event, target, data, refresh_only)
end
end
player = player.next
end until player == _target end
end
until player == _target
end
if #skills == 0 or refresh_only then return end
if #skills == 0 or refresh_only then
return
end
local prio_tab = self.skill_priority_table[event]
local prev_prio = math.huge
for _, prio in ipairs(prio_tab) do
if broken then break end
if broken then
break
end
if prio >= prev_prio then
-- continue
goto trigger_loop_continue
end
repeat do
local invoked_skills = {}
local filter_func = function(skill)
return skill.priority_table[event] == prio and
not table.contains(invoked_skills, skill) and
skill:triggerable(event, target, player, data)
end
repeat
do
local triggerables = table.filter(skills, function(skill)
return skill.priority_table[event] == prio and skill:triggerable(event, target, player, data)
end)
local skill_names = table.map(table.filter(skills, filter_func), Util.NameMapper)
local skill_names = table.map(triggerables, function(skill)
return skill.name
end)
while #skill_names > 0 do
local skill_name = prio <= 0 and table.random(skill_names) or
room:askForChoice(player, skill_names, "trigger", "#choose-trigger")
local skill = skill_name == "game_rule" and GameRule
or Fk.skills[skill_name]
local skill = skill_name == "game_rule" and GameRule or Fk.skills[skill_name]
table.insert(invoked_skills, skill)
local len = #skills
broken = skill:trigger(event, target, player, data)
skill_names = table.map(table.filter(skills, filter_func), Util.NameMapper)
broken = broken or (event == fk.AskForPeaches
and room:getPlayerById(data.who).hp > 0)
table.insertTable(skill_names,
table.map(table.filter(table.slice(skills, len - #skills), function(s)
return s.priority_table[event] == prio and s:triggerable(event, target, player, data)
end), function(s)
return s.name
end))
if broken then break end
broken = broken or (event == fk.AskForPeaches and room:getPlayerById(data.who).hp > 0)
if broken then
break
end
table.removeOne(skill_names, skill_name)
end
if broken then
break
end
if broken then break end
player = player.next
end until player == _target
end
until player == _target
prev_prio = prio
::trigger_loop_continue::
end
_target.ai:filterEvent(event, target, data)
return broken
end
@ -419,18 +433,6 @@ function GameLogic:getCurrentEvent()
return self.game_event_stack.t[self.game_event_stack.p]
end
--- 如果当前事件刚好是技能生效事件,就返回那个技能名,否则返回空串。
function GameLogic:getCurrentSkillName()
local skillEvent = self:getCurrentEvent()
local ret = ""
if skillEvent.event == GameEvent.SkillEffect then
local _, _, _skill = table.unpack(skillEvent.data)
local skill = _skill.main_skill and _skill.main_skill or _skill
ret = skill.name
end
return ret
end
-- 在指定历史范围中找至多n个符合条件的事件
---@param eventType integer @ 要查找的事件类型
---@param n integer @ 最多找多少个
@ -458,10 +460,14 @@ function GameLogic:dumpEventStack(detailed)
local top = self:getCurrentEvent()
local i = self.game_event_stack.p
local inspect = p
if not top then return end
if not top then
return
end
print("===== Start of event stack dump =====")
if not detailed then print("") end
if not detailed then
print("")
end
repeat
local printable_data
@ -477,7 +483,7 @@ function GameLogic:dumpEventStack(detailed)
print("\nStack level #" .. i .. ":")
inspect {
eventId = GameEvent:translate(top.event),
data = printable_data or "nil",
data = printable_data or "nil"
}
end
@ -511,6 +517,7 @@ function GameLogic:dumpAllEvents(from, to)
end
function GameLogic:breakEvent(ret)
self.room.breakEvent = true
coroutine.yield("__breakEvent", ret)
end

File diff suppressed because it is too large Load Diff

46
lua/server/room.lua.rej Normal file
View File

@ -0,0 +1,46 @@
diff a/lua/server/room.lua b/lua/server/room.lua (rejected hunks)
@@ -1482,41 +1482,18 @@
local result = self:doRequest(chooser, command, json.encode(data))
if result == "" then
- local areas = {}
- local handcards
+ local handcards = {}
if type(flag) == "string" then
- if string.find(flag, "h") then
- table.insert(areas, Player.Hand)
- end
- if string.find(flag, "e") then
- table.insert(areas, Player.Equip)
- end
- if string.find(flag, "j") then
- table.insert(areas, Player.Judge)
- end
- handcards = target:getCardIds(areas)
+ handcards = target:getCardIds(flag)
else
- handcards = {}
for _, t in ipairs(flag.card_data) do
table.insertTable(handcards, t[2])
end
end
- if #handcards == 0 then
- return
- end
- result = handcards[math.random(1, #handcards)]
+ result = handcards[math.random(1, #handcards)] or -1
else
result = tonumber(result)
end
-
- if result == -1 then
- local handcards = target:getCardIds(Player.Hand)
- if #handcards == 0 then
- return
- end
- result = table.random(handcards)
- end
-
return result
end

View File

@ -45,7 +45,7 @@ function ServerPlayer:initialize(_self)
self._prelighted_skills = {}
self._timewaste_count = 0
self.ai = RandomAI:new(self)
self.ai = TrustAI:new(self)
end
---@param command string
@ -469,7 +469,7 @@ function ServerPlayer:gainAnExtraPhase(phase, delay)
local logic = room.logic
local turn = logic:getCurrentEvent():findParent(GameEvent.Phase, true)
if turn then
turn:prependExitFunc(function() self:gainAnExtraPhase(phase, false) end)
turn:addExitFunc(function() self:gainAnExtraPhase(phase, false) end)
return
end
end
@ -484,6 +484,7 @@ function ServerPlayer:gainAnExtraPhase(phase, delay)
arg = phase_name_table[phase],
}
GameEvent(GameEvent.Phase, self, self.phase):exec()
self.phase = current
@ -579,7 +580,6 @@ function ServerPlayer:skip(phase)
end
end
--- 当进行到出牌阶段空闲点时,结束出牌阶段。
function ServerPlayer:endPlayPhase()
self._play_phase_end = true
-- TODO: send log
@ -592,7 +592,7 @@ function ServerPlayer:gainAnExtraTurn(delay)
local logic = room.logic
local turn = logic:getCurrentEvent():findParent(GameEvent.Turn, true)
if turn then
turn:prependExitFunc(function() self:gainAnExtraTurn(false) end)
turn:addExitFunc(function() self:gainAnExtraTurn(false) end)
return
end
end
@ -604,32 +604,10 @@ function ServerPlayer:gainAnExtraTurn(delay)
local current = room.current
room.current = self
self.tag["_extra_turn_count"] = self.tag["_extra_turn_count"] or {}
local ex_tag = self.tag["_extra_turn_count"]
local skillName = room.logic:getCurrentSkillName()
table.insert(ex_tag, skillName)
GameEvent(GameEvent.Turn, self):exec()
table.remove(ex_tag)
room.current = current
end
function ServerPlayer:insideExtraTurn()
return self.tag["_extra_turn_count"] and #self.tag["_extra_turn_count"] > 0
end
---@return string
function ServerPlayer:getCurrentExtraTurnReason()
local ex_tag = self.tag["_extra_turn_count"]
if (not ex_tag) or #ex_tag == 0 then
return "game_rule"
end
return ex_tag[#ex_tag]
end
function ServerPlayer:drawCards(num, skillName, fromPlace)
return self.room:drawCards(self, num, skillName, fromPlace)
end
@ -1013,4 +991,8 @@ function ServerPlayer:removeBuddy(other)
self:doNotify("RmBuddy", tostring(other.id))
end
function ServerPlayer:getAI()
return self.ai
end
return ServerPlayer

View File

@ -1,5 +1,4 @@
-- SPDX-License-Identifier: GPL-3.0-or-later
local extension = Package:new("maneuvering", Package.CardPack)
local slash = Fk:cloneCard("slash")
@ -28,20 +27,13 @@ local thunderSlashSkill = fk.CreateActiveSkill{
local thunderSlash = fk.CreateBasicCard {
name = "thunder__slash",
skill = thunderSlashSkill,
is_damage_card = true,
is_damage_card = true
}
extension:addCards{
thunderSlash:clone(Card.Club, 5),
thunderSlash:clone(Card.Club, 6),
thunderSlash:clone(Card.Club, 7),
thunderSlash:clone(Card.Club, 8),
thunderSlash:clone(Card.Spade, 4),
thunderSlash:clone(Card.Spade, 5),
thunderSlash:clone(Card.Spade, 6),
thunderSlash:clone(Card.Spade, 7),
thunderSlash:clone(Card.Spade, 8),
}
extension:addCards{thunderSlash:clone(Card.Club, 5), thunderSlash:clone(Card.Club, 6), thunderSlash:clone(Card.Club, 7),
thunderSlash:clone(Card.Club, 8), thunderSlash:clone(Card.Spade, 4),
thunderSlash:clone(Card.Spade, 5), thunderSlash:clone(Card.Spade, 6),
thunderSlash:clone(Card.Spade, 7), thunderSlash:clone(Card.Spade, 8)}
local fireSlashSkill = fk.CreateActiveSkill {
name = "fire__slash_skill",
@ -67,29 +59,28 @@ local fireSlashSkill = fk.CreateActiveSkill{
local fireSlash = fk.CreateBasicCard {
name = "fire__slash",
skill = fireSlashSkill,
is_damage_card = true,
is_damage_card = true
}
extension:addCards{
fireSlash:clone(Card.Heart, 4),
fireSlash:clone(Card.Heart, 7),
fireSlash:clone(Card.Heart, 10),
fireSlash:clone(Card.Diamond, 4),
fireSlash:clone(Card.Diamond, 5),
}
extension:addCards{fireSlash:clone(Card.Heart, 4), fireSlash:clone(Card.Heart, 7), fireSlash:clone(Card.Heart, 10),
fireSlash:clone(Card.Diamond, 4), fireSlash:clone(Card.Diamond, 5)}
local analepticSkill = fk.CreateActiveSkill {
name = "analeptic_skill",
max_turn_use_time = 1,
mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
return self:withinTimesLimit(Fk:currentRoom():getPlayerById(to_select), Player.HistoryTurn, card, "analeptic", Fk:currentRoom():getPlayerById(to_select)) and
local to = Fk:currentRoom():getPlayerById(to_select)
local from = Fk:currentRoom():getPlayerById(user)
return self:withinTimesLimit(from, Player.HistoryTurn, card, "analeptic", to) and
not table.find(Fk:currentRoom().alive_players, function(p)
return p.dying
end)
end) and not (card and from:isProhibited(to, card))
end,
can_use = function(self, player, card)
return self:withinTimesLimit(player, Player.HistoryTurn, card, "analeptic", player)
return self:withinTimesLimit(player, Player.HistoryTurn, card, "analeptic", player) and
not player:isProhibited(player, card)
end,
on_use = function(self, room, use)
if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then
use.tos = {{use.from}}
@ -106,7 +97,7 @@ local analepticSkill = fk.CreateActiveSkill{
who = to,
num = 1,
recoverBy = room:getPlayerById(effect.from),
card = effect.card,
card = effect.card
})
else
to.drank = to.drank + 1
@ -124,7 +115,6 @@ local analepticEffect = fk.CreateTriggerSkill{
if target ~= player then
return false
end
if event == fk.PreCardUse then
return data.card.trueName == "slash" and player.drank > 0
else
@ -147,7 +137,7 @@ local analepticEffect = fk.CreateTriggerSkill{
end
end
end
end,
end
}
Fk:addSkill(analepticEffect)
@ -155,16 +145,11 @@ local analeptic = fk.CreateBasicCard{
name = "analeptic",
suit = Card.Spade,
number = 3,
skill = analepticSkill,
skill = analepticSkill
}
extension:addCards({
analeptic,
analeptic:clone(Card.Spade, 9),
analeptic:clone(Card.Club, 3),
analeptic:clone(Card.Club, 9),
analeptic:clone(Card.Diamond, 9),
})
extension:addCards({analeptic, analeptic:clone(Card.Spade, 9), analeptic:clone(Card.Club, 3),
analeptic:clone(Card.Club, 9), analeptic:clone(Card.Diamond, 9)})
local recast = fk.CreateActiveSkill {
name = "recast",
@ -180,50 +165,57 @@ local ironChainCardSkill = fk.CreateActiveSkill{
min_target_num = 1,
max_target_num = 2,
mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
return true
local to = Fk:currentRoom():getPlayerById(to_select)
local from = Fk:currentRoom():getPlayerById(user)
return not (card and from:isProhibited(to, card))
end,
target_filter = function(self, to_select, selected, _, card)
if #selected < self:getMaxTargetNum(Self, card) then
return self:modTargetFilter(to_select, selected, Self.id, card)
end
end,
target_filter = function() return true end,
on_effect = function(self, room, cardEffectEvent)
local to = room:getPlayerById(cardEffectEvent.to)
to:setChainState(not to.chained)
end,
end
}
local ironChain = fk.CreateTrickCard {
name = "iron_chain",
skill = ironChainCardSkill,
special_skills = {"recast"},
multiple_targets = true,
}
extension:addCards{
ironChain:clone(Card.Spade, 11),
ironChain:clone(Card.Spade, 12),
ironChain:clone(Card.Club, 10),
ironChain:clone(Card.Club, 11),
ironChain:clone(Card.Club, 12),
ironChain:clone(Card.Club, 13),
multiple_targets = true
}
extension:addCards{ironChain:clone(Card.Spade, 11), ironChain:clone(Card.Spade, 12), ironChain:clone(Card.Club, 10),
ironChain:clone(Card.Club, 11), ironChain:clone(Card.Club, 12), ironChain:clone(Card.Club, 13)}
local fireAttackSkill = fk.CreateActiveSkill {
name = "fire_attack_skill",
target_num = 1,
mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
return not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
local to = Fk:currentRoom():getPlayerById(to_select)
local from = Fk:currentRoom():getPlayerById(user)
return not (card and from:isProhibited(to, card)) and not to:isKongcheng()
end,
target_filter = function(self, to_select)
return self:modTargetFilter(to_select)
target_filter = function(self, to_select, selected, _, card)
if #selected < self:getMaxTargetNum(Self, card) then
return self:modTargetFilter(to_select, selected, Self.id, card)
end
end,
on_effect = function(self, room, cardEffectEvent)
local from = room:getPlayerById(cardEffectEvent.from)
local to = room:getPlayerById(cardEffectEvent.to)
if to:isKongcheng() then return end
if to:isKongcheng() then
return
end
local showCard = room:askForCard(to, 1, 1, false, self.name, false, ".|.|.|hand", "#fire_attack-show:" .. from.id)[1]
local showCard = room:askForCard(to, 1, 1, false, self.name, false, ".|.|.|hand",
"#fire_attack-show:" .. from.id)[1]
to:showCards(showCard)
showCard = Fk:getCardById(showCard)
local cards = room:askForDiscard(from, 1, 1, false, self.name, true,
".|.|" .. showCard:getSuitString(), "#fire_attack-discard:" .. to.id .. "::" .. showCard:getSuitString())
local cards = room:askForDiscard(from, 1, 1, false, self.name, true, ".|.|" .. showCard:getSuitString(),
"#fire_attack-discard:" .. to.id .. "::" .. showCard:getSuitString())
if #cards > 0 then
room:damage({
from = from,
@ -234,18 +226,14 @@ local fireAttackSkill = fk.CreateActiveSkill{
skillName = self.name
})
end
end,
end
}
local fireAttack = fk.CreateTrickCard {
name = "fire_attack",
skill = fireAttackSkill,
is_damage_card = true,
}
extension:addCards{
fireAttack:clone(Card.Heart, 2),
fireAttack:clone(Card.Heart, 3),
fireAttack:clone(Card.Diamond, 12),
is_damage_card = true
}
extension:addCards{fireAttack:clone(Card.Heart, 2), fireAttack:clone(Card.Heart, 3), fireAttack:clone(Card.Diamond, 12)}
local supplyShortageSkill = fk.CreateActiveSkill {
name = "supply_shortage_skill",
@ -253,10 +241,12 @@ local supplyShortageSkill = fk.CreateActiveSkill{
mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
local player = Fk:currentRoom():getPlayerById(to_select)
local from = Fk:currentRoom():getPlayerById(user)
return from ~= player and not (distance_limited and not self:withinDistanceLimit(from, false, card, player))
return
user ~= to_select and not (distance_limited and not self:withinDistanceLimit(from, false, card, player)) and
not (card and from:isProhibited(player, card))
end,
target_filter = function(self, to_select, selected, _, card)
return #selected == 0 and self:modTargetFilter(to_select, selected, Self.id, card, true)
return #selected < 1 and self:modTargetFilter(to_select, selected, Self.id, card, true)
end,
target_num = 1,
on_effect = function(self, room, effect)
@ -264,11 +254,10 @@ local supplyShortageSkill = fk.CreateActiveSkill{
local judge = {
who = to,
reason = "supply_shortage",
pattern = ".|.|spade,heart,diamond",
pattern = ".|.|club"
}
room:judge(judge)
local result = judge.card
if result.suit ~= Card.Club then
if judge.card.suit ~= Card.Club then
to:skip(Player.Draw)
end
self:onNullified(room, effect)
@ -279,16 +268,13 @@ local supplyShortageSkill = fk.CreateActiveSkill{
toArea = Card.DiscardPile,
moveReason = fk.ReasonUse
}
end,
end
}
local supplyShortage = fk.CreateDelayedTrickCard {
name = "supply_shortage",
skill = supplyShortageSkill,
}
extension:addCards{
supplyShortage:clone(Card.Spade, 10),
supplyShortage:clone(Card.Club, 4),
skill = supplyShortageSkill
}
extension:addCards{supplyShortage:clone(Card.Spade, 10), supplyShortage:clone(Card.Club, 4)}
local gudingSkill = fk.CreateTriggerSkill {
name = "#guding_blade_skill",
@ -296,13 +282,12 @@ local gudingSkill = fk.CreateTriggerSkill{
frequency = Skill.Compulsory,
events = {fk.DamageCaused},
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.to:isKongcheng() and data.card and data.card.trueName == "slash" and
not data.chain
return target == player and player:hasSkill(self.name) and data.to:isKongcheng() and data.card and
data.card.trueName == "slash" and not data.chain
end,
on_use = function(_, _, _, _, data)
data.damage = data.damage + 1
end,
end
}
Fk:addSkill(gudingSkill)
local gudingBlade = fk.CreateWeapon {
@ -310,7 +295,7 @@ local gudingBlade = fk.CreateWeapon{
suit = Card.Spade,
number = 1,
attack_range = 2,
equip_skill = gudingSkill,
equip_skill = gudingSkill
}
extension:addCard(gudingBlade)
@ -327,7 +312,7 @@ local fanSkill = fk.CreateTriggerSkill{
card.skillName = "fan"
card:addSubcard(data.card)
data.card = card
end,
end
}
Fk:addSkill(fanSkill)
local fan = fk.CreateWeapon {
@ -335,7 +320,7 @@ local fan = fk.CreateWeapon{
suit = Card.Diamond,
number = 1,
attack_range = 4,
equip_skill = fanSkill,
equip_skill = fanSkill
}
extension:addCard(fan)
@ -349,13 +334,12 @@ local vineSkill = fk.CreateTriggerSkill{
events = {fk.PreCardEffect, fk.DamageInflicted},
can_trigger = function(self, event, target, player, data)
if event == fk.DamageInflicted then
return target == player and player:hasSkill(self.name) and
data.damageType == fk.FireDamage
return target == player and player:hasSkill(self.name) and data.damageType == fk.FireDamage
end
local effect = data ---@type CardEffectEvent
return player.id == effect.to and player:hasSkill(self.name) and
(effect.card.name == "slash" or effect.card.name == "savage_assault" or
effect.card.name == "archery_attack")
(effect.card.name == "slash" or effect.card.name == "savage_assault" or effect.card.name ==
"archery_attack")
end,
on_use = function(self, event, target, player, data)
local room = player.room
@ -368,17 +352,14 @@ local vineSkill = fk.CreateTriggerSkill{
room:setEmotion(player, "./packages/maneuvering/image/anim/vine")
return true
end
end,
end
}
Fk:addSkill(vineSkill)
local vine = fk.CreateArmor {
name = "vine",
equip_skill = vineSkill,
}
extension:addCards{
vine:clone(Card.Spade, 2),
vine:clone(Card.Club, 2),
equip_skill = vineSkill
}
extension:addCards{vine:clone(Card.Spade, 2), vine:clone(Card.Club, 2)}
local silverLionSkill = fk.CreateTriggerSkill {
name = "#silver_lion_skill",
@ -390,7 +371,7 @@ local silverLionSkill = fk.CreateTriggerSkill{
end,
on_use = function(_, _, _, _, data)
data.damage = 1
end,
end
}
Fk:addSkill(silverLionSkill)
local silverLion = fk.CreateArmor {
@ -409,40 +390,26 @@ local silverLion = fk.CreateArmor{
skillName = self.name
}
end
end,
end
}
extension:addCard(silverLion)
local huaLiu = fk.CreateDefensiveRide {
name = "hualiu",
suit = Card.Diamond,
number = 13,
number = 13
}
extension:addCards({
huaLiu,
})
extension:addCards({huaLiu})
extension:addCards{
Fk:cloneCard("jink", Card.Heart, 8),
Fk:cloneCard("jink", Card.Heart, 9),
Fk:cloneCard("jink", Card.Heart, 11),
Fk:cloneCard("jink", Card.Heart, 12),
Fk:cloneCard("jink", Card.Diamond, 6),
Fk:cloneCard("jink", Card.Diamond, 7),
Fk:cloneCard("jink", Card.Diamond, 8),
Fk:cloneCard("jink", Card.Diamond, 10),
Fk:cloneCard("jink", Card.Diamond, 11),
Fk:cloneCard("peach", Card.Heart, 5),
Fk:cloneCard("peach", Card.Heart, 6),
Fk:cloneCard("peach", Card.Diamond, 2),
Fk:cloneCard("peach", Card.Diamond, 3),
Fk:cloneCard("nullification", Card.Heart, 1),
Fk:cloneCard("nullification", Card.Heart, 13),
Fk:cloneCard("nullification", Card.Spade, 13),
}
extension:addCards{Fk:cloneCard("jink", Card.Heart, 8), Fk:cloneCard("jink", Card.Heart, 9),
Fk:cloneCard("jink", Card.Heart, 11), Fk:cloneCard("jink", Card.Heart, 12),
Fk:cloneCard("jink", Card.Diamond, 6), Fk:cloneCard("jink", Card.Diamond, 7),
Fk:cloneCard("jink", Card.Diamond, 8), Fk:cloneCard("jink", Card.Diamond, 10),
Fk:cloneCard("jink", Card.Diamond, 11), Fk:cloneCard("peach", Card.Heart, 5),
Fk:cloneCard("peach", Card.Heart, 6), Fk:cloneCard("peach", Card.Diamond, 2),
Fk:cloneCard("peach", Card.Diamond, 3), Fk:cloneCard("nullification", Card.Heart, 1),
Fk:cloneCard("nullification", Card.Heart, 13), Fk:cloneCard("nullification", Card.Spade, 13)}
Fk:loadTranslationTable{
["maneuvering"] = "军争",
@ -475,7 +442,7 @@ Fk:loadTranslationTable{
["silver_lion"] = "白银狮子",
[":silver_lion"] = "装备牌·防具<br /><b>防具技能</b>锁定技。每当你受到伤害时若此伤害大于1点防止多余的伤害。每当你失去装备区里的【白银狮子】后你回复1点体力。",
["hualiu"] = "骅骝",
[":hualiu"] = "装备牌·坐骑<br /><b>坐骑技能</b>:其他角色与你的距离+1。",
[":hualiu"] = "装备牌·坐骑<br /><b>坐骑技能</b>:其他角色与你的距离+1。"
}
return extension

View File

@ -0,0 +1,140 @@
fk.ai_card.thunder__slash = fk.ai_card.slash
fk.ai_use_play.thunder__slash = fk.ai_use_play.slash
fk.ai_card.fire__slash = fk.ai_card.slash
fk.ai_use_play.fire__slash = fk.ai_use_play.slash
fk.ai_card.analeptic = {
intention = 60, -- 身份值
value = 5, -- 卡牌价值
priority = 3 -- 使用优先值
}
fk.ai_use_play.analeptic = function(self, card)
local cards = table.map(self.player:getCardIds("&he"), function(id)
return Fk:getCardById(id)
end)
self:sortValue(cards)
for _, sth in ipairs(self:getActives("slash")) do
local slash = nil
if sth:isInstanceOf(Card) then
if sth.skill:canUse(self.player, sth) and not self.player:prohibitUse(sth) then
slash = sth
end
else
local selected = {}
for _, c in ipairs(cards) do
if sth:cardFilter(c.id, selected) then
table.insert(selected, c.id)
end
end
local tc = sth:viewAs(selected)
if tc and tc:matchPattern("slash") and tc.skill:canUse(self.player, tc) and not self.player:prohibitUse(tc) then
slash = tc
end
end
if slash then
fk.ai_use_play.slash(self, slash)
if self.use_id then
self.use_id = card.id
self.use_tos = {}
break
end
end
end
end
fk.ai_card.iron_chain = {
intention = function(self, card, from)
if self.player.chained then
return -80
end
return 80
end, -- 身份值
value = 2, -- 卡牌价值
priority = 3 -- 使用优先值
}
fk.ai_use_play.iron_chain = function(self, card)
for _, p in ipairs(self.friends) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and p.chained then
table.insert(self.use_tos, p.id)
end
end
self:sort(self.enemies)
for _, p in ipairs(self.enemies) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and not p.chained then
table.insert(self.use_tos, p.id)
end
end
if #self.use_tos < 2 then
self.use_tos = {}
else
self.use_id = card.id
end
end
fk.ai_use_play.recast = function(self, card)
if self.command == "PlayCard" then
self.use_id = card.id
self.special_skill = "recast"
end
end
fk.ai_card.fire_attack = {
intention = 90, -- 身份值
value = 3, -- 卡牌价值
priority = 4 -- 使用优先值
}
fk.ai_use_play.fire_attack = function(self, card)
self:sort(self.enemies)
for _, p in ipairs(self.enemies) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and #self.player:getCardIds("h") > 2 then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
end
fk.ai_dis_card.fire_attack_skill = function(self, min_num, num, include_equip, cancelable, pattern, prompt)
local use = self:eventData("UseCard")
for _, p in ipairs(TargetGroup:getRealTargets(use.tos)) do
if self:isEnemie(p) then
local cards = table.map(self.player:getCardIds("h"), function(id)
return Fk:getCardById(id)
end)
local exp = Exppattern:Parse(pattern)
cards = table.filter(cards, function(c)
return exp:match(c)
end)
if #cards > 0 then
self:sortValue(cards)
return { cards[1].id }
end
end
end
end
fk.ai_card.fire_attack = {
intention = 120, -- 身份值
value = 2, -- 卡牌价值
priority = 2 -- 使用优先值
}
fk.ai_use_play.supply_shortage = function(self, card)
self:sort(self.enemies)
for _, p in ipairs(self.enemies) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and not p.chained then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
end
fk.ai_skill_invoke["#fan_skill"] = function(self)
local use = self:eventData("UseCard")
for _, p in ipairs(TargetGroup:getRealTargets(use.tos)) do
if not self:isFriend(p) then
return true
end
end
end

View File

@ -41,7 +41,7 @@ GameRule = fk.CreateTriggerSkill{
local dyingPlayer = room:getPlayerById(data.who)
while dyingPlayer.hp < 1 do
local cardNames = { "peach" }
local prompt = "#AskForPeaches:" .. dyingPlayer.id .. "::" .. tostring(1 - dyingPlayer.hp)
local prompt = "#AskForPeaches:" .. data.who .. "::" .. tostring(1 - dyingPlayer.hp)
if player == dyingPlayer then
table.insert(cardNames, "analeptic")
prompt = "#AskForPeachesSelf:::" .. tostring(1 - dyingPlayer.hp)
@ -51,16 +51,41 @@ GameRule = fk.CreateTriggerSkill{
local cardCloned = Fk:cloneCard(cardName)
return not (player:prohibitUse(cardCloned) or player:isProhibited(dyingPlayer, cardCloned))
end)
if #cardNames == 0 then return end
local peach_use = room:askForUseCard(player, "peach", table.concat(cardNames, ",") , prompt)
if not peach_use then break end
peach_use.tos = { {dyingPlayer.id} }
if peach_use.card.trueName == "analeptic" then
peach_use.extra_data = peach_use.extra_data or {}
peach_use.extra_data.analepticRecover = true
if #cardNames < 1 then return end
room:notifyMoveFocus(player, "peach")
local useData = {
user = player,
cardName = "peach",
pattern = table.concat(cardNames, ","),
extraData = Util.DummyTable
}
room.logic:trigger(fk.AskForCardUse, player, useData)
if type(useData.result) == "table" then
useData = useData.result
useData.tos = { { data.who } }
if useData.card.trueName == "analeptic" then
useData.extra_data = useData.extra_data or {}
useData.extra_data.analepticRecover = true
end
room:useCard(useData)
end
useData = { "peach", table.concat(cardNames, ","), prompt, true, Util.DummyTable }
while dyingPlayer.hp < 1 do
Fk.currentResponsePattern = table.concat(cardNames, ",")
local result = room:doRequest(player, "AskForUseCard", json.encode(useData))
Fk.currentResponsePattern = nil
if result ~= "" then
result = room:handleUseCardReply(player, result)
result.tos = { { data.who } }
if result.card.trueName == "analeptic" then
result.extra_data = result.extra_data or {}
result.extra_data.analepticRecover = true
end
room:useCard(result)
else
return
end
end
room:useCard(peach_use)
end
end,
[fk.AskForPeachesDone] = function()

View File

@ -1,5 +1,4 @@
-- SPDX-License-Identifier: GPL-3.0-or-later
local extension = Package:new("standard")
extension.metadata = require "packages.standard.metadata"
dofile "packages/standard/game_rule.lua"
@ -12,13 +11,14 @@ local jianxiong = fk.CreateTriggerSkill{
can_trigger = function(self, event, target, player, data)
local room = target.room
return target == player and player:hasSkill(self.name) and data.card and
table.every(data.card:isVirtual() and data.card.subcards or {data.card.id}, function(id) return room:getCardArea(id) == Card.Processing end)
table.every(data.card:isVirtual() and data.card.subcards or { data.card.id }, function(id)
return room:getCardArea(id) == Card.Processing
end)
end,
on_use = function(self, event, target, player, data)
player.room:obtainCard(player.id, data.card, true, fk.ReasonJustMove)
end,
end
}
local hujia = fk.CreateViewAsSkill {
name = "hujia$",
anim_type = "defensive",
@ -38,10 +38,10 @@ local hujia = fk.CreateViewAsSkill{
return false
end,
enabled_at_response = function(self, player)
return not table.every(Fk:currentRoom().alive_players, function(p)
return player:getMark("hujia-failed-phase") == 0 and not table.every(Fk:currentRoom().alive_players, function(p)
return p == player or p.kingdom ~= "wei"
end)
end,
end
}
local hujiaResponse = fk.CreateTriggerSkill {
name = "#hujiaResponse",
@ -58,34 +58,34 @@ local hujiaResponse = fk.CreateTriggerSkill{
end,
on_use = function(self, event, target, player, data)
local room = player.room
for _, p in ipairs(room:getOtherPlayers(player)) do
if p.kingdom == "wei" then
local weis = table.filter(room:getOtherPlayers(player), function(p)
return p.kingdom == "wei"
end)
room:doIndicate(player.id, table.map(weis, function(p)
return p.id
end))
for _, p in ipairs(weis) do
local cardResponded = room:askForResponse(p, "jink", "jink", "#hujia-ask:" .. player.id, true)
if cardResponded then
if cardResponded then --[[
room:responseCard({
from = p.id,
card = cardResponded,
skipDrop = true,
})
data.card = cardResponded
skipDrop = true
})--]]
data.card = cardResponded.card
return false
end
end
end
if event == fk.PreCardUse and player.phase == Player.Play then
room:setPlayerMark(player, "hujia-failed-phase", 1)
end
return true
end,
refresh_events = {fk.CardUsing},
refresh_events = { fk.CardUsing, fk.CardResponding },
can_refresh = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name, true) and player:getMark("hujia-failed-phase") > 0
return player:hasSkill(self.name, true) and player:getMark("hujia-failed-phase") > 0
end,
on_refresh = function(self, event, target, player, data)
player.room:setPlayerMark(player, "hujia-failed-phase", 0)
end,
end
}
hujia:addRelatedSkill(hujiaResponse)
@ -103,16 +103,16 @@ local guicai = fk.CreateTriggerSkill{
on_cost = function(self, event, target, player, data)
local room = player.room
local prompt = "#guicai-ask::" .. target.id
local card = room:askForResponse(player, self.name, ".|.|.|hand", prompt, true)
if card ~= nil then
self.cost_data = card
local Response = room:askForResponse(player, self.name, ".|.|.|hand", prompt, true, nil, nil, true)
if Response then
self.cost_data = Response.card
return true
end
end,
on_use = function(self, event, target, player, data)
local room = player.room
room:retrial(self.cost_data, player, data, self.name)
end,
end
}
local fankui = fk.CreateTriggerSkill {
name = "fankui",
@ -149,11 +149,13 @@ local ganglie = fk.CreateTriggerSkill{
on_use = function(self, event, target, player, data)
local room = player.room
local from = data.from
if from and not from.dead then room:doIndicate(player.id, {from.id}) end
if from and not from.dead then
room:doIndicate(player.id, { from.id })
end
local judge = {
who = player,
reason = self.name,
pattern = ".|.|^heart",
pattern = ".|.|^heart"
}
room:judge(judge)
if judge.card.suit ~= Card.Heart and from and not from.dead then
@ -163,11 +165,11 @@ local ganglie = fk.CreateTriggerSkill{
from = player,
to = from,
damage = 1,
skillName = self.name,
skillName = self.name
}
end
end
end,
end
}
local xiahoudun = General:new(extension, "xiahoudun", "wei", 4)
xiahoudun:addSkill(ganglie)
@ -178,12 +180,17 @@ local tuxi = fk.CreateTriggerSkill{
events = { fk.EventPhaseStart },
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and player.phase == Player.Draw and
table.find(player.room:getOtherPlayers(player), function(p) return not p:isKongcheng() end)
table.find(player.room:getOtherPlayers(player), function(p)
return not p:isKongcheng()
end)
end,
on_cost = function(self, event, target, player, data)
local room = player.room
local targets = table.map(table.filter(room:getOtherPlayers(player), function(p)
return not p:isKongcheng() end), function (p) return p.id end)
return not p:isKongcheng()
end), function(p)
return p.id
end)
local result = room:askForChoosePlayers(player, targets, 1, 2, "#tuxi-ask", self.name)
if #result > 0 then
@ -194,7 +201,9 @@ local tuxi = fk.CreateTriggerSkill{
on_use = function(self, event, target, player, data)
local room = player.room
for _, id in ipairs(self.cost_data) do
if player.dead then return end
if player.dead then
return
end
local p = room:getPlayerById(id)
if not p.dead then
local c = room:askForCardChosen(player, p, "h", self.name)
@ -202,7 +211,7 @@ local tuxi = fk.CreateTriggerSkill{
end
end
return true
end,
end
}
local zhangliao = General:new(extension, "zhangliao", "wei", 4)
zhangliao:addSkill(tuxi)
@ -216,15 +225,15 @@ local luoyi = fk.CreateTriggerSkill{
end,
on_use = function(self, event, target, player, data)
data.n = data.n - 1
end,
end
}
local luoyi_trigger = fk.CreateTriggerSkill {
name = "#luoyi_trigger",
mute = true,
events = { fk.DamageCaused },
can_trigger = function(self, event, target, player, data)
return target == player and player:usedSkillTimes("luoyi", Player.HistoryTurn) > 0 and
not data.chain and data.card and (data.card.trueName == "slash" or data.card.name == "duel")
return target == player and player:usedSkillTimes("luoyi", Player.HistoryTurn) > 0 and not data.chain and
data.card and (data.card.trueName == "slash" or data.card.name == "duel")
end,
on_cost = function(self, event, target, player, data)
return true
@ -234,7 +243,7 @@ local luoyi_trigger = fk.CreateTriggerSkill{
player:broadcastSkillInvoke("luoyi")
room:notifySkillInvoked(player, "luoyi")
data.damage = data.damage + 1
end,
end
}
local xuchu = General:new(extension, "xuchu", "wei", 4)
luoyi:addRelatedSkill(luoyi_trigger)
@ -249,7 +258,7 @@ local tiandu = fk.CreateTriggerSkill{
end,
on_use = function(self, event, target, player, data)
player.room:obtainCard(player.id, data.card, true, fk.ReasonJustMove)
end,
end
}
local yiji = fk.CreateTriggerSkill {
name = "yiji",
@ -258,13 +267,15 @@ local yiji = fk.CreateTriggerSkill{
on_trigger = function(self, event, target, player, data)
self.cancel_cost = false
for i = 1, data.damage do
if self.cancel_cost then break end
if self.cancel_cost then
break
end
self:doCost(event, target, player, data)
end
end,
on_cost = function(self, event, target, player, data)
local room = player.room
if room:askForSkillInvoke(player, self.name, data) then
if room:askForSkillInvoke(player, self.name) then
return true
end
self.cancel_cost = true
@ -275,24 +286,39 @@ local yiji = fk.CreateTriggerSkill{
local fakemove = {
toArea = Card.PlayerHand,
to = player.id,
moveInfo = table.map(ids, function(id) return {cardId = id, fromArea = Card.Void} end),
moveReason = fk.ReasonJustMove,
moveInfo = table.map(ids, function(id)
return {
cardId = id,
fromArea = Card.Void
}
end),
moveReason = fk.ReasonJustMove
}
room:notifyMoveCards({ player }, { fakemove })
for _, id in ipairs(ids) do
room:setCardMark(Fk:getCardById(id), "yiji", 1)
end
while table.find(ids, function(id) return Fk:getCardById(id):getMark("yiji") > 0 end) do
player.yiji_ids = ids
while table.find(ids, function(id)
return Fk:getCardById(id):getMark("yiji") > 0
end) do
if not room:askForUseActiveSkill(player, "yiji_active", "#yiji-give", true) then
for _, id in ipairs(ids) do
room:setCardMark(Fk:getCardById(id), "yiji", 0)
end
ids = table.filter(ids, function(id) return room:getCardArea(id) ~= Card.PlayerHand end)
ids = table.filter(ids, function(id)
return room:getCardArea(id) ~= Card.PlayerHand
end)
fakemove = {
from = player.id,
toArea = Card.Void,
moveInfo = table.map(ids, function(id) return {cardId = id, fromArea = Card.PlayerHand} end),
moveReason = fk.ReasonGive,
moveInfo = table.map(ids, function(id)
return {
cardId = id,
fromArea = Card.PlayerHand
}
end),
moveReason = fk.ReasonGive
}
room:notifyMoveCards({ player }, { fakemove })
room:moveCards({
@ -301,11 +327,11 @@ local yiji = fk.CreateTriggerSkill{
to = player.id,
toArea = Card.PlayerHand,
moveReason = fk.ReasonGive,
skillName = self.name,
skillName = self.name
})
end
end
end,
end
}
local yiji_active = fk.CreateActiveSkill {
name = "yiji_active",
@ -328,8 +354,13 @@ local yiji_active = fk.CreateActiveSkill{
local fakemove = {
from = player.id,
toArea = Card.Void,
moveInfo = table.map(effect.cards, function(id) return {cardId = id, fromArea = Card.PlayerHand} end),
moveReason = fk.ReasonGive,
moveInfo = table.map(effect.cards, function(id)
return {
cardId = id,
fromArea = Card.PlayerHand
}
end),
moveReason = fk.ReasonGive
}
room:notifyMoveCards({ player }, { fakemove })
room:moveCards({
@ -338,9 +369,9 @@ local yiji_active = fk.CreateActiveSkill{
to = target.id,
toArea = Card.PlayerHand,
moveReason = fk.ReasonGive,
skillName = self.name,
skillName = self.name
})
end,
end
}
local guojia = General:new(extension, "guojia", "wei", 3)
Fk:addSkill(yiji_active)
@ -360,14 +391,14 @@ local luoshen = fk.CreateTriggerSkill{
local judge = {
who = player,
reason = self.name,
pattern = ".|.|spade,club",
pattern = ".|.|spade,club"
}
room:judge(judge)
if judge.card.color ~= Card.Black or player.dead or not room:askForSkillInvoke(player, self.name) then
break
end
end
end,
end
}
local luoshen_obtain = fk.CreateTriggerSkill {
name = "#luoshen_obtain",
@ -375,10 +406,11 @@ local luoshen_obtain = fk.CreateTriggerSkill{
frequency = Skill.Compulsory,
events = { fk.FinishJudge },
can_trigger = function(self, event, target, player, data)
return target == player and data.reason == "luoshen" and data.card.color == Card.Black end,
return target == player and data.reason == "luoshen" and data.card.color == Card.Black
end,
on_use = function(self, event, target, player, data)
player.room:obtainCard(player.id, data.card)
end,
end
}
luoshen:addRelatedSkill(luoshen_obtain)
local qingguo = fk.CreateViewAsSkill {
@ -386,9 +418,10 @@ local qingguo = fk.CreateViewAsSkill{
anim_type = "defensive",
pattern = "jink",
card_filter = function(self, to_select, selected)
if #selected == 1 then return false end
return Fk:getCardById(to_select).color == Card.Black
and Fk:currentRoom():getCardArea(to_select) == Player.Hand
if #selected == 1 then
return false
end
return Fk:getCardById(to_select).color == Card.Black and Fk:currentRoom():getCardArea(to_select) == Player.Hand
end,
view_as = function(self, cards)
if #cards ~= 1 then
@ -398,7 +431,7 @@ local qingguo = fk.CreateViewAsSkill{
c.skillName = self.name
c:addSubcard(cards[1])
return c
end,
end
}
local zhenji = General:new(extension, "zhenji", "wei", 3, 3, General.Female)
zhenji:addSkill(luoshen)
@ -430,7 +463,7 @@ local rende = fk.CreateActiveSkill{
skillName = self.name
}
end
end,
end
}
local jijiang = fk.CreateViewAsSkill {
@ -449,15 +482,17 @@ local jijiang = fk.CreateViewAsSkill{
return c
end,
enabled_at_play = function(self, player)
return player:getMark("jijiang-failed-phase") == 0 and not table.every(Fk:currentRoom().alive_players, function(p)
return player:getMark("jijiang-failed-phase") == 0 and
not table.every(Fk:currentRoom().alive_players, function(p)
return p == player or p.kingdom ~= "shu"
end)
end,
enabled_at_response = function(self, player)
return not table.every(Fk:currentRoom().alive_players, function(p)
return player:getMark("jijiang-failed-phase") == 0 and
not table.every(Fk:currentRoom().alive_players, function(p)
return p == player or p.kingdom ~= "shu"
end)
end,
end
}
local jijiangResponse = fk.CreateTriggerSkill {
name = "#jijiangResponse",
@ -468,40 +503,34 @@ local jijiangResponse = fk.CreateTriggerSkill{
return target == player and player:hasSkill(self.name, true) and table.contains(data.card.skillNames, "jijiang")
end,
on_cost = function(self, event, target, player, data)
local room = player.room
room:doIndicate(player.id, TargetGroup:getRealTargets(data.tos))
player.room:doIndicate(player.id, TargetGroup:getRealTargets(data.tos))
return true
end,
on_use = function(self, event, target, player, data)
local room = player.room
for _, p in ipairs(room:getOtherPlayers(player)) do
if p.kingdom == "shu" then
local shus = table.filter(room:getOtherPlayers(player), function(p)
return p.kingdom == "shu"
end)
room:doIndicate(player.id, table.map(shus, function(p)
return p.id
end))
for _, p in ipairs(shus) do
local cardResponded = room:askForResponse(p, "slash", "slash", "#jijiang-ask:" .. player.id, true)
if cardResponded then
room:responseCard({
from = p.id,
card = cardResponded,
skipDrop = true,
})
data.card = cardResponded
data.card = cardResponded.card
return false
end
end
end
if event == fk.PreCardUse and player.phase == Player.Play then
room:setPlayerMark(player, "jijiang-failed-phase", 1)
end
return true
end,
refresh_events = {fk.CardUsing},
refresh_events = { fk.CardUsing, fk.CardResponding },
can_refresh = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name, true) and player:getMark("jijiang-failed-phase") > 0
return player:hasSkill(self.name, true) and player:getMark("jijiang-failed-phase") > 0
end,
on_refresh = function(self, event, target, player, data)
player.room:setPlayerMark(player, "jijiang-failed-phase", 0)
end,
end
}
jijiang:addRelatedSkill(jijiangResponse)
@ -514,7 +543,9 @@ local wusheng = fk.CreateViewAsSkill{
anim_type = "offensive",
pattern = "slash",
card_filter = function(self, to_select, selected)
if #selected == 1 then return false end
if #selected == 1 then
return false
end
return Fk:getCardById(to_select).color == Card.Red
end,
view_as = function(self, cards)
@ -525,7 +556,7 @@ local wusheng = fk.CreateViewAsSkill{
c.skillName = self.name
c:addSubcard(cards[1])
return c
end,
end
}
local guanyu = General:new(extension, "guanyu", "shu", 4)
guanyu:addSkill(wusheng)
@ -535,8 +566,7 @@ local paoxiaoAudio = fk.CreateTriggerSkill{
visible = false,
refresh_events = { fk.CardUsing },
can_refresh = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.card.trueName == "slash" and
return target == player and player:hasSkill(self.name) and data.card.trueName == "slash" and
player:usedCardTimes("slash") > 1
end,
on_refresh = function(self, event, target, player, data)
@ -544,19 +574,18 @@ local paoxiaoAudio = fk.CreateTriggerSkill{
player.room:doAnimate("InvokeSkill", {
name = "paoxiao",
player = player.id,
skill_type = "offensive",
skill_type = "offensive"
})
end,
end
}
local paoxiao = fk.CreateTargetModSkill {
name = "paoxiao",
frequency = Skill.Compulsory,
bypass_times = function(self, player, skill, scope)
if player:hasSkill(self.name) and skill.trueName == "slash_skill"
and scope == Player.HistoryPhase then
if player:hasSkill(self.name) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
return true
end
end,
end
}
paoxiao:addRelatedSkill(paoxiaoAudio)
local zhangfei = General:new(extension, "zhangfei", "shu", 4)
@ -567,20 +596,23 @@ local guanxing = fk.CreateTriggerSkill{
anim_type = "control",
events = { fk.EventPhaseStart },
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
player.phase == Player.Start
return target == player and player:hasSkill(self.name) and player.phase == Player.Start
end,
on_use = function(self, event, target, player, data)
local room = player.room
room:askForGuanxing(player, room:getNCards(math.min(5, #room.alive_players)))
end,
end
}
local kongchengAudio = fk.CreateTriggerSkill {
name = "#kongchengAudio",
refresh_events = { fk.AfterCardsMove },
can_refresh = function(self, event, target, player, data)
if not player:hasSkill(self.name) then return end
if not player:isKongcheng() then return end
if not player:hasSkill(self.name) then
return
end
if not player:isKongcheng() then
return
end
for _, move in ipairs(data) do
if move.from == player.id then
for _, info in ipairs(move.moveInfo) do
@ -594,7 +626,7 @@ local kongchengAudio = fk.CreateTriggerSkill{
on_refresh = function(self, event, target, player, data)
player:broadcastSkillInvoke("kongcheng")
player.room:notifySkillInvoked(player, "kongcheng", "defensive")
end,
end
}
local kongcheng = fk.CreateProhibitSkill {
name = "kongcheng",
@ -603,7 +635,7 @@ local kongcheng = fk.CreateProhibitSkill{
if to:hasSkill(self.name) and to:isKongcheng() then
return card.trueName == "slash" or card.trueName == "duel"
end
end,
end
}
kongcheng:addRelatedSkill(kongchengAudio)
local zhugeliang = General:new(extension, "zhugeliang", "shu", 3)
@ -614,7 +646,9 @@ local longdan = fk.CreateViewAsSkill{
name = "longdan",
pattern = "slash,jink",
card_filter = function(self, to_select, selected)
if #selected == 1 then return false end
if #selected == 1 then
return false
end
local _c = Fk:getCardById(to_select)
local c
if _c.trueName == "slash" then
@ -624,7 +658,8 @@ local longdan = fk.CreateViewAsSkill{
else
return false
end
return (Fk.currentResponsePattern == nil and Self:canUse(c)) or (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(c))
return (Fk.currentResponsePattern == nil and Self:canUse(c)) or
(Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(c))
end,
view_as = function(self, cards)
if #cards ~= 1 then
@ -640,7 +675,7 @@ local longdan = fk.CreateViewAsSkill{
c.skillName = self.name
c:addSubcard(cards[1])
return c
end,
end
}
local zhaoyun = General:new(extension, "zhaoyun", "shu", 4)
zhaoyun:addSkill(longdan)
@ -652,28 +687,28 @@ local mashu = fk.CreateDistanceSkill{
if from:hasSkill(self.name) then
return -1
end
end,
end
}
local tieqi = fk.CreateTriggerSkill {
name = "tieqi",
anim_type = "offensive",
events = { fk.TargetSpecified },
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.card.trueName == "slash"
player.tieqi_tos = data.tos
return target == player and player:hasSkill(self.name) and data.card.trueName == "slash"
end,
on_use = function(self, event, target, player, data)
local room = player.room
local judge = {
who = player,
reason = self.name,
pattern = ".|.|heart,diamond",
pattern = ".|.|heart,diamond"
}
room:judge(judge)
if judge.card.color == Card.Red then
data.disresponsive = true
end
end,
end
}
local machao = General:new(extension, "machao", "shu", 4)
machao:addSkill(mashu)
@ -689,14 +724,14 @@ local jizhi = fk.CreateTriggerSkill{
end,
on_use = function(self, event, target, player, data)
player:drawCards(1, self.name)
end,
end
}
local qicai = fk.CreateTargetModSkill {
name = "qicai",
frequency = Skill.Compulsory,
bypass_distances = function(self, player, skill, card)
return player:hasSkill(self.name) and card and card.type == Card.TypeTrick
end,
end
}
local huangyueying = General:new(extension, "huangyueying", "shu", 3, 3, General.Female)
huangyueying:addSkill(jizhi)
@ -723,18 +758,12 @@ local jiuyuan = fk.CreateTriggerSkill{
frequency = Skill.Compulsory,
events = { fk.PreHpRecover },
can_trigger = function(self, event, target, player, data)
return
target == player and
player:hasSkill(self.name) and
data.card and
data.card.trueName == "peach" and
data.recoverBy and
data.recoverBy.kingdom == "wu" and
data.recoverBy ~= player
return target == player and player:hasSkill(self.name) and data.card and data.card.trueName == "peach" and
data.recoverBy and data.recoverBy.kingdom == "wu" and data.recoverBy ~= player
end,
on_use = function(self, event, target, player, data)
data.num = data.num + 1
end,
end
}
local sunquan = General:new(extension, "sunquan", "wu", 4)
@ -746,7 +775,9 @@ local qixi = fk.CreateViewAsSkill{
anim_type = "control",
pattern = "dismantlement",
card_filter = function(self, to_select, selected)
if #selected == 1 then return false end
if #selected == 1 then
return false
end
return Fk:getCardById(to_select).color == Card.Black
end,
view_as = function(self, cards)
@ -757,7 +788,7 @@ local qixi = fk.CreateViewAsSkill{
c.skillName = self.name
c:addSubcard(cards[1])
return c
end,
end
}
local ganning = General:new(extension, "ganning", "wu", 4)
ganning:addSkill(qixi)
@ -767,10 +798,8 @@ local keji = fk.CreateTriggerSkill{
anim_type = "defensive",
events = { fk.EventPhaseChanging },
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and
data.to == Player.Discard and
player:usedCardTimes("slash") < 1 and
player:getMark("_keji_played_slash") == 0
return target == player and player:hasSkill(self.name) and data.to == Player.Discard and
player:usedCardTimes("slash") < 1 and player:getMark("_keji_played_slash") == 0
end,
on_use = function(self, event, target, player, data)
return true
@ -822,14 +851,16 @@ local yingzi = fk.CreateTriggerSkill{
events = { fk.DrawNCards },
on_use = function(self, event, target, player, data)
data.n = data.n + 1
end,
end
}
local fanjian = fk.CreateActiveSkill {
name = "fanjian",
can_use = function(self, player)
return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and not player:isKongcheng()
end,
card_filter = function() return false end,
card_filter = function()
return false
end,
target_filter = function(self, to_select, selected)
return #selected == 0 and to_select ~= Self.id
end,
@ -845,10 +876,10 @@ local fanjian = fk.CreateActiveSkill{
from = player,
to = target,
damage = 1,
skillName = self.name,
skillName = self.name
}
end
end,
end
}
local zhouyu = General:new(extension, "zhouyu", "wu", 3)
zhouyu:addSkill(yingzi)
@ -859,7 +890,9 @@ local guose = fk.CreateViewAsSkill{
anim_type = "control",
pattern = "indulgence",
card_filter = function(self, to_select, selected)
if #selected == 1 then return false end
if #selected == 1 then
return false
end
return Fk:getCardById(to_select).suit == Card.Diamond
end,
view_as = function(self, cards)
@ -870,20 +903,20 @@ local guose = fk.CreateViewAsSkill{
c.skillName = self.name
c:addSubcard(cards[1])
return c
end,
end
}
local liuli = fk.CreateTriggerSkill {
name = "liuli",
anim_type = "defensive",
events = { fk.TargetConfirming },
can_trigger = function(self, event, target, player, data)
local ret = target == player and player:hasSkill(self.name) and
data.card.trueName == "slash"
local ret = target == player and player:hasSkill(self.name) and data.card.trueName == "slash"
if ret then
local room = player.room
local from = room:getPlayerById(data.from)
for _, p in ipairs(room.alive_players) do
if p ~= player and p.id ~= data.from and player:inMyAttackRange(p) and not from:isProhibited(p, data.card) then
if p ~= player and p.id ~= data.from and player:inMyAttackRange(p) and
not from:isProhibited(p, data.card) then
return true
end
end
@ -899,7 +932,9 @@ local liuli = fk.CreateTriggerSkill{
table.insert(targets, p.id)
end
end
if #targets == 0 then return false end
if #targets == 0 then
return false
end
local plist, cid = room:askForChooseCardAndPlayers(player, targets, 1, 1, nil, prompt, self.name, true)
if #plist > 0 then
self.cost_data = { plist[1], cid }
@ -913,7 +948,7 @@ local liuli = fk.CreateTriggerSkill{
room:throwCard(self.cost_data[2], self.name, player, player)
TargetGroup:removeTarget(data.targetGroup, player.id)
TargetGroup:pushTargets(data.targetGroup, to)
end,
end
}
local daqiao = General:new(extension, "daqiao", "wu", 3, 3, General.Female)
daqiao:addSkill(guose)
@ -926,15 +961,19 @@ local qianxun = fk.CreateProhibitSkill{
if to:hasSkill(self.name) then
return card.name == "indulgence" or card.name == "snatch"
end
end,
end
}
local lianying = fk.CreateTriggerSkill {
name = "lianying",
anim_type = "drawcard",
events = { fk.AfterCardsMove },
can_trigger = function(self, event, target, player, data)
if not player:hasSkill(self.name) then return end
if not player:isKongcheng() then return end
if not player:hasSkill(self.name) then
return
end
if not player:isKongcheng() then
return
end
for _, move in ipairs(data) do
if move.from == player.id then
for _, info in ipairs(move.moveInfo) do
@ -947,7 +986,7 @@ local lianying = fk.CreateTriggerSkill{
end,
on_use = function(self, event, target, player, data)
player:drawCards(1, self.name)
end,
end
}
local luxun = General:new(extension, "luxun", "wu", 3)
luxun:addSkill(qianxun)
@ -958,7 +997,9 @@ local xiaoji = fk.CreateTriggerSkill{
anim_type = "drawcard",
events = { fk.AfterCardsMove },
can_trigger = function(self, event, target, player, data)
if not player:hasSkill(self.name) then return end
if not player:hasSkill(self.name) then
return
end
for _, move in ipairs(data) do
if move.from == player.id then
for _, info in ipairs(move.moveInfo) do
@ -982,7 +1023,9 @@ local xiaoji = fk.CreateTriggerSkill{
end
self.cancel_cost = false
for i = 1, i do
if self.cancel_cost or not player:hasSkill(self.name) then break end
if self.cancel_cost or not player:hasSkill(self.name) then
break
end
self:doCost(event, target, player, data)
end
end,
@ -994,7 +1037,7 @@ local xiaoji = fk.CreateTriggerSkill{
end,
on_use = function(self, event, target, player, data)
player:drawCards(2, self.name)
end,
end
}
local jieyin = fk.CreateActiveSkill {
name = "jieyin",
@ -1007,9 +1050,7 @@ local jieyin = fk.CreateActiveSkill{
end,
target_filter = function(self, to_select, selected)
local target = Fk:currentRoom():getPlayerById(to_select)
return target:isWounded() and
target.gender == General.Male
and #selected < 1 and to_select ~= Self.id
return target:isWounded() and target.gender == General.Male and #selected < 1 and to_select ~= Self.id
end,
target_num = 1,
card_num = 2,
@ -1059,14 +1100,16 @@ local qingnang = fk.CreateActiveSkill{
recoverBy = from,
skillName = self.name
})
end,
end
}
local jijiu = fk.CreateViewAsSkill {
name = "jijiu",
anim_type = "support",
pattern = "peach",
card_filter = function(self, to_select, selected)
if #selected == 1 then return false end
if #selected == 1 then
return false
end
return Fk:getCardById(to_select).color == Card.Red
end,
view_as = function(self, cards)
@ -1083,7 +1126,7 @@ local jijiu = fk.CreateViewAsSkill{
end,
enabled_at_response = function(self, player)
return player.phase == Player.NotActive
end,
end
}
local huatuo = General:new(extension, "huatuo", "qun", 3)
huatuo:addSkill(qingnang)
@ -1114,7 +1157,7 @@ local wushuang = fk.CreateTriggerSkill{
data.fixedAddTimesResponsors = data.fixedAddTimesResponsors or {}
table.insert(data.fixedAddTimesResponsors, (event == fk.TargetSpecified and data.to or data.from))
end
end,
end
}
local lvbu = General:new(extension, "lvbu", "qun", 4)
lvbu:addSkill(wushuang)
@ -1129,8 +1172,8 @@ local lijian = fk.CreateActiveSkill{
return #selected == 0
end,
target_filter = function(self, to_select, selected)
return #selected < 2 and to_select ~= Self.id and
Fk:currentRoom():getPlayerById(to_select).gender == General.Male
return #selected < 2 and to_select ~= Self.id and Fk:currentRoom():getPlayerById(to_select).gender ==
General.Male
end,
target_num = 2,
min_card_num = 1,
@ -1143,22 +1186,21 @@ local lijian = fk.CreateActiveSkill{
from = use.tos[2],
tos = { { use.tos[1] } },
card = duel,
prohibitedCardNames = { "nullification" },
prohibitedCardNames = { "nullification" }
}
room:useCard(new_use)
end,
end
}
local biyue = fk.CreateTriggerSkill {
name = "biyue",
anim_type = "drawcard",
events = { fk.EventPhaseStart },
can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name)
and player.phase == Player.Finish
return target == player and player:hasSkill(self.name) and player.phase == Player.Finish
end,
on_use = function(self, event, target, player, data)
player:drawCards(1, self.name)
end,
end
}
local diaochan = General:new(extension, "diaochan", "qun", 3, 3, General.Female)
diaochan:addSkill(lijian)
@ -1174,16 +1216,12 @@ local role_mode = fk.CreateGameMode{
surrender_func = function(self, playedTime)
local roleCheck = false
local roleText = ""
local roleTable = {
{ "lord" },
{ "lord", "rebel" },
{ "lord", "rebel", "renegade" },
local roleTable = { { "lord" }, { "lord", "rebel" }, { "lord", "rebel", "renegade" },
{ "lord", "loyalist", "rebel", "renegade" },
{ "lord", "loyalist", "rebel", "rebel", "renegade" },
{ "lord", "loyalist", "rebel", "rebel", "rebel", "renegade" },
{ "lord", "loyalist", "loyalist", "rebel", "rebel", "rebel", "renegade" },
{ "lord", "loyalist", "loyalist", "rebel", "rebel", "rebel", "rebel", "renegade" },
}
{ "lord", "loyalist", "loyalist", "rebel", "rebel", "rebel", "rebel", "renegade" } }
roleTable = roleTable[#Fk:currentRoom().players]
@ -1230,7 +1268,10 @@ local role_mode = fk.CreateGameMode{
roleText = "left one rebel alive"
else
if Self.role == "loyalist" then
return { { text = "loyalist never surrender", passed = false } }
return { {
text = "loyalist never surrender",
passed = false
} }
else
if #Fk:currentRoom().alive_players == 2 then
roleCheck = true
@ -1263,11 +1304,14 @@ local role_mode = fk.CreateGameMode{
roleText = "left you alive"
end
return {
{ text = "time limitation: 5 min", passed = playedTime >= 300 },
{ text = roleText, passed = roleCheck },
}
end,
return { {
text = "time limitation: 5 min",
passed = playedTime >= 300
}, {
text = roleText,
passed = roleCheck
} }
end
}
extension:addGameMode(role_mode)
Fk:loadTranslationTable {
@ -1275,7 +1319,7 @@ Fk:loadTranslationTable{
["left lord and loyalist alive"] = "仅剩你和主忠方存活",
["left one rebel alive"] = "反贼仅剩你存活且不存在存活内奸",
["left you alive"] = "主忠方仅剩你存活且其他阵营仅剩一方",
["loyalist never surrender"] = "忠臣永不投降!",
["loyalist never surrender"] = "忠臣永不投降!"
}
local anjiang = General(extension, "anjiang", "unknown", 5)
@ -1283,7 +1327,7 @@ anjiang.gender = General.Agender
anjiang.total_hidden = true
Fk:loadTranslationTable {
["anjiang"] = "暗将",
["anjiang"] = "暗将"
}
-- load translations of this package

View File

@ -0,0 +1,227 @@
fk.ai_use_play.rende = function(self, skill)
for _, p in ipairs(self.friends_noself) do
if p.kingdom == "shu" and #self.player:getCardIds("h") >= self.player.hp then
self.use_id = {}
for _, cid in ipairs(self.player:getCardIds("h")) do
if #self.use_id < #self.player:getCardIds("h") / 2 then
table.insert(self.use_id, cid)
end
end
self.use_tos = { p.id }
return
end
end
for _, p in ipairs(self.friends_noself) do
if #self.player:getCardIds("h") >= self.player.hp then
self.use_id = {}
for _, cid in ipairs(self.player:getCardIds("h")) do
if #self.use_id < #self.player:getCardIds("h") / 2 then
table.insert(self.use_id, cid)
end
end
self.use_tos = { p.id }
return
end
end
end
fk.ai_card.jijiang = { priority = 10 }
fk.ai_use_play.lijian = function(self, skill)
local c = Fk:cloneCard("duel")
c.skillName = "lijian"
for _, p in ipairs(self.enemies) do
for _, pt in ipairs(self.enemies) do
if p.gender == General.Male and pt.gender == General.Male and p.id ~= pt.id and
c.skill:targetFilter(pt.id, {}, p.id, c) then
self.use_id = { self.player:getCardIds("he")[1] }
self.use_tos = { pt.id, p.id }
break
end
end
end
for _, p in ipairs(self.friends_noself) do
for _, pt in ipairs(self.enemies) do
if p.gender == General.Male and pt.gender == General.Male and p.id ~= pt.id and
c.skill:targetFilter(pt.id, {}, p.id, c) then
self.use_id = { self.player:getCardIds("he")[1] }
self.use_tos = { pt.id, p.id }
break
end
end
end
end
fk.ai_card.lijian = { priority = 2 }
fk.ai_use_play.zhiheng = function(self, skill)
local card_ids = {}
for _, h in ipairs(self.player:getCardIds("he")) do
if #card_ids < #self.player:getCardIds("he") / 2 then
table.insert(card_ids, h)
end
end
if #card_ids > 0 then
self.use_id = card_ids
end
end
fk.ai_use_play.kurou = function(self, skill)
if #self:getActives("peach") + self.player.hp > 1 then
local slash = Fk:cloneCard("slash")
if slash.skill:canUse(self.player, slash) and not self.player:prohibitUse(slash) then
fk.ai_use_play.slash(self, slash)
if self.use_id then
self.use_id = {}
self.use_tos = {}
end
end
end
end
fk.ai_use_play.fanjian = function(self, skill)
for _, p in ipairs(self.enemies) do
if #self.player:getCardIds("h") > 0 then
self.use_id = {}
table.insert(self.use_tos, p.id)
break
end
end
end
fk.ai_use_play.jieyin = function(self, skill)
for cs, p in ipairs(self.friends_noself) do
cs = self.player:getCardIds("h")
if #cs > 1 and p.gender == General.Male and p:isWounded() then
self.use_id = { cs[1], cs[2] }
table.insert(self.use_tos, p.id)
break
end
end
end
fk.ai_use_play.qingnang = function(self, skill)
for cs, p in ipairs(self.friends) do
cs = self.player:getCardIds("h")
if #cs > 0 and p:isWounded() then
self.use_id = { cs[1] }
table.insert(self.use_tos, p.id)
break
end
end
end
fk.ai_skill_invoke.jianxiong = true
fk.ai_card.hujia = { priority = 10 }
fk.ai_response_card["#hujia-ask"] = function(self, pattern, prompt, cancelable, data)
local to = self.room:getPlayerById(tonumber(prompt:split(":")[2]))
if to and self:isFriend(to) then
self:setUseId(pattern)
end
end
fk.ai_response_card["#jijiang-ask"] = fk.ai_response_card["#hujia-ask"]
fk.ai_skill_invoke.fankui = function(self, data, prompt)
local damage = self:eventData("Damage")
return damage and damage.from and not self:isFriend(damage.from)
end
fk.ai_response_card["#guicai-ask"] = function(self, pattern, prompt, cancelable, data)
local cards = table.map(self.player:getHandlyIds(true), function(id)
return Fk:getCardById(id)
end)
local id = self:getRetrialCardId(cards)
if id then
self.use_id = id
end
end
fk.ai_skill_invoke.ganglie = function(self, data, prompt)
local damage = self:eventData("Damage")
return damage and damage.from and not self:isFriend(damage.from)
end
fk.ai_skill_invoke.luoyi = function(self, data, prompt)
for _, p in ipairs(self.enemies) do
if #self:getActives("slash") > 0 and not self:isWeak() then
return true
end
end
end
fk.ai_skill_invoke.tiandu = true
fk.ai_skill_invoke.yiji = true
fk.ai_skill_invoke.luoshen = true
fk.ai_skill_invoke.guanxing = true
fk.ai_skill_invoke.tieqi = function(self, data, prompt)
local use = self:eventData("UseCard")
for _, p in ipairs(TargetGroup:getRealTargets(use.tos)) do
p = self.room:getPlayerById(p)
if self:isEnemie(p) then
return true
end
end
end
fk.ai_skill_invoke.jizhi = true
fk.ai_skill_invoke.keji = true
fk.ai_skill_invoke.yingzi = true
fk.ai_skill_invoke.lianying = true
fk.ai_skill_invoke.xiaoji = true
fk.ai_skill_invoke.biyue = true
fk.ai_choose_players.tuxi = function(self, targets, min_num, num, cancelable)
for _, pid in ipairs(targets) do
local p = self.room:getPlayerById(pid)
if self:isEnemie(p) and #self.use_tos < num then
table.insert(self.use_tos, pid)
end
end
end
fk.ai_use_skill.yiji_active = function(self, prompt, cancelable, data)
for _, p in ipairs(self.friends_noself) do
for c, cid in ipairs(self.player.yiji_ids) do
c = Fk:getCardById(cid)
if c:getMark("yiji") > 0 and c.skill:canUse(p, c) then
self.use_tos = { p.id }
self.use_id = json.encode {
skill = "yiji_active",
subcards = { cid }
}
return
end
end
end
end
fk.ai_choose_players.liuli = function(self, targets, min_num, num, cancelable)
for _, pid in ipairs(targets) do
local p = self.room:getPlayerById(pid)
if self:isEnemie(p) and #self.use_tos < num and #self.player:getCardIds("he") > 0 then
table.insert(self.use_tos, pid)
self.use_id = { self.player:getCardIds("he")[1] }
return
end
end
for _, pid in ipairs(targets) do
local p = self.room:getPlayerById(pid)
if not self:isFriend(p) and #self.use_tos < num and #self.player:getCardIds("he") > 0 then
table.insert(self.use_tos, pid)
self.use_id = { self.player:getCardIds("he")[1] }
return
end
end
end

View File

@ -50,13 +50,12 @@ Fk:loadTranslationTable{
["slash"] = "",
[":slash"] = "基本牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:攻击范围内的一名其他角色<br /><b>效果</b>对目标角色造成1点伤害。",
["#slash-jink"] = "%src 对你使用了杀,请使用 %arg 张闪",
["#slash-jinks"] = "%src 对你使用了杀,需 %arg2 张闪,你还需使用 %arg 张闪",
["jink"] = "",
[":jink"] = "基本牌<br /><b>时机</b>:【杀】对你生效时<br /><b>目标</b>:此【杀】<br /><b>效果</b>:抵消此【杀】的效果。",
["peach"] = "",
[":peach"] = "基本牌<br /><b>时机</b>:出牌阶段/一名角色处于濒死状态时<br /><b>目标</b>:已受伤的你/处于濒死状态的角色<br /><b>效果</b>目标角色回复1点体力。",
["dismantlement"] = "过河拆桥",
[":dismantlement"] = "锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:一名区域内有牌的其他角色。<br /><b>效果</b>:你弃置目标角色区域内的一张牌。",
["dismantlement_skill"] = "过河拆桥",
@ -67,26 +66,19 @@ Fk:loadTranslationTable{
["duel"] = "决斗",
[":duel"] = "锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:一名其他角色<br /><b>效果</b>由目标角色开始你与其轮流打出一张【杀】否则受到对方的1点伤害并结束此牌结算。",
["collateral"] = "借刀杀人",
[":collateral"] = "锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>装备区内有武器牌且攻击范围内有【杀】的合法目标的一名其他角色A你需要选择一名A攻击范围内的【杀】的合法目标B<br /><b>效果</b>A须对B使用一张【杀】否则你获得A装备区内的武器牌。",
["#collateral-slash"] = "借刀杀人:你需对 %dest 使用【杀】,否则 %src 获得你的武器",
["ex_nihilo"] = "无中生有",
[":ex_nihilo"] = "锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:你<br /><b>效果</b>:目标角色摸两张牌。",
["nullification"] = "无懈可击",
[":nullification"] = "锦囊牌<br /><b>时机</b>:锦囊牌对目标角色生效前,或一张【无懈可击】生效前<br /><b>目标</b>:该锦囊牌<br /><b>效果</b>:抵消该锦囊牌对该角色产生的效果,或抵消另一张【无懈可击】产生的效果。",
["savage_assault"] = "南蛮入侵",
[":savage_assault"] = "锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:所有其他角色<br /><b>效果</b>每名目标角色须打出一张【杀】否则受到1点伤害。",
["archery_attack"] = "万箭齐发",
[":archery_attack"] = "锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:所有其他角色<br /><b>效果</b>每名目标角色须打出一张【闪】否则受到1点伤害。",
["god_salvation"] = "桃园结义",
[":god_salvation"] = "锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:所有角色<br /><b>效果</b>每名目标角色回复1点体力。",
["amazing_grace"] = "五谷丰登",
[":amazing_grace"] = "锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:所有角色<br /><b>效果</b>:你亮出牌堆顶等于角色数的牌,每名目标角色获得其中一张牌,然后将其余的牌置入弃牌堆。",
["amazing_grace_skill"] = "五谷选牌",
@ -94,16 +86,12 @@ Fk:loadTranslationTable{
["lightning"] = "闪电",
[":lightning"] = "延时锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:你<br /><b>效果</b>将此牌置于目标角色判定区内。其判定阶段进行判定若结果为黑桃2-9其受到3点雷电伤害并将【闪电】置入弃牌堆否则将【闪电】移动至其下家判定区内。",
["indulgence"] = "乐不思蜀",
[":indulgence"] = "延时锦囊牌<br /><b>时机</b>:出牌阶段<br /><b>目标</b>:一名其他角色<br /><b>效果</b>:将此牌置于目标角色判定区内。其判定阶段进行判定:若结果不为红桃,其跳过出牌阶段。然后将【乐不思蜀】置入弃牌堆。",
["crossbow"] = "诸葛连弩",
[":crossbow"] = "装备牌·武器<br /><b>攻击范围</b><br /><b>武器技能</b>:锁定技。你于出牌阶段内使用【杀】无次数限制。",
["qinggang_sword"] = "青釭剑",
[":qinggang_sword"] = "装备牌·武器<br /><b>攻击范围</b><br /><b>武器技能</b>:锁定技。你的【杀】无视目标角色的防具。",
["ice_sword"] = "寒冰剑",
[":ice_sword"] = "装备牌·武器<br /><b>攻击范围</b><br /><b>武器技能</b>:每当你使用【杀】对目标角色造成伤害时,若该角色有牌,你可以防止此伤害,然后依次弃置其两张牌。",
["#ice_sword_skill"] = "寒冰剑",
@ -130,7 +118,6 @@ Fk:loadTranslationTable{
["halberd"] = "方天画戟",
[":halberd"] = "装备牌·武器<br /><b>攻击范围</b><br /><b>武器技能</b>:锁定技。你使用最后的手牌【杀】可以额外选择至多两名目标。",
["kylin_bow"] = "麒麟弓",
[":kylin_bow"] = "装备牌·武器<br /><b>攻击范围</b><br /><b>武器技能</b>:每当你使用【杀】对目标角色造成伤害时,你可以弃置其装备区内的一张坐骑牌。",
["#kylin_bow_skill"] = "麒麟弓",

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,407 @@
fk.ai_card.slash = {
intention = 100, -- 身份值
value = 4, -- 卡牌价值
priority = 2.5 -- 使用优先值
}
fk.ai_card.peach = {
intention = -150,
value = 10,
priority = 0.5
}
fk.ai_card.dismantlement = {
intention = function(self, card, from)
if #self.player.player_cards[Player.Judge] < 1 then
return 80
elseif fk.ai_role[from.id] == "neutral" then
return 30
end
end,
value = 3.5,
priority = 10.5
}
fk.ai_card.snatch = {
intention = function(self, card, from)
if #self.player.player_cards[Player.Judge] < 1 then
return 80
elseif fk.ai_role[from.id] == "neutral" then
return 30
end
end,
value = 4.5,
priority = 10.4
}
fk.ai_card.duel = {
intention = 120,
value = 4.5,
priority = 3.5
}
fk.ai_card.collateral = {
intention = 20,
value = 3,
priority = 4.5
}
fk.ai_card.ex_nihilo = {
intention = -200,
value = 8,
priority = 10
}
fk.ai_card.savage_assault = {
intention = 20,
value = 2,
priority = 4
}
fk.ai_card.archery_attack = {
intention = 30,
value = 2,
priority = 3
}
fk.ai_card.god_salvation = {
intention = function(self, card, from)
if self.player.hp ~= self.player.maxHp then
return -45
end
end,
value = 1.5,
priority = 2
}
fk.ai_card.amazing_grace = {
intention = -30,
value = 2,
priority = 2
}
fk.ai_card.indulgence = {
intention = 150,
value = -1,
priority = 2
}
local function slashEeffect(slash, to)
for _, s in ipairs(to:getAllSkills()) do
if s.name == "#vine_skill" then
if slash.name == "slash" then
return
end
end
if s.name == "#nioh_shield_skill" then
if slash.color == Card.Black then
return
end
end
end
return true
end
fk.ai_use_play.slash = function(self, card)
self:sort(self.enemies)
for _, p in ipairs(self.enemies) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and slashEeffect(card, p) then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
end
fk.ai_askuse_card["#slash-jink"] = function(self, pattern, prompt, cancelable, extra_data)
local act = self:getActives(pattern)
if tonumber(prompt:split(":")[4]) > #act then
return
end
local cards =
table.map(
self.player:getCardIds("&he"),
function(id)
return Fk:getCardById(id)
end
)
self:sortValue(cards)
for _, sth in ipairs(act) do
if sth:isInstanceOf(Card) then
self.use_id = sth.id
break
else
local selected = {}
for _, c in ipairs(cards) do
if sth.cardFilter(sth, c.id, selected) then
table.insert(selected, c.id)
end
end
local tc = sth.viewAs(sth, selected)
if tc and tc:matchPattern(pattern) then
self.use_id =
json.encode {
skill = sth.name,
subcards = selected
}
break
end
end
end
end
fk.ai_askuse_card["#slash-jinks"] = fk.ai_askuse_card["#slash-jink"]
fk.ai_use_play.snatch = function(self, card)
for _, p in ipairs(self.friends_noself) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and #p:getCardIds("j") > 0 then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
self:sort(self.enemies)
for _, p in ipairs(self.enemies) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and #p:getCardIds("he") > 0 then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
end
fk.ai_nullification.snatch = function(self, card, to, from, positive)
if positive then
if self:isFriend(to) and not self:isFriend(from) and fk.ai_role[from.id] ~= "neutral" then
if #self.avail_cards > 1 or self:isWeak(to) or to.id == self.player.id then
self.use_id = self.avail_cards[1]
end
end
else
if self:isEnemie(to) and self:isEnemie(from) then
if #self.avail_cards > 1 or self:isWeak(to) then
self.use_id = self.avail_cards[1]
end
end
end
end
fk.ai_use_play.dismantlement = function(self, card)
for _, p in ipairs(self.friends_noself) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and #p:getCardIds("j") > 0 then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
self:sort(self.enemies)
for _, p in ipairs(self.enemies) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) and #p:getCardIds("he") > 0 then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
end
fk.ai_nullification.dismantlement = function(self, card, to, from, positive)
if positive then
if self:isFriend(to) and not self:isFriend(from) and fk.ai_role[from.id] ~= "neutral" then
if #self.avail_cards > 1 or self:isWeak(to) or to.id == self.player.id then
self.use_id = self.avail_cards[1]
end
end
else
if self:isEnemie(to) and self:isEnemie(from) then
if #self.avail_cards > 1 or self:isWeak(to) then
self.use_id = self.avail_cards[1]
end
end
end
end
fk.ai_use_play.indulgence = function(self, card)
self:sort(self.enemies, nil, true)
for _, p in ipairs(self.enemies) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
end
fk.ai_nullification.indulgence = function(self, card, to, from, positive)
if positive then
if self:isFriend(to) then
if #self.avail_cards > 1 or self:isWeak(to) or to.id == self.player.id then
self.use_id = self.avail_cards[1]
end
end
else
if self:isEnemie(to) then
if #self.avail_cards > 1 or self:isWeak(to) then
self.use_id = self.avail_cards[1]
end
end
end
end
fk.ai_use_play.collateral = function(self, card)
local max = (card.skill:getMaxTargetNum(self.player, card) - 1) * 2
self:sort(self.enemies)
for _, p in ipairs(self.enemies) do
if #self.use_tos < max and card.skill:targetFilter(p.id, {}, {}, card) then
for _, pt in ipairs(self.enemies) do
if p ~= pt and p:inMyAttackRange(pt) then
table.insert(self.use_tos, p.id)
table.insert(self.use_tos, pt.id)
self.use_id = card.id
break
end
end
end
end
for _, p in ipairs(self.friends_noself) do
if #self.use_tos < max and card.skill:targetFilter(p.id, {}, {}, card) then
for _, pt in ipairs(self.enemies) do
if p ~= pt and p:inMyAttackRange(pt) then
table.insert(self.use_tos, p.id)
table.insert(self.use_tos, pt.id)
self.use_id = card.id
break
end
end
end
end
end
fk.ai_nullification.collateral = function(self, card, to, from, positive)
if positive then
if self:isFriend(to) and self:isEnemie(from) then
if #self.avail_cards > 1 or self:isWeak(to) or to.id == self.player.id then
self.use_id = self.avail_cards[1]
end
end
end
end
fk.ai_nullification.ex_nihilo = function(self, card, to, from, positive)
if positive then
if self:isEnemie(to) then
if #self.avail_cards > 1 or self:isWeak(to) or to.id == self.player.id then
self.use_id = self.avail_cards[1]
end
end
else
if self:isFriend(to) then
if #self.avail_cards > 1 or self:isWeak(to) then
self.use_id = self.avail_cards[1]
end
end
end
end
fk.ai_nullification.savage_assault = function(self, card, to, from, positive)
if positive then
if self:isFriend(to) then
if #self.avail_cards > 1 or self:isWeak(to) or to.id == self.player.id then
self.use_id = self.avail_cards[1]
end
end
else
if self:isEnemie(to) then
if #self.avail_cards > 1 or self:isWeak(to) then
self.use_id = self.avail_cards[1]
end
end
end
end
fk.ai_nullification.archery_attack = function(self, card, to, from, positive)
if positive then
if self:isFriend(to) then
if #self.avail_cards > 1 or self:isWeak(to) or to.id == self.player.id then
self.use_id = self.avail_cards[1]
end
end
else
if self:isEnemie(to) then
if #self.avail_cards > 1 or self:isWeak(to) then
self.use_id = self.avail_cards[1]
end
end
end
end
fk.ai_nullification.god_salvation = function(self, card, to, from, positive)
if positive then
if self:isEnemie(to) and to.hp ~= to.maxHp then
if #self.avail_cards > 1 or self:isWeak(to) then
self.use_id = self.avail_cards[1]
end
end
else
if self:isFriend(to) and to.hp ~= to.maxHp then
if #self.avail_cards > 1 or self:isWeak(to) or to.id == self.player.id then
self.use_id = self.avail_cards[1]
end
end
end
end
fk.ai_use_play.ex_nihilo = function(self, card)
self.use_id = card.id
end
fk.ai_use_play.lightning = function(self, card)
self.use_id = #self.enemies > #self.friends and card.id
end
fk.ai_use_play.peach = function(self, card)
if self.command == "PlayCard" then
self.use_id = self.player.hp ~= self.player.maxHp and self.player.hp < #self.player:getCardIds("h") and card.id
else
for _, p in ipairs(self.friends) do
if p.dying then
self.use_id = card.id
self.use_tos = { p.id }
break
end
end
end
end
fk.ai_use_play.duel = function(self, card)
self:sort(self.enemies)
for _, p in ipairs(self.enemies) do
if card.skill:targetFilter(p.id, self.use_tos, {}, card) then
self.use_id = card.id
table.insert(self.use_tos, p.id)
end
end
end
fk.ai_skill_invoke["#ice_sword_skill"] = function(self)
local damage = self:eventData("Damage")
return self:isFriend(damage.to) or not self:isWeak(damage.to) and #damage.to:getCardIds("e") > 1
end
fk.ai_skill_invoke["#double_swords_skill"] = function(self)
local use = self:eventData("UseCard")
for _, p in ipairs(TargetGroup:getRealTargets(use.tos)) do
if not self:isFriend(p) and self.room:getPlayerById(p).gender ~= self.player.gender then
return true
end
end
end
fk.ai_dis_card["#double_swords_skill"] = function(self, min_num, num, include_equip, cancelable, pattern, prompt)
local use = self:eventData("UseCard")
return self:isEnemie(use.from) and { self.player:getCardIds("h")[1] }
end
fk.ai_dis_card["#axe_skill"] = function(self, min_num, num, include_equip, cancelable, pattern, prompt)
local ids = {}
for _, cid in ipairs(self.player:getCardIds("he")) do
if Fk:getCardById(cid):matchPattern(pattern) then
table.insert(ids, cid)
end
if
#ids >= min_num and self:isEnemie(self.player.axe_to) and
(self:isWeak(self.player.axe_to) or #self.player:getCardIds("he") > 3)
then
return ids
end
end
end
fk.ai_skill_invoke["#kylin_bow_skill"] = function(self)
local damage = self:eventData("Damage")
return not self:isFriend(damage.to)
end
fk.ai_skill_invoke["#eight_diagram_skill"] = true

View File

@ -90,12 +90,6 @@ local control = fk.CreateActiveSkill{
-- room:swapSeat(from, to)
for _, pid in ipairs(effect.tos) do
local to = room:getPlayerById(pid)
-- p(room:askForPoxi(from, "test", {
-- { "你自己", from:getCardIds "h" },
-- { "对方", to:getCardIds "h" },
-- }))
-- room:setPlayerMark(from, "@$a", {1,2,3})
-- room:setPlayerMark(from, "@$b", {'slash','duel','axe'})
if to:getMark("mouxushengcontrolled") == 0 then
room:addPlayerMark(to, "mouxushengcontrolled")
from:control(to)
@ -130,22 +124,6 @@ local control = fk.CreateActiveSkill{
-- room:useVirtualCard("slash", nil, from, room:getOtherPlayers(from), self.name, true)
end,
}
--[[
Fk:addPoxiMethod{
name = "test",
card_filter = function(to_select, selected, data)
local s = Fk:getCardById(to_select).suit
for _, id in ipairs(selected) do
if Fk:getCardById(id).suit == s then return false end
end
return true
end,
feasible = function(selected, data)
return #selected == 0 or #selected == 4
end,
prompt = "魄袭:选你们俩手牌总共四个花色,或者不选直接按确定按钮"
}
--]]
local test_vs = fk.CreateViewAsSkill{
name = "test_vs",
pattern = "nullification",