Exemplo n.º 1
0
def check_win(a):
    current = a.fg_wz_current
    ownedflags = 0
    winfreq = -1

    for i in range(current):
        n, f = flagcore.GetFlags(a, i)
        assert n == 1
        if f.state == asss.FI_ONMAP:
            if f.freq == winfreq:
                ownedflags += 1
            else:
                winfreq = f.freq
                ownedflags = 1

    # just to check
    for i in range(current, a.fg_wz_sets.max):
        n, f = flagcore.GetFlags(a, current)
        assert n == 0 or f.state == asss.FI_NONE

    if ownedflags == current and winfreq != -1:
        # we have a winner!
        points = asss.call_callback(asss.CB_WARZONEWIN, (a, winfreq, 0), a)
        # hardcoded default
        if points == 0: points = 1000
        flagcore.FlagReset(a, winfreq, points)
        a.fg_wz_current = 0
        if a.fg_wz_sets.warpplayersonwin:
            for i in range(0, a.fg_wz_sets.maxfreqtowarp + 1):
                game.GivePrize((a, i), asss.PRIZE_WARP, 1)

        if a.fg_wz_last_freq_to_win != winfreq:
            a.fg_wz_last_freq_to_win = winfreq
            a.fg_wz_consecutive_wins = 0

        a.fg_wz_consecutive_wins += 1
        if winfreq <= a.fg_wz_sets.maxfreqtoshuffle and \
           winfreq >= a.fg_wz_sets.minfreqtoshuffle:
            playerlist = []
            if a.fg_wz_sets.consecutivewinstoshuffle > 0 and \
               a.fg_wz_consecutive_wins >= a.fg_wz_sets.consecutivewinstoshuffle:
                a.fg_wz_last_freq_to_win = -1
                a.fg_wz_consecutive_wins = 0
                chat.SendArenaMessage(a,
                                      "---SPECCING EVERYONE TO EVEN TEAMS---")

                def playerstolist(p):
                    if p.freq <= a.fg_wz_sets.maxfreqtoshuffle and \
                       p.freq >= a.fg_wz_sets.minfreqtoshuffle and \
                       p.arena == a and p.type != asss.T_FAKE:
                        playerlist.append((p, p.ship))
                        game.SetShipAndFreq(p, asss.SHIP_SPEC, a.specfreq)

                asss.for_each_player(playerstolist)
                random.shuffle(playerlist)

                for (p, ship) in playerlist:
                    (actualship,
                     actualfreq) = a.fg_wz_freqman.ShipChange(p, ship, 0)
                    game.SetShipAndFreq(p, actualship, actualfreq)
Exemplo n.º 2
0
def check_flag_team_sizes(arena):
    freqs = {}
    result = True

    def get_freq_counts(player):
        if player.type != asss.T_CONT and player.type != asss.T_VIE:
            return

        if player.arena == arena and player.ship != asss.SHIP_SPEC:
            if player.freq in freqs:
                freqs[player.freq] += 1
            else:
                freqs[player.freq] = 1

    if arena.fg_wz_sets.minplayersperteam > 0:
        # get freq player counts
        asss.for_each_player(get_freq_counts)

        for i in range(arena.fg_wz_sets.privfreqstart,
                       arena.fg_wz_sets.privfreqmax):
            if i not in freqs or freqs[i] < arena.fg_wz_sets.minplayersperteam:
                result = False
                break

    return result
Exemplo n.º 3
0
def count_freq(a, f):
	count = [0]
	def each_player(p):
		if p.arena == a and p.freq == f:
			count[0] += 1
	asss.for_each_player(each_player)
	return count[0]
Exemplo n.º 4
0
def arenaToPlayerList(arena):
    def each(player):
        if player.arena == arena:
            playerList.append(player)

    playerList = asss.PlayerListType()
    asss.for_each_player(each)
    return playerList
Exemplo n.º 5
0
 def cleanup(self):
     del self.cbs[:]
     del self.cmds[:]
     del self.ready[:]
     self.p1 = None
     self.p2 = None
     asss.for_each_player(lambda p: self.del_pdat(p))
     self.arena = None
