-
Notifications
You must be signed in to change notification settings - Fork 0
/
gilded_rose_ifs_combined.py
52 lines (40 loc) · 1.55 KB
/
gilded_rose_ifs_combined.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
import pytest
from logic_checks import *
class GildedRose(object):
def __init__(self, items):
self.items = items
def update_quality(self):
for item in self.items:
update_item(item)
def update_item(item):
if itemNotSpecialCheck(item) and qualityPositiveCheck(item):
item.quality = decreaseQuality(item)
else:
item.quality = increaseQualityIfLessThanMaxQuality(item)
if itemNotSpecialCheck(item) and qualityPositiveCheck(item) and sellInNegativeCheck(item):
item.quality = decreaseQuality(item)
if itemIsConjuredCheck(item):
if sellInPositiveCheck(item):
item.quality = decreaseQuality(item)
else:
item.quality = decreaseQualityBy2(item)
if itemIsBackstagePassCheck(item):
if sellInLessThan11Check(item):
item.quality = increaseQualityIfLessThanMaxQuality(item)
if sellInLessThan6Check(item):
item.quality = increaseQualityIfLessThanMaxQuality(item)
if sellInNegativeCheck(item):
item.quality = zeroQuality(item)
if itemIsBrieCheck(item):
if sellInNegativeCheck(item):
item.quality = increaseQualityIfLessThanMaxQuality(item)
if itemNotSulfurasCheck(item):
item.sell_in = decreaseSellIn(item)
class Item:
def __init__(self, name, sell_in, quality):
self.name = name
self.sell_in = sell_in
self.quality = quality
def __repr__(self):
return "%s, %s, %s" % (self.name, self.sell_in, self.quality)