Skip to content

Commit

Permalink
fix: prism card code with test [upload]
Browse files Browse the repository at this point in the history
  • Loading branch information
MPThLee committed Nov 19, 2023
1 parent 4a16bbc commit cfc9e57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions spec/PrismCardCode_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ describe("PrismCardCode", function()
describe("Produce", function()
local code = c("1328001")

it("Type check", function()
assert.is_equal(PrismCardCode.getTypeFromCode(code), "Produce")
end)

it("Rarity check", function()
assert.is_equal(PrismCardCode.getRarityFromCode(code), "3*")
end)
Expand All @@ -29,6 +33,10 @@ describe("PrismCardCode", function()
describe("Support", function()
local code = c("2390001")

it("Type check", function()
assert.is_equal(PrismCardCode.getTypeFromCode(code), "Support")
end)

it("Rarity check", function()
assert.is_equal(PrismCardCode.getRarityFromCode(code), "SSR")
end)
Expand Down
10 changes: 7 additions & 3 deletions src/PrismCardCode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,20 @@ function p.getInfoFromCode(code)
return p.getSupportInfo(raw_data)
end

function p.getRarityFromCode(code)
function p.getTypeFromCode(code)
return p.getInfoFromCode(code)[1]
end

function p.getCharacterFromCode(code)
function p.getRarityFromCode(code)
return p.getInfoFromCode(code)[2]
end

function p.getCardNumberFromCode(code)
function p.getCharacterFromCode(code)
return p.getInfoFromCode(code)[3]
end

function p.getCardNumberFromCode(code)
return p.getInfoFromCode(code)[4]
end

return p

0 comments on commit cfc9e57

Please sign in to comment.