小功能 (#211)

- 注释和各种i18n
- player的canUse,杜绝data.card.skill.canuse(Self)
- Card也可以getNumberStr了
- 转换技状态查询可以返回文字(阳/阴)
This commit is contained in:
YoumuKon 2023-06-30 00:48:37 +08:00 committed by GitHub
parent fde7d41e19
commit c7e0b2fdf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 8 deletions

View File

@ -255,8 +255,14 @@ Fk:loadTranslationTable{
["phase_finish"] = "结束阶段",
["chained"] = "横置",
["un-chained"] = "竖置",
["not-chained"] = "重置",
["yang"] = "",
["yin"] = "",
["quest_succeed"] = "成功",
["quest_failed"] = "失败",
["pile_draw"] = "牌堆",
["pile_discard"] = "弃牌堆",
["processing_area"] = "处理区",

View File

@ -303,7 +303,7 @@ function Card:getSubtypeString()
end
end
--- 获取卡牌点数并返回点数文字描述仅限A/J/Q/K)。
--- 获取卡牌点数并返回点数文字描述仅限A/J/Q/K/X)。
local function getNumberStr(num)
if num == 1 then
return "A"
@ -313,10 +313,35 @@ local function getNumberStr(num)
return "Q"
elseif num == 13 then
return "K"
elseif num == 0 then
return "X"
end
return tostring(num)
end
--- 获取卡牌点数并返回点数文字描述仅限A/J/Q/K/X
---@param num integer @ 当你只想翻译点数为文字时(优先检查,请注意)
function Card:getNumberStr(num)
return tostring(getNumberStr(num and num or self.number))
end
--- 根据点数文字描述返回数字。
---@param str integer @ 只能翻译文字为点数
function Card:strToNumber(str)
if str == "A" then
return 1
elseif str == "J" then
return 11
elseif str == "Q" then
return 12
elseif str == "K" then
return 13
elseif str == "X" then
return 0
end
return tonumber(str)
end
--- 获取卡牌的完整点数(花色+点数)黑桃A/♠A
---@param symbol boolean @ 是否以符号形式显示花色
---@return string @ 完整点数(字符串)

View File

@ -725,7 +725,14 @@ function Player:getAllSkills()
return ret
end
--- 确认玩家是否可以对特定玩家使用特定牌。
--- 确认玩家是否可以使用特定牌。
---@param card Card @ 特定牌
function Player:canUse(card)
assert(card, "Error: No Card")
return card.skill.canUse(self, card)
end
--- 确认玩家是否被禁止对特定玩家使用特定牌。
---@param to Player @ 特定玩家
---@param card Card @ 特定牌
function Player:isProhibited(to, card)
@ -739,7 +746,7 @@ function Player:isProhibited(to, card)
return false
end
--- 确认玩家是否可以使用特定牌。
--- 确认玩家是否被禁止使用特定牌。
---@param card Card @ 特定的牌
function Player:prohibitUse(card)
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
@ -751,7 +758,7 @@ function Player:prohibitUse(card)
return false
end
--- 确认玩家是否可以打出特定牌。
--- 确认玩家是否被禁止打出特定牌。
---@param card Card @ 特定的牌
function Player:prohibitResponse(card)
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
@ -763,7 +770,7 @@ function Player:prohibitResponse(card)
return false
end
--- 确认玩家是否可以弃置特定牌。
--- 确认玩家是否被禁止弃置特定牌。
---@param card Card @ 特定的牌
function Player:prohibitDiscard(card)
local status_skills = Fk:currentRoom().status_skills[ProhibitSkill] or Util.DummyTable
@ -782,12 +789,14 @@ fk.SwitchYin = 1
--- 获取转换技状态
---@param skillName string @ 技能名
---@param afterUse boolean @ 是否提前计算转换后状态
---@param inWord boolean @ 是否返回文字
---@return number @ 转换技状态
function Player:getSwitchSkillState(skillName, afterUse)
function Player:getSwitchSkillState(skillName, afterUse, inWord)
if afterUse then
return self:getMark(MarkEnum.SwithSkillPreName .. skillName) < 1 and fk.SwitchYin 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 fk.SwitchYang 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