I am writing a program where I have 2 lists. When a certain condition is met, I would like to move an item from "active list" to an "inactive list". Then, I would like to set a timer for the item that moved to inactive list for 4 hours. Once time expires, I would like to move the item back to the active list.
I could have a number of items go to the inactive list, and each item would need its own 4hour timer.
Some simple code:
games_active = []
games_not_active = []
while True:
for x in games_active:
game = games_active.pop()
try:
bot.click_autos()
sleep(random.uniform(4.8, 5.9))
except TypeError:
games_not_active.append(game)
error += 1
I cant think of any solution that would do what i need. Any suggestions where to look?
My idea...
* Create a dictionary of all of your games
* For each game - capture the time before it switches back to active (for active games, set to 0)
* Decrement this time in your loop
* Generate your list on the fly whenever you need it.
So its something like this...
games = dict()
games['game1'] = dict()
games['game1']['timetoActive'] = 0
games['game1']['status'] = 'active'
....
while True:
for game in games:
if game['timetoActive'] > 0:
game['timetoActive'] = game['timetoActive'] - 1
# Decrease the time
else:
games['game1']['status'] = 'inactive'
.....
Then if you need to get all of the active games you could do something like
games = [game for game in games if game['Status'] = 'Active']