@@ -29,7 +29,7 @@ def __init__(
29
29
super ().__init__ (slots , 5 , slot_class = TeamSlot )
30
30
self ._battle = battle
31
31
self .seed_state = seed_state
32
- self .team = [TeamSlot (seed_state = self .seed_state ) for x in range (self .nslots )]
32
+ self .slots = [TeamSlot (seed_state = self .seed_state ) for x in range (self .nslots )]
33
33
for iter_idx , obj in enumerate (slots ):
34
34
self [iter_idx ] = obj
35
35
self [iter_idx ]._pet .team = self
@@ -121,40 +121,40 @@ def move_backward(self):
121
121
122
122
def remove (self , obj ):
123
123
if type (obj ) == int :
124
- self .team [obj ] = TeamSlot (seed_state = self .seed_state )
124
+ self .slots [obj ] = TeamSlot (seed_state = self .seed_state )
125
125
elif type (obj ).__name__ == "TeamSlot" :
126
126
found = False
127
- for iter_idx , temp_slot in enumerate (self .team ):
127
+ for iter_idx , temp_slot in enumerate (self .slots ):
128
128
if temp_slot == obj :
129
129
found_idx = iter_idx
130
130
found = True
131
131
if not found :
132
132
raise Exception ("Remove {} not found" .format (obj ))
133
- self .team [found_idx ] = TeamSlot (seed_state = self .seed_state )
133
+ self .slots [found_idx ] = TeamSlot (seed_state = self .seed_state )
134
134
elif type (obj ).__name__ == "Pet" :
135
135
found = False
136
- for iter_idx , temp_slot in enumerate (self .team ):
136
+ for iter_idx , temp_slot in enumerate (self .slots ):
137
137
temp_pet = temp_slot .pet
138
138
if temp_pet == obj :
139
139
found_idx = iter_idx
140
140
found = True
141
141
if not found :
142
142
raise Exception ("Remove {} not found" .format (obj ))
143
- self .team [found_idx ] = TeamSlot (seed_state = self .seed_state )
143
+ self .slots [found_idx ] = TeamSlot (seed_state = self .seed_state )
144
144
else :
145
145
raise Exception ("Object of type {} not recognized" .format (type (obj )))
146
146
147
147
def check_friend (self , obj ):
148
148
if type (obj ).__name__ == "TeamSlot" :
149
149
found = False
150
- for iter_idx , temp_slot in enumerate (self .team ):
150
+ for iter_idx , temp_slot in enumerate (self .slots ):
151
151
if temp_slot == obj :
152
152
found_idx = iter_idx
153
153
found = True
154
154
return found
155
155
elif type (obj ).__name__ == "Pet" :
156
156
found = False
157
- for iter_idx , temp_slot in enumerate (self .team ):
157
+ for iter_idx , temp_slot in enumerate (self .slots ):
158
158
temp_pet = temp_slot .pet
159
159
if temp_pet == obj :
160
160
found_idx = iter_idx
@@ -166,7 +166,7 @@ def check_friend(self, obj):
166
166
def get_idx (self , obj ):
167
167
if type (obj ).__name__ == "TeamSlot" :
168
168
found = False
169
- for iter_idx , temp_slot in enumerate (self .team ):
169
+ for iter_idx , temp_slot in enumerate (self .slots ):
170
170
if temp_slot == obj :
171
171
found_idx = iter_idx
172
172
found = True
@@ -175,7 +175,7 @@ def get_idx(self, obj):
175
175
return found_idx
176
176
elif type (obj ).__name__ == "Pet" :
177
177
found = False
178
- for iter_idx , temp_slot in enumerate (self .team ):
178
+ for iter_idx , temp_slot in enumerate (self .slots ):
179
179
temp_pet = temp_slot .pet
180
180
if temp_pet == obj :
181
181
found_idx = iter_idx
@@ -233,7 +233,7 @@ def get_behind(self, obj, n=1):
233
233
chosen = []
234
234
for temp_idx in fidx :
235
235
if temp_idx > pet_idx :
236
- chosen .append (self .team [temp_idx ])
236
+ chosen .append (self .slots [temp_idx ])
237
237
return chosen [0 :n ]
238
238
239
239
def get_empty (self ):
@@ -246,15 +246,15 @@ def get_empty(self):
246
246
def append (self , obj ):
247
247
obj = TeamSlot (obj , seed_state = self .seed_state )
248
248
n = len (self )
249
- if n == len (self .team ):
249
+ if n == len (self .slots ):
250
250
raise Exception ("Attempted to append to a full team" )
251
251
empty_idx = self .get_empty ()
252
252
if len (empty_idx ) == 0 :
253
253
raise Exception ("This should not be possible" )
254
- self .team [empty_idx [0 ]] = obj
254
+ self .slots [empty_idx [0 ]] = obj
255
255
256
256
def check_lvl3 (self ):
257
- for slot in self .team :
257
+ for slot in self .slots :
258
258
if slot .empty :
259
259
continue
260
260
if slot .pet .level == 3 :
@@ -266,33 +266,33 @@ def battle(self):
266
266
return self ._battle
267
267
268
268
def __iter__ (self ):
269
- yield from self .team
269
+ yield from self .slots
270
270
271
271
def __len__ (self ):
272
272
count = 0
273
- for temp_slot in self .team :
273
+ for temp_slot in self .slots :
274
274
if not temp_slot .empty :
275
275
count += 1
276
276
return count
277
277
278
278
def __getitem__ (self , idx ):
279
- return self .team [idx ]
279
+ return self .slots [idx ]
280
280
281
281
def __setitem__ (self , idx , obj ):
282
282
if type (obj ).__name__ == "Pet" :
283
- self .team [idx ] = TeamSlot (obj , seed_state = self .seed_state )
283
+ self .slots [idx ] = TeamSlot (obj , seed_state = self .seed_state )
284
284
elif type (obj ).__name__ == "TeamSlot" :
285
- self .team [idx ] = obj
285
+ self .slots [idx ] = obj
286
286
elif type (obj ) == str or type (obj ) == numpy .str_ :
287
- self .team [idx ] = TeamSlot (obj , seed_state = self .seed_state )
287
+ self .slots [idx ] = TeamSlot (obj , seed_state = self .seed_state )
288
288
else :
289
289
raise Exception (
290
290
"Tried setting a team slot with type {}" .format (type (obj ).__name__ )
291
291
)
292
292
293
293
def __repr__ (self ):
294
294
repr_str = ""
295
- for iter_idx , slot in enumerate (self .team ):
295
+ for iter_idx , slot in enumerate (self .slots ):
296
296
repr_str += "{}: {} \n " .format (iter_idx , slot )
297
297
return repr_str
298
298
@@ -311,7 +311,7 @@ def state(self):
311
311
state_dict = {
312
312
"type" : "Team" ,
313
313
"battle" : self .battle ,
314
- "team" : [x .state for x in self .team ],
314
+ "team" : [x .state for x in self .slots ],
315
315
"pack" : self .pack ,
316
316
}
317
317
return state_dict
0 commit comments