Exemplo n.º 6
0
 def cleanup(self):
     del self.cbs[:]
     del self.cmds[:]
     del self.ready[:]
     self.p1 = None
     self.p2 = None
     asss.for_each_player(lambda p : self.del_pdat(p))
     self.arena = None
Exemplo n.º 7
0
def arenaToPlayerList(arena):
	def each(player):
		if player.arena == arena:
			playerList.append(player)

	playerList = asss.PlayerListType()
	asss.for_each_player(each)
	return playerList
Exemplo n.º 8
0
def count_freq(a, f):
    count = [0]

    def each_player(p):
        if p.arena == a and p.freq == f:
            count[0] += 1

    asss.for_each_player(each_player)
    return count[0]
Exemplo n.º 9
0
def check_win(a):
  current = a.fg_wz_current
  ownedflags = 0
  winfreq = -1

  for i in range(current):
    n, f = flagcore.GetFlags(a, i)
    assert n == 1
    if f.state == asss.FI_ONMAP:
      if f.freq == winfreq:
        ownedflags += 1
      else:
        winfreq = f.freq
        ownedflags = 1

  # just to check
  for i in range(current, a.fg_wz_sets.max):
    n, f = flagcore.GetFlags(a, current)
    assert n == 0 or f.state == asss.FI_NONE

  if ownedflags == current and winfreq != -1:
    # we have a winner!
    points = asss.call_callback(asss.CB_WARZONEWIN, (a, winfreq, 0), a)
    # hardcoded default
    if points == 0: points = 1000
    flagcore.FlagReset(a, winfreq, points)
    a.fg_wz_current = 0
    if a.fg_wz_sets.warpplayersonwin:
      for i in range(0, a.fg_wz_sets.maxfreqtowarp+1):
        game.GivePrize((a, i), asss.PRIZE_WARP, 1)

    if a.fg_wz_last_freq_to_win != winfreq:
      a.fg_wz_last_freq_to_win = winfreq
      a.fg_wz_consecutive_wins = 0

    a.fg_wz_consecutive_wins += 1
    if winfreq <= a.fg_wz_sets.maxfreqtoshuffle and \
       winfreq >= a.fg_wz_sets.minfreqtoshuffle:
      playerlist = []
      if a.fg_wz_sets.consecutivewinstoshuffle > 0 and \
         a.fg_wz_consecutive_wins >= a.fg_wz_sets.consecutivewinstoshuffle:
        a.fg_wz_last_freq_to_win = -1
        a.fg_wz_consecutive_wins = 0
        chat.SendArenaMessage(a, "---SPECCING EVERYONE TO EVEN TEAMS---")
        def playerstolist(p):
          if p.freq <= a.fg_wz_sets.maxfreqtoshuffle and \
             p.freq >= a.fg_wz_sets.minfreqtoshuffle and \
             p.arena == a and p.type != asss.T_FAKE:
            playerlist.append((p, p.ship))
            game.SetShipAndFreq(p, asss.SHIP_SPEC, a.specfreq)
        asss.for_each_player(playerstolist)
        random.shuffle(playerlist)

        for (p, ship) in playerlist:
          (actualship, actualfreq) = a.fg_wz_freqman.ShipChange(p, ship, 0)
          game.SetShipAndFreq(p, actualship, actualfreq)
Exemplo n.º 10
0
def getP(name):
	""" Returns pointer to player or None """
	_p = [0]
	def each_player(p):
		if str(p.name.lower()) == str(name.lower()):
			_p[0] = p
			return _p[0]
	asss.for_each_player(each_player)
	if isinstance(_p[0], asss.PlayerType):
		return _p[0]
	return None
Exemplo n.º 11
0
def dev(targ, msg):

	"""Provides chat function for development. Must be Mod+ to view.
	
	On client-> profile-> auto (underneath chats), or ?devmode in game. 
	
	Targ can be either p or arena."""

	list = asss.PlayerListType()
	if isinstance(targ, asss.PlayerType):
		if getattr(targ, 'devmode', 'False'):
			list.append(targ)
	elif isinstance(targ, asss.ArenaType):
		def listplayer(p):
			if p.arena == targ and \
				getattr(targ, 'devmode', 'False'):
					list.append(p)
		asss.for_each_player(listplayer)
	chat.SendAnyMessage(list, asss.MSG_MODCHAT, 0, None, msg)
