Package megamek.common

Examples of megamek.common.Team


        int nTeams = game.getNoOfTeams();
        Hashtable<Team, TurnVectors> allTeamTurns = new Hashtable<Team, TurnVectors>(nTeams);
        Hashtable<Team, int[]> evenTrackers = new Hashtable<Team, int[]>(nTeams);
        int numTeamsMoving = 0;
        for (Enumeration<Team> loop = game.getTeams(); loop.hasMoreElements();) {
            final Team team = loop.nextElement();
            allTeamTurns.put(team, team.determineTeamOrder(game));

            // Track both the number of times we've checked the team for
            // "leftover" turns, and the number of "leftover" turns placed.
            int[] evenTracker = new int[2];
            evenTracker[0] = 0;
            evenTracker[1] = 0;
            evenTrackers.put(team, evenTracker);

            // Count this team if it has any "normal" moves.
            if (team.getNormalTurns(game) > 0) {
                numTeamsMoving++;
            }
        }

        // Now, generate the global order of all teams' turns.
        TurnVectors team_order = TurnOrdered.generateTurnOrder(game.getTeamsVector(), game);

        // See if there are any loaded units stranded on immobile transports.
        Enumeration<Entity> strandedUnits = game.getSelectedEntities(new EntitySelector() {
            public boolean accept(Entity entity) {
                if (game.isEntityStranded(entity)) {
                    return true;
                }
                return false;
            }
        });

        // Now, we collect everything into a single vector.
        Vector<GameTurn> turns;

        if (strandedUnits.hasMoreElements() && (game.getPhase() == IGame.Phase.PHASE_MOVEMENT)) {
            // Add a game turn to unload stranded units, if this
            // is the movement phase.
            turns = new Vector<GameTurn>(team_order.getTotalTurns() + team_order.getEvenTurns() + 1);
            turns.addElement(new GameTurn.UnloadStrandedTurn(strandedUnits));
        } else {
            // No stranded units.
            turns = new Vector<GameTurn>(team_order.getTotalTurns() + team_order.getEvenTurns());
        }

        // Walk through the global order, assigning turns
        // for individual players to the single vector.
        // Keep track of how many turns we've added to the vector.
        Team prevTeam = null;
        int min = team_order.getMin();
        for (int numTurn = 0; team_order.hasMoreElements(); numTurn++) {
            Team team = (Team) team_order.nextElement();
            TurnVectors withinTeamTurns = allTeamTurns.get(team);

            int[] evenTracker = evenTrackers.get(team);
            float teamEvenTurns = team.getEvenTurns();

            // Calculate the number of "even" turns to add for this team.
            int numEven = 0;
            if (1 == numTeamsMoving) {
                // The only team moving should move all "even" units.
                numEven += teamEvenTurns;
            } else if (prevTeam == null) {
                // Increment the number of times we've checked for "leftovers".
                evenTracker[0]++;

                // The first team to move just adds the "baseline" turns.
                numEven += teamEvenTurns / min;
            } else if (!team.equals(prevTeam)) {
                // Increment the number of times we've checked for "leftovers".
                evenTracker[0]++;

                // This wierd equation attempts to spread the "leftover"
                // turns accross the turn's moves in a "fair" manner.
View Full Code Here


                    }
                }
            }
        } else {
            for (Enumeration<Team> i = game.getTeams(); i.hasMoreElements();) {
                final Team team = i.nextElement();

                // If there is only one player, list them as the 'team', and
                // use the team iniative
                if (team.getSize() == 1) {
                    final Player player = team.getPlayers().nextElement();
                    r = new Report(1015, Report.PUBLIC);
                    r.add(player.getName());
                    r.add(team.getInitiative().toString());
                    addReport(r);
                } else {
                    // Multiple players. List the team, then break it down.
                    r = new Report(1015, Report.PUBLIC);
                    r.add(Player.teamNames[team.getId()]);
                    r.add(team.getInitiative().toString());
                    addReport(r);
                    for (Enumeration<Player> j = team.getPlayers(); j.hasMoreElements();) {
                        final Player player = j.nextElement();
                        r = new Report(1015, Report.PUBLIC);
                        r.indent();
                        r.add(player.getName());
                        r.add(player.getInitiative().toString());
View Full Code Here

     *            The <code>Minefield</code> to be revealed
     */
    private void revealMinefield(Minefield mf) {
        Enumeration<Team> teams = game.getTeams();
        while (teams.hasMoreElements()) {
            Team team = teams.nextElement();
            revealMinefield(team, mf);
        }
    }
View Full Code Here

    private void checkForRevealMinefield(Minefield mf, Entity layer) {
        Enumeration<Team> teams = game.getTeams();
        //loop through each team and determine if they can see the mine, then loop through players on team
        //and reveal the mine
        while(teams.hasMoreElements()) {
            Team team = teams.nextElement();
            boolean canSee = false;

            //the players own team can always see the mine
            if(team.equals(game.getTeamForPlayer(game.getPlayer(mf.getPlayerId())))) {
                canSee = true;
            } else {
                //need to loop through all entities on this team and find the one with the best shot of seeing
                //the mine placement
                int target = Integer.MAX_VALUE;
                Enumeration<Entity> entities = game.getEntities();
                    while(entities.hasMoreElements()) {
                        Entity en = entities.nextElement();
                        //are we on the right team?
                        if(!team.equals(game.getTeamForPlayer(en.getOwner()))) {
                            continue;
                        }
                        if(LosEffects.calculateLos(game, en.getId(),
                                new HexTarget(mf.getCoords(), game.getBoard(), Targetable.TYPE_HEX_CLEAR)).canSee()) {
                            target = 0;
View Full Code Here

            int teamId = player.getTeam();

            if (teamId != Player.TEAM_NONE) {
                Enumeration<Team> teams = game.getTeams();
                while (teams.hasMoreElements()) {
                    Team team = teams.nextElement();
                    if (team.getId() == teamId) {
                        Enumeration<Player> players = team.getPlayers();
                        while (players.hasMoreElements()) {
                            Player teamPlayer = players.nextElement();
                            if (teamPlayer.getId() != player.getId()) {
                                send(teamPlayer.getId(), new Packet(Packet.COMMAND_DEPLOY_MINEFIELDS, minefields));
                            }
View Full Code Here

        Vector<Report> vFullReport = new Vector<Report>();
        vFullReport.add(new Report(5002, Report.PUBLIC));
        int damage_bonus = Math.max(0, game.getPlanetaryConditions().getWindStrength() - PlanetaryConditions.WI_MOD_GALE);
        //cycle through each team and damage 1d6 airborne VTOL/WIGE
        for (Enumeration<Team> loop = game.getTeams(); loop.hasMoreElements();) {
            Team team = loop.nextElement();
            Vector<Integer> airborne = team.getAirborneVTOL();
            if(airborne.size() > 0) {
                //how many units are affected
                int unitsAffected = Math.min(Compute.d6(), airborne.size());
                while((unitsAffected > 0) && (airborne.size() > 0)) {
                    int loc = Compute.randomInt(airborne.size());
View Full Code Here

TOP

Related Classes of megamek.common.Team

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.