mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
readability
This commit is contained in:
parent
efcaa3b33d
commit
0686f46d73
6
python/.pylintrc
Normal file
6
python/.pylintrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[MASTER]
|
||||||
|
disable=
|
||||||
|
C0103,
|
||||||
|
C0114,
|
||||||
|
C0115,
|
||||||
|
C0116
|
||||||
@ -4,30 +4,39 @@ class GildedRose(object):
|
|||||||
|
|
||||||
def __init__(self, items):
|
def __init__(self, items):
|
||||||
self.items = items
|
self.items = items
|
||||||
|
self.AGED_BRIE = "Aged Brie"
|
||||||
|
self.SULFURAS = "Sulfuras, Hand of Ragnaros"
|
||||||
|
self.BACKSTAGE_PASSES = "Backstage passes to a TAFKAL80ETC concert"
|
||||||
|
|
||||||
def update_quality(self):
|
def update_quality(self):
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
|
self.update_each_item_quality(item)
|
||||||
|
# print(f'Log: {item}\n')
|
||||||
|
|
||||||
|
def update_each_item_quality(self, item):
|
||||||
|
# Update item.sell_in
|
||||||
|
if item.name != self.SULFURAS:
|
||||||
|
item.sell_in = item.sell_in - 1
|
||||||
|
# Update item.quality
|
||||||
|
if item.name != self.AGED_BRIE and item.name != self.BACKSTAGE_PASSES:
|
||||||
if item.quality > 0:
|
if item.quality > 0:
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
if item.name != self.SULFURAS:
|
||||||
item.quality = item.quality - 1
|
item.quality = item.quality - 1
|
||||||
else:
|
else:
|
||||||
if item.quality < 50:
|
if item.quality < 50:
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1
|
||||||
if item.name == "Backstage passes to a TAFKAL80ETC concert":
|
if item.name == self.BACKSTAGE_PASSES:
|
||||||
if item.sell_in < 11:
|
if item.sell_in < 10:
|
||||||
if item.quality < 50:
|
if item.quality < 50:
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1
|
||||||
if item.sell_in < 6:
|
if item.sell_in < 5:
|
||||||
if item.quality < 50:
|
if item.quality < 50:
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
|
||||||
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 != self.AGED_BRIE:
|
||||||
if item.name != "Backstage passes to a TAFKAL80ETC concert":
|
if item.name != self.BACKSTAGE_PASSES:
|
||||||
if item.quality > 0:
|
if item.quality > 0:
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
if item.name != self.SULFURAS:
|
||||||
item.quality = item.quality - 1
|
item.quality = item.quality - 1
|
||||||
else:
|
else:
|
||||||
item.quality = item.quality - item.quality
|
item.quality = item.quality - item.quality
|
||||||
@ -43,4 +52,4 @@ class Item:
|
|||||||
self.quality = quality
|
self.quality = quality
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "%s, %s, %s" % (self.name, self.sell_in, self.quality)
|
return f"{self.name}, {self.sell_in}, {self.quality}"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user