mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-16 19:05:05 +00:00
added js version of Gilded Rose from git@github.com:guyroyse/gilded-rose-javascript.git
This commit is contained in:
1 parent
2e7e36eda1
commit
4bb9659190
13 files changed
+12802
No files matched your search
@@ -0,0 +1,62 @@
|
||||
function Item(name, sell_in, quality) {
|
||||
this.name = name;
|
||||
this.sell_in = sell_in;
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
var items = []
|
||||
|
||||
items.push(new Item('+5 Dexterity Vest', 10, 20));
|
||||
items.push(new Item('Aged Brie', 2, 0));
|
||||
items.push(new Item('Elixir of the Mongoose', 5, 7));
|
||||
items.push(new Item('Sulfuras, Hand of Ragnaros', 0, 80));
|
||||
items.push(new Item('Backstage passes to a TAFKAL80ETC concert', 15, 20));
|
||||
items.push(new Item('Conjured Mana Cake', 3, 6));
|
||||
|
||||
function update_quality() {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].name != 'Aged Brie' && items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (items[i].quality > 0) {
|
||||
if (items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||
items[i].quality = items[i].quality - 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1
|
||||
if (items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (items[i].sell_in < 11) {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1
|
||||
}
|
||||
}
|
||||
if (items[i].sell_in < 6) {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||
items[i].sell_in = items[i].sell_in - 1;
|
||||
}
|
||||
if (items[i].sell_in < 0) {
|
||||
if (items[i].name != 'Aged Brie') {
|
||||
if (items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (items[i].quality > 0) {
|
||||
if (items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||
items[i].quality = items[i].quality - 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
items[i].quality = items[i].quality - items[i].quality
|
||||
}
|
||||
} else {
|
||||
if (items[i].quality < 50) {
|
||||
items[i].quality = items[i].quality + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user