mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
feat(name): added constant names
This commit is contained in:
parent
e0d2e5c555
commit
6468212b02
3
.prettierrc
Normal file
3
.prettierrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"singleQuote": true
|
||||
}
|
||||
@ -10,6 +10,18 @@ export class Item {
|
||||
}
|
||||
}
|
||||
|
||||
enum ItemType {
|
||||
AgedBrie = 'Aged Brie',
|
||||
BackstagePasses = 'Backstage passes to a TAFKAL80ETC concert',
|
||||
Sulfuras = 'Sulfuras, Hand of Ragnaros',
|
||||
}
|
||||
|
||||
const TEN_DAYS_FOR_THE_CONCERT = 11;
|
||||
const FIVE_DAYS_FOR_THE_CONCERT = 6;
|
||||
const ZERO_DAYS_FOR_SALE = 0;
|
||||
const MAX_QUALITY = 50;
|
||||
const MIN_QUALITY = 0;
|
||||
|
||||
export class GildedRose {
|
||||
items: Array<Item>;
|
||||
|
||||
@ -19,46 +31,52 @@ 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
|
||||
if (
|
||||
this.items[i].name != ItemType.AgedBrie &&
|
||||
this.items[i].name != ItemType.BackstagePasses
|
||||
) {
|
||||
if (this.items[i].quality > MIN_QUALITY) {
|
||||
if (this.items[i].name != ItemType.Sulfuras) {
|
||||
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].quality < MAX_QUALITY) {
|
||||
this.items[i].quality = this.items[i].quality + 1;
|
||||
if (this.items[i].name == ItemType.BackstagePasses) {
|
||||
if (this.items[i].sellIn < TEN_DAYS_FOR_THE_CONCERT) {
|
||||
if (this.items[i].quality < MAX_QUALITY) {
|
||||
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].sellIn < FIVE_DAYS_FOR_THE_CONCERT) {
|
||||
if (this.items[i].quality < MAX_QUALITY) {
|
||||
this.items[i].quality = this.items[i].quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||
|
||||
if (this.items[i].name != ItemType.Sulfuras) {
|
||||
this.items[i].sellIn = 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
|
||||
|
||||
if (this.items[i].sellIn < ZERO_DAYS_FOR_SALE) {
|
||||
if (this.items[i].name != ItemType.AgedBrie) {
|
||||
if (this.items[i].name != ItemType.BackstagePasses) {
|
||||
if (this.items[i].quality > MIN_QUALITY) {
|
||||
if (this.items[i].name != ItemType.Sulfuras) {
|
||||
this.items[i].quality = 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 - this.items[i].quality;
|
||||
}
|
||||
} else {
|
||||
if (this.items[i].quality < 50) {
|
||||
this.items[i].quality = this.items[i].quality + 1
|
||||
if (this.items[i].quality < MAX_QUALITY) {
|
||||
this.items[i].quality = this.items[i].quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user