|
@@ -10,6 +10,28 @@ from itertools import cycle
|
|
|
import pendulum
|
|
|
from pprint import pformat
|
|
|
|
|
|
+class SpinningCursor(object):
|
|
|
+ """ Spinner class, that handles every so many clicks
|
|
|
+
|
|
|
+ s = SpinningCursor(5) # every 5
|
|
|
+ for x in range(10):
|
|
|
+ if s.click():
|
|
|
+ print(s.cycle())
|
|
|
+
|
|
|
+ """
|
|
|
+ def __init__(self, every=10):
|
|
|
+ self.itercycle = cycle(["/", "-", "\\", "|"])
|
|
|
+ self.count = 0
|
|
|
+ self.every = every
|
|
|
+ def reset(self):
|
|
|
+ self.itercycle = cycle(["/", "-", "\\", "|"])
|
|
|
+ self.count = 0
|
|
|
+ def click(self):
|
|
|
+ self.count += 1
|
|
|
+ return self.count % self.every == 0
|
|
|
+ def cycle(self):
|
|
|
+ return next(self.itercycle)
|
|
|
+
|
|
|
|
|
|
def merge(color_string):
|
|
|
""" Given a string of colorama ANSI, merge them if you can. """
|
|
@@ -239,13 +261,13 @@ class CIMWarpReport(object):
|
|
|
self.queue_player.put("^") # Activate CIM
|
|
|
self.state = 1
|
|
|
# self.warpdata = {}
|
|
|
- self.warpcycle = cycle(["/", "-", "\\", "|"])
|
|
|
+ self.warpcycle = SpinningCursor()
|
|
|
|
|
|
def game_prompt(self, prompt):
|
|
|
if prompt == ": ":
|
|
|
if self.state == 1:
|
|
|
# Ok, then we're ready to request the port report
|
|
|
- self.warpcycle = cycle(["/", "-", "\\", "|"])
|
|
|
+ self.warpcycle.reset()
|
|
|
self.queue_player.put("I")
|
|
|
self.state = 2
|
|
|
elif self.state == 2:
|
|
@@ -275,8 +297,8 @@ class CIMWarpReport(object):
|
|
|
|
|
|
# This should be the CIM Report Data -- parse it
|
|
|
if self.warpcycle:
|
|
|
- if len(self.game.gamedata.warps) % 10 == 0:
|
|
|
- self.queue_game.put("\b" + next(self.warpcycle))
|
|
|
+ if self.warpcycle.click():
|
|
|
+ self.queue_game.put("\b" + self.warpcycle.cycle())
|
|
|
|
|
|
work = line.strip()
|
|
|
parts = re.split(r"(?<=\d)\s", work)
|
|
@@ -367,13 +389,13 @@ class CIMPortReport(object):
|
|
|
self.queue_player.put("^") # Activate CIM
|
|
|
self.state = 1
|
|
|
# self.portdata = {}
|
|
|
- self.portcycle = cycle(["/", "-", "\\", "|"])
|
|
|
+ self.portcycle = SpinningCursor()
|
|
|
|
|
|
def game_prompt(self, prompt):
|
|
|
if prompt == ": ":
|
|
|
if self.state == 1:
|
|
|
# Ok, then we're ready to request the port report
|
|
|
- self.portcycle = cycle(["/", "-", "\\", "|"])
|
|
|
+ self.portcycle.reset()
|
|
|
self.queue_player.put("R")
|
|
|
self.state = 2
|
|
|
elif self.state == 2:
|
|
@@ -401,8 +423,8 @@ class CIMPortReport(object):
|
|
|
|
|
|
# This should be the CIM Report Data -- parse it
|
|
|
if self.portcycle:
|
|
|
- if len(self.game.gamedata.ports) % 10 == 0:
|
|
|
- self.queue_game.put("\b" + next(self.portcycle))
|
|
|
+ if self.portcycle.click():
|
|
|
+ self.queue_game.put("\b" + self.portcycle.cycle())
|
|
|
|
|
|
work = line.replace("%", "")
|
|
|
|
|
@@ -1134,8 +1156,9 @@ class ProxyMenu(object):
|
|
|
ok_trades = []
|
|
|
best_trades = []
|
|
|
|
|
|
-
|
|
|
- for sector, pd in self.game.gamedata.ports.items():
|
|
|
+ # for sector, pd in self.game.gamedata.ports.items():
|
|
|
+ for sector in sorted(self.game.gamedata.ports.keys()):
|
|
|
+ pd = self.game.gamedata.ports[sector]
|
|
|
if not port_burnt(pd):
|
|
|
pc = pd['class']
|
|
|
|