예제 #1
0
    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()
예제 #2
0
  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()
예제 #3
0
    def __init__(self, listeningThread, gameState, sock):
        ClientServerConnection.__init__(self)
        self.listeningThread = listeningThread
        self.logic = StandardGameLogic()
        self.gameState = gameState

        self.setSocket(sock)
예제 #4
0
    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()
예제 #5
0
    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.
예제 #6
0
 def __init__(self, listeningThread, gameState):
   self.listeningThread = listeningThread
   self.logic = StandardGameLogic()
   self.gameState = gameState
예제 #7
0
 def setUp(self):
     self.gl = StandardGameLogic()
     self.gameState = GameState()
     self.gameState.setGameTime(120)
예제 #8
0
 def __init__(self, serverTime):
     self.serverTime = serverTime
     self.logic = StandardGameLogic()
예제 #9
0
def game_logic():
    return StandardGameLogic()