[Megameknet-cvs] MegaMekNET/src/client ClientThread.java,1.15,1.16
Status: Inactive
Brought to you by:
mcwizard
From: Helge R. <mcw...@us...> - 2005-05-07 16:42:50
|
Update of /cvsroot/megameknet/MegaMekNET/src/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv995/src/client Modified Files: ClientThread.java Log Message: Made client capable of supporting latest megamek. One small thing is still missing.. Index: ClientThread.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/client/ClientThread.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ClientThread.java 26 Feb 2005 20:44:23 -0000 1.15 --- ClientThread.java 7 May 2005 16:42:40 -0000 1.16 *************** *** 20,34 **** import java.util.Vector; - import client.campaign.CUnit; - - import common.MegaMekPilotOption; - import common.PlanetEnvironment; - import common.Unit; - import megamek.client.Client; import megamek.client.ClientGUI; import megamek.client.CloseClientListener; - import megamek.client.GameEvent; - import megamek.client.GameListener; import megamek.common.BattleArmor; import megamek.common.CriticalSlot; --- 20,26 ---- *************** *** 39,49 **** import megamek.common.MechWarrior; import megamek.common.Pilot; - import megamek.common.PilotOptions; import megamek.common.Player; import megamek.common.Protomech; import megamek.common.QuadMech; import megamek.common.Tank; ! import megamek.common.options.GameOption; ! import megamek.common.options.OptionGroup; --- 31,63 ---- import megamek.common.MechWarrior; import megamek.common.Pilot; import megamek.common.Player; import megamek.common.Protomech; import megamek.common.QuadMech; import megamek.common.Tank; ! import megamek.common.event.GameAttackEvent; ! import megamek.common.event.GameBoardChangeEvent; ! import megamek.common.event.GameBoardNewEvent; ! import megamek.common.event.GameEndEvent; ! import megamek.common.event.GameEntityChangeEvent; ! import megamek.common.event.GameEntityNewEvent; ! import megamek.common.event.GameEntityNewOffboardEvent; ! import megamek.common.event.GameEntityRemoveEvent; ! import megamek.common.event.GameEvent; ! import megamek.common.event.GameListener; ! import megamek.common.event.GameMapQueryEvent; ! import megamek.common.event.GamePhaseChangeEvent; ! import megamek.common.event.GamePlayerChangeEvent; ! import megamek.common.event.GamePlayerChatEvent; ! import megamek.common.event.GamePlayerConnectedEvent; ! import megamek.common.event.GamePlayerDisconnectedEvent; ! import megamek.common.event.GameReportEvent; ! import megamek.common.event.GameSettingsChangeEvent; ! import megamek.common.event.GameTurnChangeEvent; ! import megamek.common.options.IOption; ! import client.campaign.CUnit; ! ! import common.MegaMekPilotOption; ! import common.PlanetEnvironment; ! import common.Unit; *************** *** 81,85 **** public void run() { client = new Client(myname, serverip, serverport); ! client.addGameListener(this); client.addCloseClientListener(this); ClientGUI gui = new ClientGUI(client); --- 95,99 ---- public void run() { client = new Client(myname, serverip, serverport); ! client.game.addGameListener(this); client.addCloseClientListener(this); ClientGUI gui = new ClientGUI(client); *************** *** 126,138 **** while (iter.hasNext()) { MegaMekPilotOption po = (MegaMekPilotOption) iter.next(); ! for (Enumeration enumeration = pilot.getOptions().groups(); enumeration.hasMoreElements();) { ! OptionGroup group = (OptionGroup) enumeration.nextElement(); ! if (!group.getKey().equalsIgnoreCase(PilotOptions.LVL3_ADVANTAGES)) continue; ! for (Enumeration j = group.options(); j.hasMoreElements();) { ! GameOption option = (GameOption) j.nextElement(); ! System.out.println("Checking: " + option.getShortName() + " with " + po.getMmname()); ! if (option.getShortName().equals(po.getMmname())) option.setValue(po.isValue()); - } } } --- 140,148 ---- while (iter.hasNext()) { MegaMekPilotOption po = (MegaMekPilotOption) iter.next(); ! for (Enumeration enumeration = pilot.getOptions().getOptions(); enumeration.hasMoreElements();) { ! IOption option = (IOption) enumeration.nextElement(); ! System.out.println("Checking: " + option.getName() + " with " + po.getMmname()); ! if (option.getName().equals(po.getMmname())) option.setValue(po.isValue()); } } *************** *** 177,192 **** } } - public void gamePlayerStatusChange(GameEvent e) { - } - - public void gameTurnChange(GameEvent e) { - System.out.println("gTC: " + e.getMessage()); - //This is called twice as often as it should be.. - if (client != null) { - if (client.game.getRoundCount() == 0) - myClient.setGameState("Running"); - myClient.setGameTurn(client.game.getTurnIndex()); - } - } public String serializeEntity (Entity e) { --- 187,190 ---- *************** *** 251,314 **** } ! public void gamePhaseChange(GameEvent e) { ! String result = ""; ! if (client.game.getPhase() == Game.PHASE_VICTORY) { ! //result += this.myTaskID + "#"; ! //Parse the real playername from the Modified In game one.. ! String winnerName = ""; ! if (client.game.getVictoryTeam() != 0) { ! //Multiple Winners ! Enumeration en = client.game.getPlayers(); ! while (en.hasMoreElements()) { ! Player p = (Player) en.nextElement(); ! if (p.getTeam() == client.game.getVictoryTeam()) { ! StringTokenizer st = new StringTokenizer(p.getName().trim(), "~"); ! String name = ""; ! while (st.hasMoreElements()) { ! name = st.nextToken().trim(); ! } ! winnerName += name + "*"; ! } ! } ! winnerName += "#"; ! } else { ! //Only one winner ! winnerName = client.game.getPlayer(client.game.getVictoryPlayerId()).getName(); ! StringTokenizer st = new StringTokenizer(winnerName, "~"); ! String name = ""; ! while (st.hasMoreElements()) { ! name = st.nextToken().trim(); ! } ! winnerName = name + "#"; ! } ! result += winnerName; ! //Report the mech stati ! Enumeration en = client.game.getDevastatedEntities(); ! while (en.hasMoreElements()) { ! megamek.common.Entity ent = (Entity) en.nextElement(); ! result += this.serializeEntity(ent) + "#"; ! } ! en = client.game.getGraveyardEntities(); ! while (en.hasMoreElements()) { ! megamek.common.Entity ent = (Entity) en.nextElement(); ! result += this.serializeEntity(ent) + "#"; ! } ! en = client.game.getEntities(); ! while (en.hasMoreElements()) { ! megamek.common.Entity ent = (Entity) en.nextElement(); ! result += this.serializeEntity(ent) + "#"; ! } ! en = client.game.getRetreatedEntities(); ! while (en.hasMoreElements()) { ! megamek.common.Entity ent = (Entity) en.nextElement(); ! result += this.serializeEntity(ent) + "#"; ! } ! System.out.println("CR|" + result); ! myClient.serverSend("CR|" + result); ! System.out.println("GAME END"); ! } ! } ! ! public void gamePlayerChat(GameEvent e) { } --- 249,253 ---- } ! public void gamePlayerChat(GameEvent e) { } *************** *** 340,342 **** --- 279,478 ---- myClient.closingGame(gameid); } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gamePlayerConnected(megamek.common.event.GamePlayerConnectedEvent) + */ + public void gamePlayerConnected(GamePlayerConnectedEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gamePlayerDisconnected(megamek.common.event.GamePlayerDisconnectedEvent) + */ + public void gamePlayerDisconnected(GamePlayerDisconnectedEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gamePlayerChange(megamek.common.event.GamePlayerChangeEvent) + */ + public void gamePlayerChange(GamePlayerChangeEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gamePlayerChat(megamek.common.event.GamePlayerChatEvent) + */ + public void gamePlayerChat(GamePlayerChatEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameTurnChange(megamek.common.event.GameTurnChangeEvent) + */ + public void gameTurnChange(GameTurnChangeEvent e) { + //System.out.println("gTC: " + e.getMessage()); + //This is called twice as often as it should be.. + if (client != null) { + if (client.game.getRoundCount() == 0) + myClient.setGameState("Running"); + myClient.setGameTurn(client.game.getTurnIndex()); + } + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gamePhaseChange(megamek.common.event.GamePhaseChangeEvent) + */ + public void gamePhaseChange(GamePhaseChangeEvent e) { + String result = ""; + if (client.game.getPhase() == Game.PHASE_VICTORY) { + //result += this.myTaskID + "#"; + //Parse the real playername from the Modified In game one.. + String winnerName = ""; + if (client.game.getVictoryTeam() != 0) { + //Multiple Winners + Enumeration en = client.game.getPlayers(); + while (en.hasMoreElements()) { + Player p = (Player) en.nextElement(); + if (p.getTeam() == client.game.getVictoryTeam()) { + StringTokenizer st = new StringTokenizer(p.getName().trim(), "~"); + String name = ""; + while (st.hasMoreElements()) { + name = st.nextToken().trim(); + } + winnerName += name + "*"; + } + } + winnerName += "#"; + } else { + //Only one winner + winnerName = client.game.getPlayer(client.game.getVictoryPlayerId()).getName(); + StringTokenizer st = new StringTokenizer(winnerName, "~"); + String name = ""; + while (st.hasMoreElements()) { + name = st.nextToken().trim(); + } + winnerName = name + "#"; + } + result += winnerName; + //Report the mech stati + Enumeration en = client.game.getDevastatedEntities(); + while (en.hasMoreElements()) { + megamek.common.Entity ent = (Entity) en.nextElement(); + result += this.serializeEntity(ent) + "#"; + } + en = client.game.getGraveyardEntities(); + while (en.hasMoreElements()) { + megamek.common.Entity ent = (Entity) en.nextElement(); + result += this.serializeEntity(ent) + "#"; + } + en = client.game.getEntities(); + while (en.hasMoreElements()) { + megamek.common.Entity ent = (Entity) en.nextElement(); + result += this.serializeEntity(ent) + "#"; + } + en = client.game.getRetreatedEntities(); + while (en.hasMoreElements()) { + megamek.common.Entity ent = (Entity) en.nextElement(); + result += this.serializeEntity(ent) + "#"; + } + System.out.println("CR|" + result); + myClient.serverSend("CR|" + result); + System.out.println("GAME END"); + } + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameReport(megamek.common.event.GameReportEvent) + */ + public void gameReport(GameReportEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameEnd(megamek.common.event.GameEndEvent) + */ + public void gameEnd(GameEndEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameBoardNew(megamek.common.event.GameBoardNewEvent) + */ + public void gameBoardNew(GameBoardNewEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameBoardChanged(megamek.common.event.GameBoardChangeEvent) + */ + public void gameBoardChanged(GameBoardChangeEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameSettingsChange(megamek.common.event.GameSettingsChangeEvent) + */ + public void gameSettingsChange(GameSettingsChangeEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameMapQuery(megamek.common.event.GameMapQueryEvent) + */ + public void gameMapQuery(GameMapQueryEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameEntityNew(megamek.common.event.GameEntityNewEvent) + */ + public void gameEntityNew(GameEntityNewEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameEntityNewOffboard(megamek.common.event.GameEntityNewOffboardEvent) + */ + public void gameEntityNewOffboard(GameEntityNewOffboardEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameEntityRemove(megamek.common.event.GameEntityRemoveEvent) + */ + public void gameEntityRemove(GameEntityRemoveEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameEntityChange(megamek.common.event.GameEntityChangeEvent) + */ + public void gameEntityChange(GameEntityChangeEvent e) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see megamek.common.event.GameListener#gameAttack(megamek.common.event.GameAttackEvent) + */ + public void gameAttack(GameAttackEvent e) { + // TODO Auto-generated method stub + + } } \ No newline at end of file |