def onMapVote(cn, mapname, mapmode): p = player(cn) if sbserver.mapName() == '': setMap(mapname, mapmode) elif isAtLeastMaster(cn) and sbserver.masterMode() > 0: setMap(mapname, mapmode) elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote): p.message(error('You cannot vote for a new game mode')) else: try: vote = player(cn).gamevars['mapvote'] allow_vote = vote[0] != mapname and vote[1] != mapmode except KeyError: allow_vote = True if allow_vote: sbserver.message( info( request_temp.substitute( colordict, user=p.name(), modename=sbserver.modeName(mapmode), mapname=mapname))) p.gamevars['mapvote'] = (mapname, mapmode) else: sbserver.playerMessage( cn, error('You have already requested this map.')) countVotes()
def render_master_JSON(self, request, user): try: map = request.args['map'][0] mode = request.args['mode'][0] mode_num = modeNumber(mode) except (KeyError, ValueError): return response('invalid_parameters', 'Valid map and mode name not specified') setMap(map, mode_num) return response('success')
def onMapSet(cn, mapname, mapmode): p = player(cn) if sbserver.mapName() == '': setMap(mapname, mapmode) elif mapreload[0]: setMap(mapname, mapmode) mapreload[0] = False elif isAtLeastMaster(cn) and sbserver.masterMode() > 0: sbserver.setMap(mapname, mapmode) elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote): p.message(error('You cannot request a new game mode'))
def countVotes(): players = allPlayers() votes_needed = (len(players) / 2) bestmap = '' bestmode = 0 bestcount = 0 candidates = [] for p in allPlayers(): try: pv = p.gamevars['mapvote'] count = vote(candidates, pv) if count > bestcount: bestmap = pv[0] bestmode = pv[1] bestcount = count except (AttributeError, KeyError): pass if bestcount > votes_needed: serverMessage(info('Vote passed.')) setMap(bestmap, bestmode)
def onMapVote(cn, mapname, mapmode): p = player(cn) if sbserver.mapName() == '': setMap(mapname, mapmode) elif isAtLeastMaster(cn) and sbserver.masterMode() > 0: setMap(mapname, mapmode) elif mapmode != sbserver.gameMode() and (lock_mode or not allow_modevote): p.message(error('You cannot vote for a new game mode')) else: try: vote = player(cn).gamevars['mapvote'] allow_vote = vote[0] != mapname and vote[1] != mapmode except KeyError: allow_vote = True if allow_vote: sbserver.message(info(request_temp.substitute(colordict, user=p.name(), modename=sbserver.modeName(mapmode), mapname=mapname))) p.gamevars['mapvote'] = (mapname, mapmode) else: sbserver.playerMessage(cn, error('You have already requested this map.')) countVotes()
def clanWar(cn, args): '''@description Start a clan war with current teams @usage map (mode)''' sender = player(cn) if args == '': raise UsageError() else: args = args.split(' ') if len(args) == 1: map = args mode = currentMode() elif len(args) == 2: map = args[0] try: mode = modeNumber(args[1]) except ValueError: raise ArgumentValueError('Invalid game mode') persistentTeams(True) setMap(map, mode) setMasterMode(2) setPaused(True, cn) setFrozen(True) clanWarTimer(10, cn)