readability

This commit is contained in:
Ashwin Rana 2023-09-27 17:34:35 +00:00
parent efcaa3b33d
commit 0686f46d73
2 changed files with 40 additions and 25 deletions

6
python/.pylintrc Normal file
View File

@ -0,0 +1,6 @@
[MASTER]
disable=
C0103,
C0114,
C0115,
C0116

View File

@ -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}"