Create module for back stage passes

This commit is contained in:
Dan Holmes 2020-12-03 16:22:55 +00:00
parent a3f6b9a668
commit 14dda486bf
2 changed files with 8 additions and 5 deletions

View File

@ -0,0 +1,5 @@
function isBackstagePass(item) {
return item.name.toLowerCase().match(/backstage pass/);
};
module.exports = { isBackstagePass }

View File

@ -1,3 +1,5 @@
var bsp = require('./backstage_pass_update.js')
class Shop {
constructor(items = []) {
this.items = items;
@ -23,7 +25,7 @@ class Shop {
}
_getQualityChange(item) {
if (this._isBackstagePass(item)) {
if (bsp.isBackstagePass(item)) {
return this._getQualityChangeBackstagePass(item);
} else if (this._isAgedBrie(item)) {
return this._getQualityChangeAgedBrie(item);
@ -34,10 +36,6 @@ class Shop {
}
}
_isBackstagePass(item) {
return item.name.toLowerCase().match(/backstage pass/);
}
_isAgedBrie(item) {
return item.name.toLowerCase().match(/aged brie/);
}