def __init__(self): parser = argparse.ArgumentParser(description='BraidsTag gun logic.') parser.add_argument( '-s', '--serial', type=str, help='serial device to which the arduino is connected', required=True) #parser.add_argument('-p', '--playerID', type=self._stringToPlayerID, help='player id', default=1) #parser.add_argument('-t', '--teamID', type=int, choices=xrange(1, 8), help='team id', default=1) self.args = parser.parse_args() self.serverConnection = Client(self) self._sendToServer(proto.HELLO.create(-1, -1)) try: self.serial = serial.Serial(self.args.serial, 115200) self.properSerial = True except serial.serialutil.SerialException: #Try just opening this as a file self.serial = open(self.args.serial) self.properSerial = False def playerDead(): print "Out of lives!" self.logic = StandardGameLogic() self.logic.playerDead.connect(playerDead) self.gameState = GameState() self.connectToArduino()
def __init__(self, serial = None): parser = argparse.ArgumentParser(description='BraidsTag gun logic.') parser.add_argument('-s', '--serial', type=str, help='serial device to which the arduino is connected') self.args = parser.parse_args() self.player = None self.logic = StandardGameLogic() self.gameState = GameState() self.serverConnection = Client(self) self._sendToServer(proto.HELLO.create()) if serial: self.serial = serial self.responsiveSerial = True else: if not self.args.serial: raise ArgumentError("You must specify -s if you do not start in fakeGun mode") try: import serial self.serial = serial.Serial(self.args.serial, 115200) self.responsiveSerial = True except ImportError: #We'll have to open this as a file print("WARNING: No serial module, assuming the serial argument is a normal file for testing") self.serial = open(self.args.serial) self.responsiveSerial = False except serial.serialutil.SerialException: #Try just opening this as a file self.serial = open(self.args.serial) self.responsiveSerial = False self.connectToArduino()
def __init__(self, listeningThread, gameState, sock): ClientServerConnection.__init__(self) self.listeningThread = listeningThread self.logic = StandardGameLogic() self.gameState = gameState self.setSocket(sock)
def __init__(self): parser = argparse.ArgumentParser(description='BraidsTag gun logic.') parser.add_argument( '-s', '--serial', type=str, help='serial device to which the arduino is connected') #parser.add_argument('-p', '--playerID', type=self._stringToPlayerID, help='player id', default=1) #parser.add_argument('-t', '--teamID', type=int, choices=xrange(1, 8), help='team id', default=1) parser.add_argument('-d', '--debugGun', help='use the debuggin gun UI', default=False, action='store_true') self.args = parser.parse_args() self.player = None self.serverConnection = Client(self) self._sendToServer(proto.HELLO.create()) if self.args.debugGun: import fakeGun self.serial = fakeGun.showUI() self.responsiveSerial = True else: if not self.args.serial: raise ArgumentError( "You must specify -s if you do not specify -d") try: import serial self.serial = serial.Serial(self.args.serial, 115200) self.responsiveSerial = True except ImportError: #We'll have to open this as a file print "WARNING: No serial module, assuming the serial argument is a normal file for testing" self.serial = open(self.args.serial) self.responsiveSerial = False except serial.serialutil.SerialException: #Try just opening this as a file self.serial = open(self.args.serial) self.responsiveSerial = False def playerDead(): print "Out of lives!" self.logic = StandardGameLogic() self.logic.playerDead.connect(playerDead) self.gameState = GameState() self.connectToArduino()
def __init__(self, listeningThread, gameState): self.listeningThread = listeningThread self.logic = StandardGameLogic() self.gameState = gameState #map from id to timestamp self.playerLastSeen = {} self.confidencePointGameState = gameState self.eventsSinceConfidencePoint = [ ] # a sorted list of (timestamp, event) self.confidencePoint = 0 self.confidencePointMinimumInterval = 10 # Only update the cache at most once this many seconds.
def __init__(self, listeningThread, gameState): self.listeningThread = listeningThread self.logic = StandardGameLogic() self.gameState = gameState
def setUp(self): self.gl = StandardGameLogic() self.gameState = GameState() self.gameState.setGameTime(120)
def __init__(self, serverTime): self.serverTime = serverTime self.logic = StandardGameLogic()
def game_logic(): return StandardGameLogic()