2023-04-09 05:35:35 +00:00
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-02-15 11:54:35 +00:00
|
|
|
local fkp_extensions = require "packages.test.test"
|
|
|
|
local extension = fkp_extensions[1]
|
|
|
|
|
2023-02-15 13:20:40 +00:00
|
|
|
local cheat = fk.CreateActiveSkill{
|
|
|
|
name = "cheat",
|
|
|
|
anim_type = "drawcard",
|
|
|
|
can_use = function(self, player)
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
on_use = function(self, room, effect)
|
|
|
|
local from = room:getPlayerById(effect.from)
|
|
|
|
local cardTypeName = room:askForChoice(from, { 'BasicCard', 'TrickCard', 'Equip' }, "cheat")
|
|
|
|
local cardType = Card.TypeBasic
|
|
|
|
if cardTypeName == 'TrickCard' then
|
|
|
|
cardType = Card.TypeTrick
|
|
|
|
elseif cardTypeName == 'Equip' then
|
|
|
|
cardType = Card.TypeEquip
|
|
|
|
end
|
|
|
|
|
|
|
|
local allCardIds = Fk:getAllCardIds()
|
|
|
|
local allCardMapper = {}
|
|
|
|
local allCardNames = {}
|
|
|
|
for _, id in ipairs(allCardIds) do
|
|
|
|
local card = Fk:getCardById(id)
|
|
|
|
if card.type == cardType then
|
|
|
|
if allCardMapper[card.name] == nil then
|
|
|
|
table.insert(allCardNames, card.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
allCardMapper[card.name] = allCardMapper[card.name] or {}
|
|
|
|
table.insert(allCardMapper[card.name], id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if #allCardNames == 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local cardName = room:askForChoice(from, allCardNames, "cheat")
|
|
|
|
local toGain = nil
|
|
|
|
if #allCardMapper[cardName] > 0 then
|
|
|
|
toGain = allCardMapper[cardName][math.random(1, #allCardMapper[cardName])]
|
|
|
|
end
|
|
|
|
|
2023-02-21 05:44:24 +00:00
|
|
|
from:addToPile(self.name, toGain, true, self.name)
|
2023-02-15 13:20:40 +00:00
|
|
|
room:obtainCard(effect.from, toGain, true, fk.ReasonPrey)
|
|
|
|
end
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
local test_filter = fk.CreateFilterSkill{
|
|
|
|
name = "test_filter",
|
|
|
|
card_filter = function(self, card)
|
2023-02-15 13:20:40 +00:00
|
|
|
return card.number > 11
|
2023-02-15 11:54:35 +00:00
|
|
|
end,
|
|
|
|
view_as = function(self, card)
|
2023-02-15 13:20:40 +00:00
|
|
|
return Fk:cloneCard("crossbow", card.suit, card.number)
|
2023-02-15 11:54:35 +00:00
|
|
|
end,
|
|
|
|
}
|
2023-02-21 05:44:24 +00:00
|
|
|
local test_active = fk.CreateActiveSkill{
|
|
|
|
name = "test_active",
|
|
|
|
can_use = function(self, player)
|
|
|
|
return true
|
|
|
|
end,
|
2023-03-04 17:28:59 +00:00
|
|
|
card_filter = function(self, card)
|
2023-04-13 12:17:39 +00:00
|
|
|
-- if self.interaction.data == "joy" then
|
2023-04-04 16:49:54 +00:00
|
|
|
--local c = Fk:getCardById(card)
|
|
|
|
--return Self:getPileNameOfId(card) == self.name and c.color == Card.Red
|
|
|
|
return true
|
2023-04-13 12:17:39 +00:00
|
|
|
-- end
|
2023-03-04 17:28:59 +00:00
|
|
|
end,
|
2023-04-04 16:49:54 +00:00
|
|
|
card_num = 2,
|
2023-03-01 13:41:16 +00:00
|
|
|
target_filter = function() return true end,
|
2023-04-19 16:19:48 +00:00
|
|
|
interaction = function()return UI.ComboBox {
|
2023-04-04 16:49:54 +00:00
|
|
|
choices = Fk.package_names,
|
|
|
|
-- default = "guanyu",
|
2023-04-19 16:19:48 +00:00
|
|
|
}end,
|
2023-02-21 05:44:24 +00:00
|
|
|
on_use = function(self, room, effect)
|
|
|
|
--room:doSuperLightBox("packages/test/qml/Test.qml")
|
|
|
|
local from = room:getPlayerById(effect.from)
|
2023-04-19 16:19:48 +00:00
|
|
|
print(self.interaction.data)
|
2023-03-01 13:41:16 +00:00
|
|
|
-- local result = room:askForCustomDialog(from, "simayi", "packages/test/qml/TestDialog.qml", "Hello, world. FROM LUA")
|
|
|
|
-- print(result)
|
|
|
|
|
|
|
|
-- room:fillAG(from, { 1, 43, 77 })
|
|
|
|
-- local id = room:askForAG(from, { 1, 43, 77 })
|
|
|
|
-- room:takeAG(from, id)
|
|
|
|
-- room:delay(2000)
|
|
|
|
-- room:closeAG(from)
|
2023-04-13 12:17:39 +00:00
|
|
|
-- local cards = room:askForCardsChosen(from, from, 2, 3, "hej", "")
|
|
|
|
-- from:addToPile(self.name, cards)
|
|
|
|
-- from.kingdom = "wei"
|
|
|
|
-- room:broadcastProperty(from, "kingdom")
|
2023-03-04 17:28:59 +00:00
|
|
|
-- p(cards)
|
2023-04-13 12:17:39 +00:00
|
|
|
room:useVirtualCard("slash", nil, from, room:getOtherPlayers(from), self.name, true)
|
2023-02-21 05:44:24 +00:00
|
|
|
end,
|
|
|
|
}
|
2023-04-08 12:45:55 +00:00
|
|
|
local test_vs = fk.CreateViewAsSkill{
|
|
|
|
name = "test_vs",
|
|
|
|
card_filter = function(self, to_select, selected)
|
|
|
|
return #selected == 0
|
|
|
|
end,
|
2023-04-13 12:17:39 +00:00
|
|
|
interaction = function(self)
|
|
|
|
return UI.ComboBox {
|
|
|
|
choices = {
|
|
|
|
"ex_nihilo",
|
|
|
|
"duel",
|
|
|
|
"snatch",
|
|
|
|
"dismantlement",
|
|
|
|
"savage_assault",
|
|
|
|
"archery_attack",
|
|
|
|
}
|
2023-04-08 12:45:55 +00:00
|
|
|
}
|
2023-04-13 12:17:39 +00:00
|
|
|
end,
|
2023-04-08 12:45:55 +00:00
|
|
|
view_as = function(self, cards)
|
|
|
|
if #cards ~= 1 then
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
if not self.interaction.data then return end
|
|
|
|
local c = Fk:cloneCard(self.interaction.data)
|
|
|
|
c.skillName = self.name
|
|
|
|
c:addSubcard(cards[1])
|
|
|
|
return c
|
|
|
|
end,
|
|
|
|
}
|
2023-02-21 05:44:24 +00:00
|
|
|
local test2 = General(extension, "mouxusheng", "wu", 4, 4, General.Female)
|
2023-04-13 12:17:39 +00:00
|
|
|
test2.shield = 4
|
2023-02-21 05:44:24 +00:00
|
|
|
test2:addSkill("rende")
|
2023-02-15 13:20:40 +00:00
|
|
|
test2:addSkill(cheat)
|
2023-02-21 05:44:24 +00:00
|
|
|
test2:addSkill(test_active)
|
2023-04-08 12:45:55 +00:00
|
|
|
test2:addSkill(test_vs)
|
2023-02-15 11:54:35 +00:00
|
|
|
|
|
|
|
Fk:loadTranslationTable{
|
|
|
|
["test"] = "测试",
|
|
|
|
["test_filter"] = "破军",
|
2023-02-15 13:20:40 +00:00
|
|
|
[":test_filter"] = "你的点数大于11的牌视为无中生有。",
|
2023-02-15 11:54:35 +00:00
|
|
|
["mouxusheng"] = "谋徐盛",
|
2023-02-15 13:20:40 +00:00
|
|
|
--["cheat"] = "开挂",
|
|
|
|
[":cheat"] = "出牌阶段,你可以获得一张想要的牌。",
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return fkp_extensions
|