예제 #1
0
파일: teamcontrol.py 프로젝트: pguenth/xsbs
def onSetTeam(tcn, cn, team):
    p = player(cn)
    r = player(tcn)
    if cn != tcn and not isAtLeastMaster(tcn):
        insufficientPermissions(tcn)
        return
    mode = currentMode()
    if isSafeTeam(team):
        execLater(p.suicide, ())
        p.setTeam(team)
    else:
        r.message(
            error('You cannot join team \'%s\' in game mode %s' %
                  (team, modeName(currentMode()))))
예제 #2
0
def onSetTeam(tcn, cn, team):
	p = player(cn)
	r = player(tcn)
	if cn != tcn and not isAtLeastMaster(tcn):
		insufficientPermissions(tcn)
		return
	mode = currentMode()
	if isSafeTeam(team):
		execLater(p.suicide, ())
		p.setTeam(team)
	else:
		r.message(error('You cannot join team \'%s\' in game mode %s' % (
				team,
				modeName(currentMode())
				)))
예제 #3
0
파일: api.py 프로젝트: GunioRobot/xsbs
	def render_JSON(self, request):
		clients_response = []
		for p in allClients():
			client = {
				'cn': p.cn,
				'name': p.name(),
				'frags': p.frags(),
				'teamkills': p.teamkills(),
				'deaths': p.deaths(),
				'privilege': p.privilege(),
				}
			try:
				client['team'] = p.team()
			except ValueError:
				client['team'] = 'spectator'
			try:
				client['is_verified'] = p.user != None
			except AttributeError:
				client['is_verified'] = False
			clients_response.append(client)
		return json.dumps({
			'clients': clients_response,
			'map': currentMap(),
			'mode': modeName(currentMode())
			})
예제 #4
0
파일: api.py 프로젝트: pguenth/xsbs
 def render_JSON(self, request):
     clients_response = []
     for p in allClients():
         client = {
             'cn': p.cn,
             'name': p.name(),
             'frags': p.frags(),
             'teamkills': p.teamkills(),
             'deaths': p.deaths(),
             'privilege': p.privilege(),
         }
         try:
             client['team'] = p.team()
         except ValueError:
             client['team'] = 'spectator'
         try:
             client['is_verified'] = p.user != None
         except AttributeError:
             client['is_verified'] = False
         clients_response.append(client)
     return json.dumps({
         'clients': clients_response,
         'map': currentMap(),
         'mode': modeName(currentMode())
     })
예제 #5
0
파일: teamcontrol.py 프로젝트: pguenth/xsbs
def onSwitchTeam(cn, team):
    p = player(cn)
    if isSafeTeam(team):
        execLater(p.suicide, ())
        p.setTeam(team)
    else:
        p.message(
            error('You cannot join team \'%s\' in game mode %s' %
                  (team, modeName(currentMode()))))
예제 #6
0
파일: teamcontrol.py 프로젝트: pguenth/xsbs
def isSafeTeam(team):
    '''Is team safe based on current mode.
	   ex: isSafeTeam('test') would return false in capture mode.'''
    mode = currentMode()
    if mode in setteam_modes:
        return True
    if mode in switchteam_modes and team in ['good', 'evil']:
        return True
    return False
예제 #7
0
def isSafeTeam(team):
	'''Is team safe based on current mode.
	   ex: isSafeTeam('test') would return false in capture mode.'''
	mode = currentMode()
	if mode in setteam_modes:
		return True
	if mode in switchteam_modes and team in ['good', 'evil']:
		return True
	return False
예제 #8
0
def onSwitchTeam(cn, team):
	p = player(cn)
	if isSafeTeam(team):
		execLater(p.suicide, ())
		p.setTeam(team)
	else:
		p.message(error('You cannot join team \'%s\' in game mode %s' % (
				team,
				modeName(currentMode())
				)))
예제 #9
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)
예제 #10
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)
예제 #11
0
파일: api.py 프로젝트: GunioRobot/xsbs
	def render_JSON(self, request):
		return json.dumps({
			'map': currentMap(),
			'mode': modeName(currentMode())
			})
예제 #12
0
파일: api.py 프로젝트: pguenth/xsbs
 def render_JSON(self, request):
     return json.dumps({
         'map': currentMap(),
         'mode': modeName(currentMode())
     })