22
33import calculationEngine .battle .WrongItemException ;
44import calculationEngine .environment .CeItem ;
5+ import calculationEngine .environment .CeItemTypes ;
6+
7+ import java .util .ArrayList ;
58
69import static calculationEngine .environment .CeItemTypes .*;
710import static calculationEngine .environment .CeItemTypes .armorShoulder ;
@@ -82,8 +85,27 @@ public void useItem(CeItem item) throws ItemNotInInventoryException {
8285 }
8386 }
8487
88+ public ArrayList <CeItem > getCages () {
89+ return getCeItems (cage );
90+ }
91+
92+ public ArrayList <CeItem > getConsumables () {
93+ return getCeItems (consumable );
94+ }
95+
96+ private ArrayList <CeItem > getCeItems (CeItemTypes itemType ) {
97+ ArrayList <CeItem > items = new ArrayList <>();
98+ for (CeSlot slot : slots ) {
99+ CeItem slotItem = slot .getItem ();
100+ if (slotItem != null && slotItem .getType () == itemType ) {
101+ items .add (slotItem );
102+ }
103+ }
104+ return items ;
105+ }
106+
85107 public void setEquippedItem (CeItem equippedItem ) throws WrongItemException {
86- switch (equippedItem .getType ()){
108+ switch (equippedItem .getType ()) {
87109 case armorShoulder :
88110 setEquippedArmorShoulder (equippedItem );
89111 break ;
@@ -109,54 +131,54 @@ public void setEquippedItem(CeItem equippedItem) throws WrongItemException {
109131 }
110132
111133 private void setEquippedArmorShoulder (CeItem equippedArmorShoulder ) throws WrongItemException {
112- if (this .equippedArmorShoulder != null )
134+ if (this .equippedArmorShoulder != null )
113135 this .equippedArmorShoulder .unequip ();
114- if (equippedArmorShoulder .getType () == armorShoulder ){
136+ if (equippedArmorShoulder .getType () == armorShoulder ) {
115137 this .equippedArmorShoulder = equippedArmorShoulder ;
116138 this .equippedArmorShoulder .equip ();
117139 } else throw new WrongItemException (equippedArmorShoulder , "Armor type shoulderArmor" );
118140 }
119141
120142 private void setEquippedArmorShoes (CeItem equippedArmorShoes ) throws WrongItemException {
121- if (this .equippedArmorShoes != null )
143+ if (this .equippedArmorShoes != null )
122144 this .equippedArmorShoes .unequip ();
123- if (equippedArmorShoes .getType () == armorShoes ){
145+ if (equippedArmorShoes .getType () == armorShoes ) {
124146 this .equippedArmorShoes = equippedArmorShoes ;
125147 this .equippedArmorShoes .equip ();
126148 } else throw new WrongItemException (equippedArmorShoes , "Armor type armorShoes" );
127149 }
128150
129151 private void setEquippedArmorLegs (CeItem equippedArmorLegs ) throws WrongItemException {
130- if (this .equippedArmorLegs != null )
152+ if (this .equippedArmorLegs != null )
131153 this .equippedArmorLegs .unequip ();
132- if (equippedArmorLegs .getType () == armorLegs ){
154+ if (equippedArmorLegs .getType () == armorLegs ) {
133155 this .equippedArmorLegs = equippedArmorLegs ;
134156 this .equippedArmorLegs .equip ();
135157 } else throw new WrongItemException (equippedArmorLegs , "Armor type ArmorLegs" );
136158 }
137159
138160 private void setEquippedArmorChest (CeItem equippedArmorChest ) throws WrongItemException {
139- if (this .equippedArmorChest != null )
161+ if (this .equippedArmorChest != null )
140162 this .equippedArmorChest .unequip ();
141- if (equippedArmorChest .getType () == armorChest ){
163+ if (equippedArmorChest .getType () == armorChest ) {
142164 this .equippedArmorChest = equippedArmorChest ;
143165 this .equippedArmorChest .equip ();
144166 } else throw new WrongItemException (equippedArmorChest , "Armor type ArmorChest" );
145167 }
146168
147169 private void setEquippedArmorHead (CeItem equippedArmorHead ) throws WrongItemException {
148- if (this .equippedArmorHead != null )
170+ if (this .equippedArmorHead != null )
149171 this .equippedArmorHead .unequip ();
150- if (equippedArmorHead .getType () == armorHead ){
172+ if (equippedArmorHead .getType () == armorHead ) {
151173 this .equippedArmorHead = equippedArmorHead ;
152174 this .equippedArmorHead .equip ();
153175 } else throw new WrongItemException (equippedArmorHead , "Armor type armorHead" );
154176 }
155177
156178 private void setEquippedWeapon (CeItem equippedWeapon ) throws WrongItemException {
157- if (this .equippedWeapon != null )
179+ if (this .equippedWeapon != null )
158180 this .equippedWeapon .unequip ();
159- if (equippedWeapon .getType () == weapon ){
181+ if (equippedWeapon .getType () == weapon ) {
160182 this .equippedWeapon = equippedWeapon ;
161183 this .equippedWeapon .equip ();
162184 } else throw new WrongItemException (equippedWeapon , "Armor type weapon" );
0 commit comments