mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
[重構] 判斷若為 Sulfuras 則不作為跳至下一輪迴圈,簡化相關判定
This commit is contained in:
parent
bfb20fbad4
commit
a95501bfb0
@ -20,6 +20,8 @@ class Shop {
|
||||
|
||||
updateQuality() {
|
||||
for (let i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].name === "Sulfuras, Hand of Ragnaros") continue;
|
||||
|
||||
if (
|
||||
this.items[i].name === "Aged Brie" ||
|
||||
this.items[i].name === "Backstage passes to a TAFKAL80ETC concert"
|
||||
@ -37,26 +39,18 @@ class Shop {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
this.items[i].quality > 0 &&
|
||||
this.items[i].name != "Sulfuras, Hand of Ragnaros"
|
||||
) {
|
||||
} else if (this.items[i].quality > 0) {
|
||||
this.items[i].quality = this.items[i].quality - 1;
|
||||
}
|
||||
|
||||
if (this.items[i].name != "Sulfuras, Hand of Ragnaros") {
|
||||
this.items[i].sellIn = this.items[i].sellIn - 1;
|
||||
}
|
||||
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 &&
|
||||
this.items[i].name != "Sulfuras, Hand of Ragnaros"
|
||||
) {
|
||||
if (this.items[i].quality > 0) {
|
||||
this.items[i].quality = this.items[i].quality - 1;
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user