mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
inline method
This commit is contained in:
parent
2fd34247dd
commit
b0c4797e66
@ -20,7 +20,15 @@ export class GildedRose {
|
||||
updateQuality() {
|
||||
this.items.forEach((item, i) => {
|
||||
if (item.name == 'Aged Brie' || item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
brieOrBackstageQuality(item);
|
||||
if (item.name == 'Aged Brie') {
|
||||
this.incrementQuality(item);
|
||||
}
|
||||
|
||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
this.incrementQuality(item);
|
||||
if (item.sellIn < 11) this.incrementQuality(item)
|
||||
if (item.sellIn < 6) this.incrementQuality(item)
|
||||
}
|
||||
} else {
|
||||
if (item.quality > 0) {
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
@ -36,22 +44,11 @@ export class GildedRose {
|
||||
|
||||
return this.items;
|
||||
|
||||
function brieOrBackstageQuality(item: Item) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (item.sellIn < 11) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
if (item.sellIn < 6) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private incrementQuality(item: Item) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user