2023-04-09 13:35:35 +08:00
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-05-19 07:45:08 +08:00
|
|
|
local extension = Package("test_p_0")
|
2023-02-15 19:54:35 +08:00
|
|
|
|
2023-02-15 21:20:40 +08: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
|
|
|
|
|
2023-05-28 18:45:54 +08:00
|
|
|
local cardName = room:askForChoice(from, allCardNames, "cheat", nil, nil, true)
|
2023-02-15 21:20:40 +08:00
|
|
|
local toGain = nil
|
|
|
|
if #allCardMapper[cardName] > 0 then
|
|
|
|
toGain = allCardMapper[cardName][math.random(1, #allCardMapper[cardName])]
|
|
|
|
end
|
|
|
|
|
2023-02-21 13:44:24 +08:00
|
|
|
from:addToPile(self.name, toGain, true, self.name)
|
2023-02-15 21:20:40 +08:00
|
|
|
room:obtainCard(effect.from, toGain, true, fk.ReasonPrey)
|
|
|
|
end
|
|
|
|
}
|
2023-02-15 19:54:35 +08:00
|
|
|
local test_filter = fk.CreateFilterSkill{
|
|
|
|
name = "test_filter",
|
|
|
|
card_filter = function(self, card)
|
2023-02-15 21:20:40 +08:00
|
|
|
return card.number > 11
|
2023-02-15 19:54:35 +08:00
|
|
|
end,
|
|
|
|
view_as = function(self, card)
|
2023-02-15 21:20:40 +08:00
|
|
|
return Fk:cloneCard("crossbow", card.suit, card.number)
|
2023-02-15 19:54:35 +08:00
|
|
|
end,
|
|
|
|
}
|
2023-06-04 19:39:20 +08:00
|
|
|
local control = fk.CreateActiveSkill{
|
|
|
|
name = "control",
|
2023-02-21 13:44:24 +08:00
|
|
|
can_use = function(self, player)
|
|
|
|
return true
|
|
|
|
end,
|
2023-03-05 01:28:59 +08:00
|
|
|
card_filter = function(self, card)
|
2023-04-13 20:17:39 +08:00
|
|
|
-- if self.interaction.data == "joy" then
|
2023-04-05 00:49:54 +08:00
|
|
|
--local c = Fk:getCardById(card)
|
|
|
|
--return Self:getPileNameOfId(card) == self.name and c.color == Card.Red
|
2023-06-04 19:39:20 +08:00
|
|
|
return false
|
2023-04-13 20:17:39 +08:00
|
|
|
-- end
|
2023-03-05 01:28:59 +08:00
|
|
|
end,
|
2023-06-04 19:39:20 +08:00
|
|
|
card_num = 0,
|
|
|
|
target_filter = function(self, to_select)
|
|
|
|
return to_select ~= Self.id
|
|
|
|
end,
|
|
|
|
min_target_num = 1,
|
|
|
|
--interaction = function()return UI.Spin {
|
2023-04-30 00:52:39 +08:00
|
|
|
--choices = Fk.package_names,
|
2023-06-04 19:39:20 +08:00
|
|
|
--from=2,to=8,
|
2023-04-05 00:49:54 +08:00
|
|
|
-- default = "guanyu",
|
2023-06-04 19:39:20 +08:00
|
|
|
--}end,
|
2023-02-21 13:44:24 +08:00
|
|
|
on_use = function(self, room, effect)
|
|
|
|
--room:doSuperLightBox("packages/test/qml/Test.qml")
|
|
|
|
local from = room:getPlayerById(effect.from)
|
2023-04-27 14:15:08 +08:00
|
|
|
-- room:swapSeat(from, to)
|
2023-06-04 19:39:20 +08:00
|
|
|
for _, pid in ipairs(effect.tos) do
|
|
|
|
local to = room:getPlayerById(pid)
|
|
|
|
if to:getMark("mouxushengcontrolled") == 0 then
|
|
|
|
room:addPlayerMark(to, "mouxushengcontrolled")
|
|
|
|
from:control(to)
|
|
|
|
else
|
|
|
|
room:setPlayerMark(to, "mouxushengcontrolled", 0)
|
|
|
|
to:control(to)
|
|
|
|
end
|
2023-05-19 23:03:39 +08:00
|
|
|
end
|
2023-06-04 19:39:20 +08:00
|
|
|
--local success, dat = room:askForUseViewAsSkill(from, "test_vs", nil, true)
|
|
|
|
--if success then
|
|
|
|
--local card = Fk.skills["test_vs"]:viewAs(dat.cards)
|
|
|
|
--room:useCard{
|
|
|
|
--from = from.id,
|
|
|
|
--tos = table.map(dat.targets, function(e) return {e} end),
|
|
|
|
--card = card,
|
|
|
|
--}
|
|
|
|
--end
|
2023-04-27 14:15:08 +08:00
|
|
|
-- from:pindian({to})
|
2023-03-01 21:41:16 +08: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 20:17:39 +08:00
|
|
|
-- local cards = room:askForCardsChosen(from, from, 2, 3, "hej", "")
|
|
|
|
-- from:addToPile(self.name, cards)
|
|
|
|
-- from.kingdom = "wei"
|
|
|
|
-- room:broadcastProperty(from, "kingdom")
|
2023-03-05 01:28:59 +08:00
|
|
|
-- p(cards)
|
2023-04-27 14:15:08 +08:00
|
|
|
-- room:useVirtualCard("slash", nil, from, room:getOtherPlayers(from), self.name, true)
|
2023-02-21 13:44:24 +08:00
|
|
|
end,
|
|
|
|
}
|
2023-04-08 20:45:55 +08:00
|
|
|
local test_vs = fk.CreateViewAsSkill{
|
|
|
|
name = "test_vs",
|
2023-04-30 18:51:05 +08:00
|
|
|
pattern = "nullification",
|
2023-04-08 20:45:55 +08:00
|
|
|
card_filter = function(self, to_select, selected)
|
|
|
|
return #selected == 0
|
|
|
|
end,
|
2023-04-13 20:17:39 +08:00
|
|
|
interaction = function(self)
|
|
|
|
return UI.ComboBox {
|
|
|
|
choices = {
|
|
|
|
"ex_nihilo",
|
|
|
|
"duel",
|
|
|
|
"snatch",
|
|
|
|
"dismantlement",
|
|
|
|
"savage_assault",
|
|
|
|
"archery_attack",
|
2023-04-30 18:51:05 +08:00
|
|
|
"lightning",
|
|
|
|
"nullification",
|
2023-04-13 20:17:39 +08:00
|
|
|
}
|
2023-04-08 20:45:55 +08:00
|
|
|
}
|
2023-04-13 20:17:39 +08:00
|
|
|
end,
|
2023-04-08 20:45:55 +08: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-04-22 14:10:06 +08:00
|
|
|
local test_trig = fk.CreateTriggerSkill{
|
|
|
|
name = "test_trig",
|
2023-06-04 19:39:20 +08:00
|
|
|
events = {fk.EventPhaseEnd},
|
|
|
|
can_trigger = function(self, event, target, player, data)
|
|
|
|
return target == player and player:hasSkill(self.name) and player.phase == Player.Discard
|
|
|
|
end,
|
|
|
|
on_cost = function(self, event, target, player, data)
|
|
|
|
local cards = player.room:askForDiscard(player, 1, 1, false, self.name, true, nil, "#test_trig-ask", true)
|
|
|
|
if #cards > 0 then
|
|
|
|
self.cost_data = cards
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
2023-04-22 15:52:26 +08:00
|
|
|
on_use = function(self, event, target, player, data)
|
2023-06-04 19:39:20 +08:00
|
|
|
player.room:throwCard(self.cost_data, self.name, player, player)
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
local damage_maker = fk.CreateActiveSkill{
|
|
|
|
name = "damage_maker",
|
|
|
|
can_use = function(self, player)
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
card_filter = function(self, card)
|
|
|
|
return false
|
|
|
|
end,
|
|
|
|
card_num = 0,
|
|
|
|
target_filter = function(self)
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
target_num = 1,
|
|
|
|
interaction = function()return UI.ComboBox {
|
|
|
|
choices = {"normal_damage", "fire_damage", "thunder_damage", "ice_damage", "lose_hp", "heal_hp", "lose_max_hp", "heal_max_hp"}
|
|
|
|
}end,
|
|
|
|
on_use = function(self, room, effect)
|
|
|
|
local from = room:getPlayerById(effect.from)
|
|
|
|
local target = room:getPlayerById(effect.tos[1])
|
|
|
|
local choice = self.interaction.data
|
|
|
|
local choices = {}
|
|
|
|
for i = 1, 99 do
|
|
|
|
table.insert(choices, tostring(i))
|
|
|
|
end
|
|
|
|
local number = tonumber(room:askForChoice(from, choices, self.name, nil))
|
|
|
|
if choice == "heal_hp" then
|
|
|
|
room:recover{
|
|
|
|
who = target,
|
|
|
|
num = number,
|
|
|
|
recoverBy = from,
|
|
|
|
skillName = self.name
|
|
|
|
}
|
|
|
|
elseif choice == "heal_max_hp" then
|
|
|
|
room:changeMaxHp(target, number)
|
|
|
|
elseif choice == "lose_max_hp" then
|
|
|
|
room:changeMaxHp(target, -number)
|
|
|
|
elseif choice == "lose_hp" then
|
|
|
|
room:loseHp(target, number, self.name)
|
|
|
|
else
|
|
|
|
choices = {"normal_damage", "fire_damage", "thunder_damage", "ice_damage"}
|
|
|
|
room:damage({
|
|
|
|
from = from,
|
|
|
|
to = target,
|
|
|
|
damage = number,
|
|
|
|
damageType = table.indexOf(choices, choice),
|
|
|
|
skillName = self.name
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
local change_hero = fk.CreateActiveSkill{
|
|
|
|
name = "change_hero",
|
|
|
|
can_use = function(self, player)
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
card_filter = function(self, card)
|
|
|
|
return false
|
|
|
|
end,
|
|
|
|
card_num = 0,
|
|
|
|
target_filter = function(self, to_select, selected)
|
|
|
|
return #selected < 1
|
|
|
|
end,
|
|
|
|
target_num = 1,
|
|
|
|
on_use = function(self, room, effect)
|
|
|
|
local from = room:getPlayerById(effect.from)
|
|
|
|
local target = room:getPlayerById(effect.tos[1])
|
|
|
|
local generals = table.map(Fk:getGeneralsRandomly(8, Fk:getAllGenerals()), function(p) return p.name end)
|
|
|
|
local general = room:askForGeneral(from, generals, 1)
|
|
|
|
if general == nil then
|
|
|
|
general = table.random(generals)
|
|
|
|
end
|
|
|
|
room:changeHero(target, general, false, false, true)
|
2023-04-22 15:52:26 +08:00
|
|
|
end,
|
2023-04-22 14:10:06 +08:00
|
|
|
}
|
2023-02-21 13:44:24 +08:00
|
|
|
local test2 = General(extension, "mouxusheng", "wu", 4, 4, General.Female)
|
2023-04-13 20:17:39 +08:00
|
|
|
test2.shield = 4
|
2023-02-21 13:44:24 +08:00
|
|
|
test2:addSkill("rende")
|
2023-02-15 21:20:40 +08:00
|
|
|
test2:addSkill(cheat)
|
2023-06-04 19:39:20 +08:00
|
|
|
test2:addSkill(control)
|
2023-04-08 20:45:55 +08:00
|
|
|
test2:addSkill(test_vs)
|
2023-06-04 19:39:20 +08:00
|
|
|
--test2:addSkill(test_trig)
|
|
|
|
test2:addSkill(damage_maker)
|
|
|
|
test2:addSkill(change_hero)
|
2023-02-15 19:54:35 +08:00
|
|
|
|
|
|
|
Fk:loadTranslationTable{
|
2023-05-19 07:45:08 +08:00
|
|
|
["test_p_0"] = "测试包",
|
2023-02-15 19:54:35 +08:00
|
|
|
["test"] = "测试",
|
|
|
|
["test_filter"] = "破军",
|
2023-02-15 21:20:40 +08:00
|
|
|
[":test_filter"] = "你的点数大于11的牌视为无中生有。",
|
2023-02-15 19:54:35 +08:00
|
|
|
["mouxusheng"] = "谋徐盛",
|
2023-02-15 21:20:40 +08:00
|
|
|
--["cheat"] = "开挂",
|
|
|
|
[":cheat"] = "出牌阶段,你可以获得一张想要的牌。",
|
2023-06-04 19:39:20 +08:00
|
|
|
--["#test_trig-ask"] = "你可弃置一张手牌",
|
|
|
|
["control"] = "控制",
|
|
|
|
["damage_maker"] = "制伤器",
|
|
|
|
["change_hero"] = "变更",
|
2023-02-15 19:54:35 +08:00
|
|
|
}
|
|
|
|
|
2023-05-19 07:45:08 +08:00
|
|
|
return { extension }
|