mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
created const file and added ItemNames constant obj to maintain a key against each item name
This commit is contained in:
parent
aeae3bbdc3
commit
e44c0a1d18
11
TypeScript/app/constants.ts
Normal file
11
TypeScript/app/constants.ts
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
/*
|
||||
A const to hold the names of the items
|
||||
*/
|
||||
const ItemNames = {
|
||||
AGED_BRIE: "Aged Brie",
|
||||
BACKSTAGE_PASSES: "Backstage passes to a TAFKAL80ETC concert",
|
||||
SULFURAS: "Sulfuras, Hand of Ragnaros",
|
||||
};
|
||||
|
||||
export { ItemNames };
|
||||
@ -1,3 +1,6 @@
|
||||
import { ItemNames } from "./constants";
|
||||
|
||||
|
||||
export class Item {
|
||||
name: string;
|
||||
sellIn: number;
|
||||
@ -19,46 +22,49 @@ export class GildedRose {
|
||||
|
||||
updateQuality() {
|
||||
for (const item of this.items) {
|
||||
if (item.name != 'Aged Brie' && item.name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (
|
||||
item.name != ItemNames.AGED_BRIE &&
|
||||
item.name != ItemNames.BACKSTAGE_PASSES
|
||||
) {
|
||||
if (item.quality > 0) {
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
item.quality = item.quality - 1
|
||||
if (item.name != ItemNames.SULFURAS) {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1
|
||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
item.quality = item.quality + 1;
|
||||
if (item.name == ItemNames.BACKSTAGE_PASSES) {
|
||||
if (item.sellIn < 11) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
if (item.sellIn < 6) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
if (item.name != ItemNames.SULFURAS) {
|
||||
item.sellIn = item.sellIn - 1;
|
||||
}
|
||||
if (item.sellIn < 0) {
|
||||
if (item.name != 'Aged Brie') {
|
||||
if (item.name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (item.name != ItemNames.AGED_BRIE) {
|
||||
if (item.name != ItemNames.BACKSTAGE_PASSES) {
|
||||
if (item.quality > 0) {
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
item.quality = item.quality - 1
|
||||
if (item.name != ItemNames.SULFURAS) {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.quality = item.quality - item.quality
|
||||
item.quality = item.quality - item.quality;
|
||||
}
|
||||
} else {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user