mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Update gilded_rose.py
This commit is contained in:
parent
5a4e92199b
commit
97e238cd55
@ -1,39 +1,55 @@
|
|||||||
# -*- coding: utf-8 -*-
|
name_Ragnaros = "Sulfuras, Hand of Ragnaros"
|
||||||
|
name_Backstage = "Backstage passes to a TAFKAL80ETC concert"
|
||||||
|
name_Brie = "Aged Brie"
|
||||||
|
|
||||||
|
|
||||||
class GildedRose(object):
|
class GildedRose(object):
|
||||||
|
|
||||||
def __init__(self, items):
|
def __init__(self, items):
|
||||||
self.items = items
|
self.items = items
|
||||||
|
|
||||||
def update_quality(self):
|
@staticmethod
|
||||||
for item in self.items:
|
def check_quality(item, step):
|
||||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
|
if 0 >= item.quality + step >= 50:
|
||||||
if item.quality > 0:
|
item.quality = item.quality + step
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
|
||||||
item.quality = item.quality - 1
|
def backstage_case(self, item):
|
||||||
else:
|
counter = 1
|
||||||
if item.quality < 50:
|
|
||||||
item.quality = item.quality + 1
|
|
||||||
if item.name == "Backstage passes to a TAFKAL80ETC concert":
|
|
||||||
if item.sell_in < 11:
|
if item.sell_in < 11:
|
||||||
if item.quality < 50:
|
counter = 2
|
||||||
item.quality = item.quality + 1
|
|
||||||
if item.sell_in < 6:
|
if item.sell_in < 6:
|
||||||
if item.quality < 50:
|
counter = 3
|
||||||
item.quality = item.quality + 1
|
for i in range(counter):
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
self.check_quality(item, 1)
|
||||||
item.sell_in = item.sell_in - 1
|
item.sell_in = item.sell_in - 1
|
||||||
if item.sell_in < 0:
|
if item.sell_in < 0:
|
||||||
if item.name != "Aged Brie":
|
|
||||||
if item.name != "Backstage passes to a TAFKAL80ETC concert":
|
|
||||||
if item.quality > 0:
|
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
|
||||||
item.quality = item.quality - 1
|
|
||||||
else:
|
|
||||||
item.quality = item.quality - item.quality
|
item.quality = item.quality - item.quality
|
||||||
|
|
||||||
|
def bree_case(self, item):
|
||||||
|
item.sell_in = item.sell_in - 1
|
||||||
|
self.check_quality(item, 1)
|
||||||
|
if item.sell_in < 0:
|
||||||
|
self.check_quality(item, 1)
|
||||||
|
|
||||||
|
def ragnaros_case(self, item):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def default_case(self, item):
|
||||||
|
self.check_quality(item, -1)
|
||||||
|
item.sell_in = item.sell_in + 1
|
||||||
|
if item.sell_in < 0:
|
||||||
|
self.check_quality(item, 1)
|
||||||
|
|
||||||
|
def update_quality(self):
|
||||||
|
for item in self.items:
|
||||||
|
if item.name == name_Brie:
|
||||||
|
self.bree_case(item)
|
||||||
|
elif item.name == name_Backstage:
|
||||||
|
self.backstage_case(item)
|
||||||
|
elif item.name == name_Ragnaros:
|
||||||
|
self.ragnaros_case(item)
|
||||||
else:
|
else:
|
||||||
if item.quality < 50:
|
self.default_case(item)
|
||||||
item.quality = item.quality + 1
|
|
||||||
|
|
||||||
|
|
||||||
class Item:
|
class Item:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user