mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
cleaned up updateAgedBrieItem method
assert AGED_BREE key
This commit is contained in:
parent
5c9f3822a2
commit
98b400604e
@ -1,3 +1,4 @@
|
|||||||
|
import { assert } from "console";
|
||||||
import { ItemNames, MAX_ITEM_QUALITY } from "./constants";
|
import { ItemNames, MAX_ITEM_QUALITY } from "./constants";
|
||||||
|
|
||||||
export class Item {
|
export class Item {
|
||||||
@ -20,49 +21,17 @@ export class GildedRose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateAgedBrieItem(item: Item) {
|
private updateAgedBrieItem(item: Item) {
|
||||||
if (
|
assert(item.name == ItemNames.AGED_BRIE);
|
||||||
item.name != ItemNames.AGED_BRIE &&
|
|
||||||
item.name != ItemNames.BACKSTAGE_PASSES
|
|
||||||
) {
|
|
||||||
if (item.quality > 0) {
|
|
||||||
if (item.name != ItemNames.SULFURAS) {
|
|
||||||
item.quality = item.quality - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (item.quality < MAX_ITEM_QUALITY) {
|
|
||||||
item.quality = item.quality + 1;
|
|
||||||
if (item.name == ItemNames.BACKSTAGE_PASSES) {
|
|
||||||
if (item.sellIn < 11) {
|
|
||||||
if (item.quality < MAX_ITEM_QUALITY) {
|
if (item.quality < MAX_ITEM_QUALITY) {
|
||||||
item.quality = item.quality + 1;
|
item.quality = item.quality + 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (item.sellIn < 6) {
|
|
||||||
if (item.quality < MAX_ITEM_QUALITY) {
|
|
||||||
item.quality = item.quality + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.name != ItemNames.SULFURAS) {
|
if (item.name != ItemNames.SULFURAS) {
|
||||||
item.sellIn = item.sellIn - 1;
|
item.sellIn = item.sellIn - 1;
|
||||||
}
|
}
|
||||||
if (item.sellIn < 0) {
|
if (item.sellIn < 0 && item.quality < MAX_ITEM_QUALITY) {
|
||||||
if (item.name != ItemNames.AGED_BRIE) {
|
|
||||||
if (item.name != ItemNames.BACKSTAGE_PASSES) {
|
|
||||||
if (item.quality > 0) {
|
|
||||||
if (item.name != ItemNames.SULFURAS) {
|
|
||||||
item.quality = item.quality - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
item.quality = 0;
|
|
||||||
}
|
|
||||||
} else if (item.quality < MAX_ITEM_QUALITY) {
|
|
||||||
item.quality = item.quality + 1;
|
item.quality = item.quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private updateBackstagePassesItem(item: Item) {
|
private updateBackstagePassesItem(item: Item) {
|
||||||
if (
|
if (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user