mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
add support for tray and board sizes
This commit is contained in:
parent
b3123c5a48
commit
be9159fc35
2 changed files with 19 additions and 7 deletions
|
@ -1465,6 +1465,15 @@ makeGameFromArgs( CursesAppGlobals* aGlobals, cJSON* args )
|
||||||
XP_ASSERT( !!tmp );
|
XP_ASSERT( !!tmp );
|
||||||
gi.nPlayers = tmp->valueint;
|
gi.nPlayers = tmp->valueint;
|
||||||
|
|
||||||
|
tmp = cJSON_GetObjectItem( args, "boardSize" );
|
||||||
|
if ( !!tmp ) {
|
||||||
|
gi.boardSize = tmp->valueint;
|
||||||
|
}
|
||||||
|
tmp = cJSON_GetObjectItem( args, "traySize" );
|
||||||
|
if ( !!tmp ) {
|
||||||
|
gi.traySize = tmp->valueint;
|
||||||
|
}
|
||||||
|
|
||||||
tmp = cJSON_GetObjectItem( args, "hostPosn" );
|
tmp = cJSON_GetObjectItem( args, "hostPosn" );
|
||||||
XP_ASSERT( !!tmp );
|
XP_ASSERT( !!tmp );
|
||||||
int hostPosn = tmp->valueint;
|
int hostPosn = tmp->valueint;
|
||||||
|
|
|
@ -205,12 +205,15 @@ class Device():
|
||||||
self.mqttDevID = response
|
self.mqttDevID = response
|
||||||
|
|
||||||
def makeGames(self):
|
def makeGames(self):
|
||||||
|
args = self.args
|
||||||
for remote in self.hostedGames:
|
for remote in self.hostedGames:
|
||||||
guests = remote.guestNames
|
nPlayers = 1 + len(remote.guestNames)
|
||||||
nPlayers = 1 + len(guests)
|
|
||||||
hostPosn = random.randint(0, nPlayers-1)
|
hostPosn = random.randint(0, nPlayers-1)
|
||||||
|
traySize = 0 == args.TRAY_SIZE and random.randint(7, 9) or args.TRAY_SIZE
|
||||||
|
|
||||||
self._sendWaitReply('makeGame', nPlayers=nPlayers, hostPosn=hostPosn,
|
self._sendWaitReply('makeGame', nPlayers=nPlayers, hostPosn=hostPosn,
|
||||||
gid=remote.gid, dict=self.args.DICTS[0])
|
gid=remote.gid, dict=args.DICTS[0],
|
||||||
|
boardSize=args.BOARD_SIZE, traySize=traySize)
|
||||||
|
|
||||||
# This is the heart of things. Do something as long as we have a
|
# This is the heart of things. Do something as long as we have a
|
||||||
# game that needs to run.
|
# game that needs to run.
|
||||||
|
@ -537,11 +540,11 @@ def mkParser():
|
||||||
parser.add_argument('--mqtt-port', dest = 'MQTT_PORT', default = 1883 )
|
parser.add_argument('--mqtt-port', dest = 'MQTT_PORT', default = 1883 )
|
||||||
parser.add_argument('--mqtt-host', dest = 'MQTT_HOST', default = 'localhost' )
|
parser.add_argument('--mqtt-host', dest = 'MQTT_HOST', default = 'localhost' )
|
||||||
|
|
||||||
# parser.add_argument('--force-tray', dest = 'TRAYSIZE', default = 0, type = int,
|
parser.add_argument('--force-tray', dest = 'TRAY_SIZE', default = 0, type = int,
|
||||||
# help = 'Always this many tiles per tray')
|
help = 'Always this many tiles per tray')
|
||||||
|
parser.add_argument('--board-size', dest = 'BOARD_SIZE', type = int, default = 15,
|
||||||
|
help = 'Use <n>x<n> size board')
|
||||||
|
|
||||||
# parser.add_argument('--board-size', dest = 'BOARD_SIZE', type = int, default = 15,
|
|
||||||
# help = 'Use <n>x<n> size board')
|
|
||||||
# parser.add_argument('--rematch-limit-secs', dest = 'REMATCH_SECS', type = int, default = 0,
|
# parser.add_argument('--rematch-limit-secs', dest = 'REMATCH_SECS', type = int, default = 0,
|
||||||
# help = 'rematch games that end within this many seconds of script launch')
|
# help = 'rematch games that end within this many seconds of script launch')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue