예제 #1
0
파일: mapvote.py 프로젝트: pguenth/xsbs
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()
예제 #2
0
파일: server.py 프로젝트: pguenth/xsbs
	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')
예제 #3
0
파일: mapvote.py 프로젝트: pguenth/xsbs
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'))
예제 #4
0
파일: mapvote.py 프로젝트: GunioRobot/xsbs
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'))
예제 #5
0
파일: mapvote.py 프로젝트: pguenth/xsbs
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)
예제 #6
0
파일: mapvote.py 프로젝트: GunioRobot/xsbs
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)
예제 #7
0
파일: mapvote.py 프로젝트: GunioRobot/xsbs
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()
예제 #8
0
파일: clanwar.py 프로젝트: GunioRobot/xsbs
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)
예제 #9
0
파일: clanwar.py 프로젝트: pguenth/xsbs
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)