Exemplo n.º 12
0
def c_lancs(cmd, params, p, targ):
    """Module: <py> hs_lancs
Targets: none
Args: none
Tells you the names of the lancasters on your team. (S) indicates summoner."""
    f = p.freq
    a = p.arena
    lancs = []

    if not a.hs_lanc_item_summoner:
        a.hs_lanc_item_summoner = items.getItemByName('Summoner', a)

    if not a.hs_lanc_item_evoker:
        a.hs_lanc_item_evoker = items.getItemByName('Evoker', a)

    def print_lancs(lanc):
        if lanc.type != asss.T_CONT and lanc.type != asss.T_VIE:
            return

        if lanc.arena == a and lanc.freq == f and lanc.ship != asss.SHIP_SPEC:
            if a.hs_lanc_item_evoker is not None and items.getItemCount(
                    lanc, a.hs_lanc_item_evoker, lanc.ship) > 0:
                msg = '(E) ' + lanc.name
                lancs.append(msg)
                return  # don't list lancs with evoker twice

        if lanc.arena == a and lanc.freq == f and lanc.ship == asss.SHIP_LANCASTER:
            msg = None
            if a.hs_lanc_item_summoner is not None and items.getItemCount(
                    lanc, a.hs_lanc_item_summoner, lanc.ship) > 0:
                msg = '(S) ' + lanc.name
            else:
                msg = lanc.name
            if msg:
                lancs.append(msg)

    asss.for_each_player(print_lancs)

    if len(lancs) > 0:
        chat.SendMessage(p, ', '.join(lancs))
    else:
        chat.SendMessage(p, 'There are no Lancasters on your team.')
Exemplo n.º 13
0
def c_lancs(cmd, params, p, targ):
    """Module: <py> hs_lancs
Targets: none
Args: none
Tells you the names of the lancasters on your team. (S) indicates summoner."""
    f = p.freq
    a = p.arena
    lancs = []
   
    if not a.hs_lanc_item_summoner:
        a.hs_lanc_item_summoner = items.getItemByName('Summoner', a)
       
    if not a.hs_lanc_item_evoker:
        a.hs_lanc_item_evoker = items.getItemByName('Evoker', a)
   
    def print_lancs(lanc):
        if lanc.type != asss.T_CONT and lanc.type != asss.T_VIE:
            return
 
        if lanc.arena == a and lanc.freq == f and lanc.ship != asss.SHIP_SPEC:
            if a.hs_lanc_item_evoker is not None and items.getItemCount(lanc, a.hs_lanc_item_evoker, lanc.ship) > 0:
                msg = '(E) ' + lanc.name
                lancs.append(msg)
                return # don't list lancs with evoker twice
               
        if lanc.arena == a and lanc.freq == f and lanc.ship == asss.SHIP_LANCASTER:
            msg = None
            if a.hs_lanc_item_summoner is not None and items.getItemCount(lanc, a.hs_lanc_item_summoner, lanc.ship) > 0:
                msg = '(S) ' + lanc.name
            else:
                msg = lanc.name
            if msg:
                lancs.append(msg)
 
    asss.for_each_player(print_lancs)
 
    if len(lancs) > 0:
        chat.SendMessage(p, ', '.join(lancs))
    else:
        chat.SendMessage(p, 'There are no Lancasters on your team.')
Exemplo n.º 14
0
def check_flag_team_sizes(arena):
  freqs = {}
  result = True

  def get_freq_counts(player):
    if player.type != asss.T_CONT and player.type != asss.T_VIE:
      return

    if player.arena == arena and player.ship != asss.SHIP_SPEC:
      if player.freq in freqs:
        freqs[player.freq] += 1
      else:
        freqs[player.freq] = 1

  if arena.fg_wz_sets.minplayersperteam > 0:
    # get freq player counts
    asss.for_each_player(get_freq_counts)

    for i in range(arena.fg_wz_sets.privfreqstart, arena.fg_wz_sets.privfreqmax):
      if i not in freqs or freqs[i] < arena.fg_wz_sets.minplayersperteam:
        result = False
        break

  return result;