Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
name: Run Tests

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm install

- name: Run Jest Tests
run: npm run test:jest
67 changes: 26 additions & 41 deletions app/gilded-rose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export class Item {
sellIn: number;
quality: number;

constructor(name, sellIn, quality) {
constructor(name: string, sellIn: number, quality: number) {
this.name = name;
this.sellIn = sellIn;
this.quality = quality;
Expand All @@ -19,51 +19,36 @@ export class GildedRose {

updateQuality() {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
if (this.items[i].quality > 0) {
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].quality = this.items[i].quality - 1
}
}
} else {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
if (this.items[i].sellIn < 11) {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
}
}
if (this.items[i].sellIn < 6) {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
}
}
}
}
}
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].sellIn = this.items[i].sellIn - 1;
this.items[i].sellIn -= 1;
}
if (this.items[i].sellIn < 0) {
if (this.items[i].name != 'Aged Brie') {
if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
if (this.items[i].quality > 0) {
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].quality = this.items[i].quality - 1
}
}
} else {
this.items[i].quality = this.items[i].quality - this.items[i].quality
}
} else {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
}
if (this.items[i].name == 'Aged Brie') {
this.items[i].quality += 1
if (this.items[i].sellIn < 0) {
this.items[i].quality += 1
}
} else if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
this.items[i].quality += 1
if (this.items[i].sellIn < 0) {
this.items[i].quality = 0
} else if (this.items[i].sellIn < 6) {
this.items[i].quality += 2
} else if (this.items[i].sellIn < 11) {
this.items[i].quality += 1
}
} else if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].quality = this.items[i].quality - 1
if (this.items[i].sellIn < 0) {
this.items[i].quality -= 1
}
}
if (this.items[i].quality < 0) {
this.items[i].quality = 0
} else if (this.items[i].quality > 50 && this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].quality = 50
}
}

return this.items;
}
}
}
Loading