From 54188dbcaa375145ded5d00c3c22c541181fe2a7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Aug 2024 20:20:09 +0200 Subject: [PATCH 1/3] implement card attributes generator to collection view --- src/commands/collection.ts | 5 ++++- src/entities/card.ts | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/commands/collection.ts b/src/commands/collection.ts index 982c4ad..33ef611 100644 --- a/src/commands/collection.ts +++ b/src/commands/collection.ts @@ -81,7 +81,10 @@ export class CollectionCommand extends Command { wishlist = ` · ◆${card.mapper.wishlistEntries.length} `; } - return `\`${card.id}\` · ${conditionEmoji} ${wishlist}· ${card.mapper.username} (${card.burnValue} gold)`; + let attributes = [...card.getAttributes()].map(it => `\`${it}\``).join(' · ') + attributes = attributes ? ' · ' + attributes : '' + + return `\`${card.id}\` · ${conditionEmoji} ${wishlist}· ${card.mapper.username} (${card.burnValue} gold) ${attributes}`; }) .join('\n') + `\n\nSorting by: \`${orderByReadable}\`` ); diff --git a/src/entities/card.ts b/src/entities/card.ts index 9c4f34f..9f1d41a 100644 --- a/src/entities/card.ts +++ b/src/entities/card.ts @@ -94,6 +94,13 @@ export class Card { return attributes; } + * getAttributes(): Generator { + if (this.foil) + yield 'foil' + if (this.jobMindblocked) + yield 'mindblocked' + } + get jobEffort() { return Math.round( this.jobBaseEffort * this.jobMotivation * 0.1 * (this.jobMindblocked ? 0.5 : 1) From 98106bf05ec1a139194b107b8dd2feb8559262c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Aug 2024 20:21:10 +0200 Subject: [PATCH 2/3] remove old attribute generator and update references --- src/commands/drop.ts | 2 +- src/commands/use.ts | 2 +- src/entities/card.ts | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/commands/drop.ts b/src/commands/drop.ts index eb8dd02..ed6a6b7 100644 --- a/src/commands/drop.ts +++ b/src/commands/drop.ts @@ -115,7 +115,7 @@ export class DropCommand extends Command { const buttons = cards.map((card) => { let name = card.mapper.username; - if (card.attributes.length > 0) { + if (card.foil) { name += ' (Foil)'; } diff --git a/src/commands/use.ts b/src/commands/use.ts index b288e00..5ba53e2 100644 --- a/src/commands/use.ts +++ b/src/commands/use.ts @@ -161,7 +161,7 @@ export class UseCommand extends Command { const buttons = cards.map((card) => { let name = card.mapper.username; - if (card.attributes.length > 0) { + if (card.foil) { name += ' (Foil)'; } diff --git a/src/entities/card.ts b/src/entities/card.ts index 9f1d41a..3914c15 100644 --- a/src/entities/card.ts +++ b/src/entities/card.ts @@ -86,14 +86,6 @@ export class Card { }[this.condition.id]!; } - get attributes() { - const attributes: string[] = []; - - if (this.foil) attributes.push('Foil'); - - return attributes; - } - * getAttributes(): Generator { if (this.foil) yield 'foil' From 98009dda2199328bb120354073db572a65a38ef3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Aug 2024 21:26:18 +0200 Subject: [PATCH 3/3] remove trailing whitespace --- src/commands/collection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/collection.ts b/src/commands/collection.ts index 33ef611..dac6423 100644 --- a/src/commands/collection.ts +++ b/src/commands/collection.ts @@ -84,7 +84,7 @@ export class CollectionCommand extends Command { let attributes = [...card.getAttributes()].map(it => `\`${it}\``).join(' · ') attributes = attributes ? ' · ' + attributes : '' - return `\`${card.id}\` · ${conditionEmoji} ${wishlist}· ${card.mapper.username} (${card.burnValue} gold) ${attributes}`; + return `\`${card.id}\` · ${conditionEmoji} ${wishlist}· ${card.mapper.username} (${card.burnValue} gold)${attributes}`; }) .join('\n') + `\n\nSorting by: \`${orderByReadable}\`` );