def duelCountdown(count, map, mode): players = sbserver.players() if len(sbserver.players()) != 2 or players[0] not in duelers or players[1] not in duelers: cancelDuel() elif count == 0: currently_dueling[0] = True sbserver.message(green('Fight!')) sbserver.setMap(map, mode) sbserver.setPaused(False) else: sbserver.message(green('%i seconds' % count)) addTimer(1000, duelCountdown, (count-1, map, mode))
def duelCountdown(count, map, mode): players = sbserver.players() if len(sbserver.players() ) != 2 or players[0] not in duelers or players[1] not in duelers: cancelDuel() elif count == 0: currently_dueling[0] = True sbserver.message(green('Fight!')) sbserver.setMap(map, mode) sbserver.setPaused(False) else: sbserver.message(green('%i seconds' % count)) addTimer(1000, duelCountdown, (count - 1, map, mode))
def onDuelCommand(cn, args): if args == '': sbserver.playerMessage( cn, error('Usage: #duel <mapname> (mode) (cn) (cn)')) args = args.split(' ') players = sbserver.players() if len(players) != 2: sbserver.playerMessage( cn, error( 'There must be only two unspectated players to enter duel mode.' )) else: if len(args) == 2: map = args[0] mode = int(args[1]) elif len(args) == 1: map = args[0] mode = sbserver.gameMode() else: sbserver.playerMessage(cn, error('Usage: #duel <mapname> (mode)')) return duelers[0] = players[0] duelers[1] = players[1] prev_mastermode = sbserver.masterMode() sbserver.setMasterMode(2) sbserver.message(green('Duel begins in...')) duelCountdown(5, map, mode)
def specAll(cn, args): '''@description Make all clients spectators @usage @master''' if args != '': raise ExtraArgumentError() else: for s in sbserver.players(): sbserver.spectate(s)
def onDuelCommand(cn, args): if args == '': sbserver.playerMessage(cn, error('Usage: #duel <mapname> (mode) (cn) (cn)')) args = args.split(' ') players = sbserver.players() if len(players) != 2: sbserver.playerMessage(cn, error('There must be only two unspectated players to enter duel mode.')) else: if len(args) == 2: map = args[0] mode = int(args[1]) elif len(args) == 1: map = args[0] mode = sbserver.gameMode() else: sbserver.playerMessage(cn, error('Usage: #duel <mapname> (mode)')) return duelers[0] = players[0] duelers[1] = players[1] prev_mastermode = sbserver.masterMode() sbserver.setMasterMode(2) sbserver.message(green('Duel begins in...')) duelCountdown(5, map, mode)
def activePlayers(): '''Get list of players as Player instances''' return cnsToPlayers(sbserver.players())
def playerCount(): '''Number of players in game''' return len(sbserver.players())