Пример #1
0
def try_start_lobby_countdown():
	global lobby_countdown_started, lobby_countdown_left
	if lobby_countdown_started == False and cmd.getGameState()[0] == "S_SVRLOBBY" and len(cmd.getWormList()) >= MIN_PLAYERS_TO_START_GAME:
		lobby_countdown_started = True
		lobby_countdown_left = LOBBY_COUNTDOWN_SECONDS
		cmd.chatMsg("The game will start in %i seconds" % LOBBY_COUNTDOWN_SECONDS)
		return True
	return False
Пример #2
0
def try_start_lobby_countdown():
    global lobby_countdown_started, lobby_countdown_left
    if lobby_countdown_started == False and cmd.getGameState(
    )[0] == "S_SVRLOBBY" and len(
            cmd.getWormList()) >= MIN_PLAYERS_TO_START_GAME:
        lobby_countdown_started = True
        lobby_countdown_left = LOBBY_COUNTDOWN_SECONDS
        cmd.chatMsg("The game will start in %i seconds" %
                    LOBBY_COUNTDOWN_SECONDS)
        return True
    return False
Пример #3
0
def signal_handler(signal):
    global lobby_countdown_started, lobby_countdown_left, invading_army

    if signal[0] == "newworm":
        if not worm_is_local(
                signal[1]
        ):  # This player is from outside the the dedicated server
            cmd.setWormTeam(signal[1],
                            DEFENDER_TEAM)  # Put it in the defender team.
        try_start_lobby_countdown(
        )  # Perhaps we are enough players to start the game now!

    if signal[0] == "wormdied":
        pass
        # If the worm is a local enemy worm and it is out of lives, kick it.
        #if worm_is_local(signal[1]) and cmd.getWormLives(signal[1])[0] == "-1":
        #	cmd.kickWorm(signal[1])
        # Now the game could be over. If it is; we would like to view the scoreboard...

    if signal[0] == "quit":
        exit()

    if signal[0] == "timer":
        if lobby_countdown_started:
            lobby_countdown_left -= 1

            if lobby_countdown_left < 1:
                lobby_countdown_started = False
                #Start the new game!
                start_game_ret = cmd.startGame()
                if len(start_game_ret) > 0:  # this means an error
                    cmd.chatMsg(start_game_ret[0])
                # Add new bots:
                invading_army.produce()
                cmd.setVar("GameOptions.GameInfo.AllowEmptyGames",
                           False)  # Set the allow empty games flag

    if signal[0] in ["backtolobby", "lobbystarted"]:
        # We have entered the lobby. prepare for next battle...

        cmd.setVar("GameOptions.GameInfo.AllowEmptyGames",
                   True)  # Set the allow empty games flag

        # Kick all bots in case there are any. However there should not be. They should be kicked ingame when they are out of lives
        cmd.kickBots()

        # select next map, next mod and decide which the next enemies will be!
        cmd.map(random.choice(all_available_maps))
        invading_army = army_architect.generate_blueprint(
            get_num_foreign_worms() + 0.5, None, 0, ENEMY_TEAM
        )  # DARN! We do not want to decide challenge level yet! What ever! It will adapt afterwards...

        # Give army information
        cmd.chatMsg("<b>Next Invading Army: " +
                    get_command_safe_string(invading_army.name) + "</b>")
        cmd.chatMsg(get_command_safe_string(invading_army.description))
        cmd.chatMsg(" ")

        try_start_lobby_countdown(
        )  # Perhaps we are enough players to start the game now!
Пример #4
0
def signal_handler(signal):
	global lobby_countdown_started, lobby_countdown_left, invading_army
	
	if signal[0] == "newworm":
		if not worm_is_local(signal[1]): # This player is from outside the the dedicated server
			cmd.setWormTeam(signal[1], DEFENDER_TEAM) # Put it in the defender team.
		try_start_lobby_countdown() # Perhaps we are enough players to start the game now!

	if signal[0] == "wormdied":
		pass
		# If the worm is a local enemy worm and it is out of lives, kick it.
		#if worm_is_local(signal[1]) and cmd.getWormLives(signal[1])[0] == "-1":
		#	cmd.kickWorm(signal[1])
		# Now the game could be over. If it is; we would like to view the scoreboard...
		
	if signal[0] == "quit":
		exit()
	
	if signal[0] == "timer":
		if lobby_countdown_started:
			lobby_countdown_left -= 1
			
			if lobby_countdown_left < 1:
				lobby_countdown_started = False
				#Start the new game!
				start_game_ret = cmd.startGame()
				if len(start_game_ret) > 0: # this means an error
					cmd.chatMsg(start_game_ret[0])
				# Add new bots:
				invading_army.produce()
				cmd.setVar("GameOptions.GameInfo.AllowEmptyGames", False) # Set the allow empty games flag
	
	if signal[0] in ["backtolobby", "lobbystarted"]:
		# We have entered the lobby. prepare for next battle...
		
		cmd.setVar("GameOptions.GameInfo.AllowEmptyGames", True) # Set the allow empty games flag
		
		# Kick all bots in case there are any. However there should not be. They should be kicked ingame when they are out of lives
		cmd.kickBots() 
		
		# select next map, next mod and decide which the next enemies will be!
		cmd.map(random.choice(all_available_maps))
		invading_army = army_architect.generate_blueprint(get_num_foreign_worms()+0.5, None, 0, ENEMY_TEAM) # DARN! We do not want to decide challenge level yet! What ever! It will adapt afterwards...
		
		# Give army information
		cmd.chatMsg("<b>Next Invading Army: "+get_command_safe_string(invading_army.name)+"</b>")
		cmd.chatMsg(get_command_safe_string(invading_army.description))
		cmd.chatMsg(" ")
		
		try_start_lobby_countdown() # Perhaps we are enough players to start the game now!