Skip to content

Commit

Permalink
Fix alt art/anime version distinction
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaKretin committed Dec 12, 2018
1 parent 4375e98 commit c855c44
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
11 changes: 9 additions & 2 deletions dist/class/Card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions lib/class/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@ export class Card {

get aliasIDs(): Promise<number[]> {
return new Promise(async (resolve, reject) => {
const list = await cards.getRawCardList();
if (this.data.alias > 0) {
const alCard = list[this.data.alias];
if (alCard.data.ot !== this.data.ot) {
resolve([this.id]);
}
}
const baseCode = this.data.alias > 0 ? this.data.alias : this.id;
const baseCard = list[baseCode];
const ids = [baseCode];
const list = await cards.getRawCardList();
for (const id in list) {
if (list.hasOwnProperty(id)) {
const card = list[id];
if (card && card.data.alias === baseCode) {
if (card && card.data.alias === baseCode && card.data.ot === baseCard.data.ot) {
ids.push(parseInt(id, 10));
}
}
Expand Down
16 changes: 15 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,25 @@ describe("Testing alias check with name", function() {
});
describe("Testing alias check with alt art's code", function() {
it("Should be [7852509, 7852510]", async function() {
const card = await index.getCard(7852510, "en");
const card = await index.getCard(7852510);
const codes = await card.aliasIDs;
expect(codes).to.deep.equal([7852509, 7852510]);
});
});
describe("Testing alias check to exclude anime version", function() {
it("Should not include 513000134", async function() {
const card = await index.getCard(10000010);
const codes = await card.aliasIDs;
expect(codes).to.not.include(513000134);
});
});
describe("Testing alias check from anime version", function() {
it("Should be [513000134]", async function() {
const card = await index.getCard(513000134);
const codes = await card.aliasIDs;
expect(codes).to.deep.equal([513000134]);
});
});
describe("Testing image link", function() {
it("Should be a string", async function() {
const card = await index.getCard(7852510, "en");
Expand Down

0 comments on commit c855c44

Please sign in to comment.