mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-04 17:21:38 +00:00
Moved aged-brie-behavior to its own folder, use config.maxQuality
This commit is contained in:
parent
ef9c478e7c
commit
6c4e56174c
@ -1,23 +1,22 @@
|
||||
import { config } from "@app/config";
|
||||
import { Item } from "@app/item";
|
||||
import { IUpdateBehavior } from "../update-behavior.interface";
|
||||
import { IUpdateBehavior } from "@app/update-behaviors";
|
||||
|
||||
export class AgedBrieBehavior implements IUpdateBehavior {
|
||||
readonly #MAX_AMOUNT = 50;
|
||||
|
||||
constructor(private item: Item) {}
|
||||
|
||||
update(): Item {
|
||||
this.item.sellIn -= 1;
|
||||
|
||||
const isPastSellInDay = this.item.sellIn < 0;
|
||||
const isPastSellInDay = this.item.sellIn <= 0;
|
||||
|
||||
const amountToAdd = isPastSellInDay ? 2 : 1;
|
||||
|
||||
this.item.quality = Math.min(
|
||||
this.#MAX_AMOUNT,
|
||||
config.maxQuality,
|
||||
this.item.quality + amountToAdd
|
||||
);
|
||||
|
||||
this.item.sellIn -= 1;
|
||||
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user