For my game Stellar Crossroads I am completing a covert mission mechanic and am encountering the following glitch when attempting to search a container and move objects into another container that satisfy a certain condition.
The code above searches the covertactive container and moves agents to the covertmission container that satisfy the "Selected" criteria. It is working inconsistently however, in that when I have agents that are adjacent to each other in the container it fails to move the second agent. From what I can tell, the for loop is skipping over the second agent and not testing them.
Say items 3 and 4 in the container satisfy the criteria, the for loop works correctly on the 3rd item, however the next loop looks at the 4th item in the revised container, which before the move function was actually the 5th. Hence the 4th item never gets tested.
Is there a way of adjusting the code above to relieve this problem?
Python:
def agent_allocate():
for sagent in covertactive.agents:
if sagent.status == "Selected":
sagent.status = "CM-{:03d}".format(covert_counter)
move_agent(sagent, covertactive, covertmission)
Say items 3 and 4 in the container satisfy the criteria, the for loop works correctly on the 3rd item, however the next loop looks at the 4th item in the revised container, which before the move function was actually the 5th. Hence the 4th item never gets tested.
Is there a way of adjusting the code above to relieve this problem?