mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
fix: fix the negative number logic
This commit is contained in:
parent
58f35a4fd5
commit
6818eda220
@ -28,14 +28,10 @@ function calculateQuality(state: TItem): number {
|
||||
}
|
||||
}
|
||||
|
||||
if(state.isConjured) {
|
||||
if(state.isConjured || state.sellIn < 0) {
|
||||
degradeRate = 2;
|
||||
}
|
||||
|
||||
if(state.sellIn <= 0) {
|
||||
return calculatedQuality;
|
||||
}
|
||||
|
||||
calculatedQuality = calculatedQuality - (qualityIdentifier * degradeRate);
|
||||
|
||||
if(calculatedQuality > 50) {
|
||||
|
||||
@ -5,13 +5,7 @@ function updateSellIn (state: any): number {
|
||||
return calculatedSellIn;
|
||||
}
|
||||
|
||||
calculatedSellIn = calculatedSellIn - 1;
|
||||
|
||||
if(calculatedSellIn < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return calculatedSellIn;
|
||||
return calculatedSellIn - 1;
|
||||
}
|
||||
|
||||
export default updateSellIn;
|
||||
Loading…
Reference in New Issue
Block a user