📄 igame.java
字号:
/* * MegaMek - Copyright (C) 2005 Ben Mazur (bmazur@sev.org) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */package megamek.common;import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector;import megamek.common.actions.ArtilleryAttackAction;import megamek.common.actions.AttackAction;import megamek.common.actions.EntityAction;import megamek.common.actions.LayMinefieldAction;import megamek.common.event.GameEvent;import megamek.common.event.GameListener;import megamek.common.options.GameOptions;import megamek.common.TagInfo;/** * This interface is the root of all data about the game in progress. * Both the Client and the Server should have one of these objects and it * is their job to keep it synched. */public interface IGame { public static final int PHASE_UNKNOWN = -1; public static final int PHASE_LOUNGE = 1; public static final int PHASE_SELECTION = 2; public static final int PHASE_EXCHANGE = 3; public static final int PHASE_DEPLOYMENT = 4; public static final int PHASE_INITIATIVE = 5; public static final int PHASE_INITIATIVE_REPORT = 6; public static final int PHASE_TARGETING = 7; public static final int PHASE_MOVEMENT = 8; public static final int PHASE_MOVEMENT_REPORT = 9; public static final int PHASE_OFFBOARD = 10; public static final int PHASE_OFFBOARD_REPORT = 11; public static final int PHASE_FIRING = 12; public static final int PHASE_FIRING_REPORT = 13; public static final int PHASE_PHYSICAL = 14; public static final int PHASE_PHYSICAL_REPORT = 15; public static final int PHASE_END = 16; public static final int PHASE_END_REPORT = 17; public static final int PHASE_VICTORY = 18; //public static final int PHASE_VICTORY_REPORT = 19; public static final int PHASE_DEPLOY_MINEFIELDS = 20; public static final int PHASE_STARTING_SCENARIO = 21; public static final int PHASE_SET_ARTYAUTOHITHEXES = 22; /** * Adds the specified game listener to receive * board events from this Game. * * @param listener the game listener. */ public abstract void addGameListener(GameListener listener); /** * Removes the specified game listener. * * @param listener the game listener. */ public abstract void removeGameListener(GameListener listener); /** * Processes game events by dispatching them to any registered * GameListener objects. * * @param event the game event. */ public abstract void processGameEvent(GameEvent event); /** * Check if there is a minefield at given coords * @param coords coords to check * @return <code>true</code> if there is a minefield at given coords * or <code>false</code> otherwise */ public abstract boolean containsMinefield(Coords coords); /** * Get the minefields at specified coords * @param coords * @return the <code>Vector</code> of minefields at specified coord */ public abstract Vector getMinefields(Coords coords); /** * Get the number of the minefields at specified coords * @param coords * @return the number of the minefields at specified coord */ public abstract int getNbrMinefields(Coords coords); /** * Get the coordinates of all mined hexes in the game. * * @return an <code>Enumeration</code> of the <code>Coords</code> * containing minefilds. This will not be <code>null</code>. */ public abstract Enumeration getMinedCoords(); /** * Addds the specified minefield * @param mf minefield to add */ public abstract void addMinefield(Minefield mf); /** * Adds a number of minefields * @param minefields the <code>Vector</code> of the minefields to add */ public abstract void addMinefields(Vector minefields); /** * Sets the minefields to the given <code>Vector</code> of the minefields * @param minefields */ public abstract void setMinefields(Vector minefields); /** * Removes the specified minefield * @param mf minefield to remove */ public abstract void removeMinefield(Minefield mf); /** * Removes all minefields * */ public abstract void clearMinefields(); /** * * @return the <code>Vector</code> of the vibrabombs */ public abstract Vector getVibrabombs(); /** * Addds the specified vibrabomb * @param mf Vibrabomb to add */ public abstract void addVibrabomb(Minefield mf); /** * Removes the specified Vibrabomb * @param mf Vibrabomb to remove */ public abstract void removeVibrabomb(Minefield mf); /** * Checks if the game contains the specified Vibrabomb * @param mf the Vibrabomb to ceck * @return */ public abstract boolean containsVibrabomb(Minefield mf); /** * * @return game options */ public abstract GameOptions getOptions(); /** * sets the game options * @param options */ public abstract void setOptions(GameOptions options); /** * * @return the game board */ public abstract IBoard getBoard(); /** * Sets the new game board * @param board */ public abstract void setBoard(IBoard board); /** * Return an enumeration of teams in the game */ public abstract Enumeration getTeams(); /** * Return the current number of teams in the game. */ public abstract int getNoOfTeams(); /** * Return the immutable vector of teams */ public abstract Vector getTeamsVector(); /** * Return a players team * Note: may return null if player has no team */ public abstract Team getTeamForPlayer(Player p); /** Set up the teams vector. Each player on a team (Team 1 .. Team X) is placed in the appropriate vector. Any player on 'No Team', is placed in their own object */ public abstract void setupTeams(); /** * Return an enumeration of player in the game */ public abstract Enumeration getPlayers(); /** * Return the players vector */ public abstract Vector getPlayersVector(); /** * Return the current number of active players in the game. */ public abstract int getNoOfPlayers(); /** * Returns the individual player assigned the id parameter. */ public abstract Player getPlayer(int id); public abstract void addPlayer(int id, Player player); public abstract void setPlayer(int id, Player player); public abstract void removePlayer(int id); /** * Returns the number of entities owned by the player, regardless of * their status, as long as they are in the game. */ public abstract int getEntitiesOwnedBy(Player player); /** * Returns the number of entities owned by the player, regardless of * their status. */ public abstract int getAllEntitiesOwnedBy(Player player); /** * Returns the number of non-destroyed entityes owned by the player */ public abstract int getLiveEntitiesOwnedBy(Player player); /** * Returns the number of non-destroyed deployed entities owned * by the player. Ignore offboard units and captured Mek pilots. */ public abstract int getLiveDeployedEntitiesOwnedBy(Player player); /** * Returns true if the player has a valid unit with the Tactical Genius * pilot special ability. */ public abstract boolean hasTacticalGenius(Player player); /** * Returns how much higher than 50 or lower than -30 * degrees, divided by ten, rounded up, the temperature is */ public abstract int getTemperatureDifference(); /** * Get a vector of entity objects that are "acceptable" to attack with this entity */ public abstract Vector getValidTargets(Entity entity); /** * Returns true if this phase has turns. If false, the phase is simply * waiting for everybody to declare "done". */ public abstract boolean phaseHasTurns(int phase); /** * Returns the current GameTurn object */ public abstract GameTurn getTurn(); /** * Changes to the next turn, returning it. */ public abstract GameTurn changeToNextTurn(); /** * Resets the turn index to -1 (awaiting first turn) */ public abstract void resetTurnIndex(); /** * Returns true if there is a turn after the current one */ public abstract boolean hasMoreTurns(); /** * Inserts a turn that will come directly after the current one */ public abstract void insertNextTurn(GameTurn turn); /** * Returns an Enumeration of the current turn list */ public abstract Enumeration getTurns(); /** * Returns the current turn index */ public abstract int getTurnIndex(); /** * Sets the current turn index */ public abstract void setTurnIndex(int turnIndex); /** * Returns the current turn vector */ public abstract Vector getTurnVector(); /** * Sets the current turn vector */ public abstract void setTurnVector(Vector turnVector); public abstract int getPhase(); public abstract void setPhase(int phase); public abstract int getLastPhase(); public abstract void setLastPhase(int lastPhase); public abstract void setDeploymentComplete(boolean deploymentComplete); public abstract boolean isDeploymentComplete();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -