mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +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,36 +4,45 @@ class GildedRose(object):
|
||||
|
||||
def __init__(self, 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):
|
||||
for item in self.items:
|
||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
|
||||
if item.quality > 0:
|
||||
if item.name != "Sulfuras, Hand of Ragnaros":
|
||||
item.quality = item.quality - 1
|
||||
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.name != self.SULFURAS:
|
||||
item.quality = item.quality - 1
|
||||
else:
|
||||
if item.quality < 50:
|
||||
item.quality = item.quality + 1
|
||||
if item.name == self.BACKSTAGE_PASSES:
|
||||
if item.sell_in < 10:
|
||||
if item.quality < 50:
|
||||
item.quality = item.quality + 1
|
||||
if item.sell_in < 5:
|
||||
if item.quality < 50:
|
||||
item.quality = item.quality + 1
|
||||
if item.sell_in < 0:
|
||||
if item.name != self.AGED_BRIE:
|
||||
if item.name != self.BACKSTAGE_PASSES:
|
||||
if item.quality > 0:
|
||||
if item.name != self.SULFURAS:
|
||||
item.quality = item.quality - 1
|
||||
else:
|
||||
item.quality = item.quality - item.quality
|
||||
else:
|
||||
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.quality < 50:
|
||||
item.quality = item.quality + 1
|
||||
if item.sell_in < 6:
|
||||
if item.quality < 50:
|
||||
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.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
|
||||
else:
|
||||
if item.quality < 50:
|
||||
item.quality = item.quality + 1
|
||||
|
||||
|
||||
class Item:
|
||||
@ -43,4 +52,4 @@ class Item:
|
||||
self.quality = quality
|
||||
|
||||
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