mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +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 {
|
export class Item {
|
||||||
name: string;
|
name: string;
|
||||||
sellIn: number;
|
sellIn: number;
|
||||||
@ -19,46 +22,49 @@ export class GildedRose {
|
|||||||
|
|
||||||
updateQuality() {
|
updateQuality() {
|
||||||
for (const item of this.items) {
|
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.quality > 0) {
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != ItemNames.SULFURAS) {
|
||||||
item.quality = item.quality - 1
|
item.quality = item.quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item.quality < 50) {
|
if (item.quality < 50) {
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1;
|
||||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if (item.name == ItemNames.BACKSTAGE_PASSES) {
|
||||||
if (item.sellIn < 11) {
|
if (item.sellIn < 11) {
|
||||||
if (item.quality < 50) {
|
if (item.quality < 50) {
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item.sellIn < 6) {
|
if (item.sellIn < 6) {
|
||||||
if (item.quality < 50) {
|
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;
|
item.sellIn = item.sellIn - 1;
|
||||||
}
|
}
|
||||||
if (item.sellIn < 0) {
|
if (item.sellIn < 0) {
|
||||||
if (item.name != 'Aged Brie') {
|
if (item.name != ItemNames.AGED_BRIE) {
|
||||||
if (item.name != 'Backstage passes to a TAFKAL80ETC concert') {
|
if (item.name != ItemNames.BACKSTAGE_PASSES) {
|
||||||
if (item.quality > 0) {
|
if (item.quality > 0) {
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != ItemNames.SULFURAS) {
|
||||||
item.quality = item.quality - 1
|
item.quality = item.quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
item.quality = item.quality - item.quality
|
item.quality = item.quality - item.quality;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item.quality < 50) {
|
if (item.quality < 50) {
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user