mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
basic refactoring done, added min and max variables, changed addition and subtraction of quality;
This commit is contained in:
parent
35db991828
commit
ba05d9fb40
@ -20,27 +20,26 @@ export class GildedRose {
|
||||
|
||||
// Method for updating item quality
|
||||
updateQuality() {
|
||||
var maxQuality = 50;
|
||||
var minQuality = 0;
|
||||
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
|
||||
}
|
||||
}
|
||||
if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert'
|
||||
&& this.items[i].name != 'Sulfuras, Hand of Ragnaros' && this.items[i].quality >minQuality) {
|
||||
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].quality < maxQuality) {
|
||||
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].sellIn <= 10) {
|
||||
// quality goes up by 2 when days are 10 or less
|
||||
if (this.items[i].quality < 50) {
|
||||
this.items[i].quality = this.items[i].quality + 1
|
||||
if (this.items[i].quality < maxQuality) {
|
||||
this.items[i].quality += 1;
|
||||
}
|
||||
}
|
||||
// quality goes up by 3 when days are 5 of less
|
||||
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].sellIn <= 5) {
|
||||
if (this.items[i].quality < maxQuality) {
|
||||
this.items[i].quality += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,26 +47,26 @@ export class GildedRose {
|
||||
}
|
||||
// checking for legendary to subtract sell by date
|
||||
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].quality > minQuality) {
|
||||
// move this if above line 57 if
|
||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||
this.items[i].quality = this.items[i].quality - 1
|
||||
this.items[i].quality -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
this.items[i].quality = this.items[i].quality - this.items[i].quality
|
||||
this.items[i].quality -= this.items[i].quality;
|
||||
}
|
||||
// aged brie increases in quality here
|
||||
} else {
|
||||
if (this.items[i].quality < 50) {
|
||||
this.items[i].quality = this.items[i].quality + 1
|
||||
if (this.items[i].quality < maxQuality) {
|
||||
this.items[i].quality += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user