示例#1
0
    def reset_game(self, player=None, territory=None):
        """reset the score of the game

        player is the player which should be awarded the necessary captures to
        end the game
        """
        self.team_1.initialize()
        self.team_2.initialize()
        if self.game_mode == CTF_MODE:
            if player is None:
                player = list(self.players.values())[0]
            intel_capture = loaders.IntelCapture()
            intel_capture.player_id = player.player_id
            intel_capture.winning = True
            self.send_contained(intel_capture, save=True)
        elif self.game_mode == TC_MODE:
            if territory is None:
                territory = self.entities[0]
            territory_capture = loaders.TerritoryCapture()
            territory_capture.object_index = territory.id
            territory_capture.winning = True
            territory_capture.state = territory.team.id
            self.send_contained(territory_capture)
            self.reset_tc()
        for entity in self.entities:
            entity.update()
        for player in self.players.values():
            if player.team is not None:
                player.spawn()
示例#2
0
from pyspades.master import get_master_connection
#from pyspades.debug import *
from pyspades.team import Team
from pyspades.entities import Territory
# importing tc_data is a quick hack since this file writes into it
from pyspades.player import ServerConnection, tc_data
from pyspades import world
from pyspades.bytes import ByteWriter
from pyspades import contained as loaders
from pyspades.common import make_color
from pyspades.mapgenerator import ProgressiveMapGenerator

fog_color = loaders.FogColor()
world_update = loaders.WorldUpdate()
intel_capture = loaders.IntelCapture()
territory_capture = loaders.TerritoryCapture()


class ServerProtocol(BaseProtocol):
    connection_class = ServerConnection

    name = 'pyspades server'
    game_mode = CTF_MODE
    max_players = 32
    connections = None
    player_ids = None
    master = False
    max_score = 10
    map = None
    spade_teamkills_on_grief = False
    friendly_fire = False