--- a/slotUI/SlotCli.py Sat Dec 17 17:06:06 2011 +0100 +++ b/slotUI/SlotCli.py Sat Dec 17 17:29:08 2011 +0100 @@ -98,6 +98,7 @@ slt["limit"] = 15 idx += 1 self.bestlap = 99999.00 + self.raceactive = False def update_positions(self): order1 = sorted(self.slot, key=itemgetter( @@ -308,6 +309,7 @@ if (self.slot[slot]["laps_last"] != l) and (l == self.laplimit): # we have lap limit reached! trigger_sound("win") + self.raceactive = False self.slot[slot]["status"] = "WINNER!" self.box.query("+") # stop race @@ -322,20 +324,20 @@ self.slot[slot]["fuel_last"] = self.slot[slot]["fuel"] self.slot[slot]["fuel"] = f if self.slot[slot]["fuel_last"] != f: - if (self.slot[slot]["fuel_last"] == 11) and (f == 10): - # 10 percent fuel, set speed limit for car to 8 + if (self.slot[slot]["fuel_last"] == 16) and (f == 15): + # 15 percent fuel, set speed limit for car to 8 # warning sound trigger_sound("fuel_warning1") cli.box.speedlimit(slot, 8) if (self.slot[slot]["fuel_last"] == 6) and (f == 5): - # 5 percent, set speed limit for car to 4 + # 5 percent, set speed limit for car to 6 # warning sound trigger_sound("fuel_warning2") - cli.box.speedlimit(slot, 4) + cli.box.speedlimit(slot, 6) if (self.slot[slot]["fuel_last"] == 1) and (f == 0): # fuel empty - # set speedlimit to 3 - cli.box.speedlimit(slot, 3) + # set speedlimit to 4 + cli.box.speedlimit(slot, 4) if (self.slot[slot]["fuel_last"] < f) and (f >= 11) and (f < 20): cli.box.speedlimit(slot, 15) if (self.slot[slot]["fuel_last"] < f) and (f == 100): @@ -380,6 +382,7 @@ if self.slot[slot]["status"] == "~~~~~~~~~~": self.slot[slot]["status"] = "Idle" trigger_sound("race_start") + self.raceactive = True if rx == "!COUNTDOWN": # countdown initiated @@ -400,15 +403,18 @@ trigger_sound("resume") - if (self.sysclk_last > 0) and (self.sysclk_last != self.sysclk) and ((self.sysclk / 60) >= self.timelimit): + if ((self.timelimit > 0) and (self.raceactive) and + (self.sysclk_last != self.sysclk) and + ((self.sysclk / 60) >= self.timelimit)): self.sysclk_last = self.sysclk + self.raceactive = False # we have time limit reached! + self.box.query("+") # stop race trigger_sound("win") # get the one with position 1 for slot in self.slots: if slot["position"] == 1: slot["status"] = "WINNER!" - self.box.query("+") # stop race self.sysclk_last = self.sysclk