Ver código fonte

cleaned up inventory

Rachelle 8 anos atrás
pai
commit
1cf276698f
1 arquivos alterados com 11 adições e 19 exclusões
  1. 11
    19
      Inventory.java

+ 11
- 19
Inventory.java Ver arquivo

@@ -14,25 +14,10 @@ public class Inventory {
14 14
             }else if(items[i].getName().equals("Aged Brie")){
15 15
                 updateQualityForBrie(i);
16 16
             }else if(items[i].getName().equals("Sulfuras, Hand of Ragnaros")){
17
-                updateQualityForSulfuras(i);
17
+                continue;
18 18
             }else if((items[i].getQuality() > 0)){              
19
-                decreaseQualityByOne(i);                   
19
+                updateQualityForOtherItems(i);               
20 20
             }
21
-
22
-            if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")&&(!items[i].getName().equals("Aged Brie"))) {
23
-                decreaseSellInByOne(i);
24
-            }
25
-
26
-            if (items[i].getSellIn() < 0) {
27
-                if (!items[i].getName().equals("Aged Brie")) {
28
-                    if (items[i].getQuality() > 0) {
29
-                        if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
30
-                            decreaseQualityByOne(i);
31
-                        }
32
-                    }
33
-                } 
34
-            }
35
-
36 21
         }
37 22
     }
38 23
 
@@ -53,6 +38,9 @@ public class Inventory {
53 38
     public void updateQualityForBackstagePasses(int i){
54 39
         if (items[i].getSellIn() < 0){
55 40
             items[i].setQuality(0);
41
+            if(items[i].getQuality() > 0){
42
+                decreaseQualityByOne(i);
43
+            }
56 44
         }else{
57 45
             increaseQualityByOne(i);
58 46
             if(items[i].getSellIn() < 11) {
@@ -72,7 +60,11 @@ public class Inventory {
72 60
         }
73 61
     }
74 62
 
75
-    public void updateQualityForSulfuras(int i){
76
-
63
+    public void updateQualityForOtherItems(int i){
64
+        decreaseQualityByOne(i); 
65
+        decreaseSellInByOne(i);
66
+        if ((items[i].getSellIn() < 0) && (items[i].getQuality() > 0)) {
67
+            decreaseQualityByOne(i);
68
+        }
77 69
     }
78 70
 }