Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

richistron/gilded_rose_angular1

Repository files navigation

Gilded Rose Kata Angular 1

This is a very well known kata, and seeing this issue in a modern app might lead to do some refactor because you will see with more clarity what is the problem behind this kata. Seat back, relax and enjoy ;)

Gilded Rose kata by Sandy Metz (OOP)

Gilded Rose kata

https://youtu.be/8bZh5LMaSmE

The algorithm

function updateQuality() {
  const items = _items;
  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
        }
      }
    }
  }
}

Dependencies

- node v9.11.*
- ruby 2.*

Installation

git clone git@github.com:richistron/gilded_rose_angular1.git

cd gilded_rose_angular1

npm install;

Package.json

npm test 
npm webpack # compile production
npm dist:server # dist server 3000
npm dev:server # dev server 3000

Docker

docker pull richistron/gilded_rose_angular1
docker run  -p 3000:3000 -it richistron/gilded_rose_angular1

About

Gilded Rose Kata in a angular 1 application

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published