From: <dr...@us...> - 2006-11-03 02:47:02
|
Revision: 2586 http://svn.sourceforge.net/colossus/?rev=2586&view=rev Author: dripton Date: 2006-11-02 18:46:57 -0800 (Thu, 02 Nov 2006) Log Message: ----------- Delete AiCreatureInfo. Too much busywork code for too little effect. Based on Adam Berger's patch for bug 1588383. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SimpleAI.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Creature.java Removed Paths: ------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AiCreatureInfo.java Deleted: trunk/Colossus/core/src/main/java/net/sf/colossus/client/AiCreatureInfo.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AiCreatureInfo.java 2006-11-03 02:18:54 UTC (rev 2585) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/AiCreatureInfo.java 2006-11-03 02:46:57 UTC (rev 2586) @@ -1,48 +0,0 @@ -package net.sf.colossus.client; - -import net.sf.colossus.server.Creature; - - -// the AI wants to save some useful information along with -// each creature. i thought about extending the Creature class -// by a aiData field, but we can have multiple AIs in a game. -// so the data must be stored in the AI instance itself. -// there is a 1:1 map from each Creature instance to AiCreatureInfo. - -/** - * TODO: this class breaks a few rules of good design: overriding hashCode() without - * overriding equals(), extensive use of package-private access, odd declaration of - * final methods and funny naming (what does the "1" behind "killValue" mean?). - */ -class AiCreatureInfo -{ - /** - * @param killValue1 - the non-terrainified killValue. - */ - AiCreatureInfo(final Creature creature) - { - this.creature = creature; - this.killValue1 = creature.getKillValue(); - } - - /** only internal book keeping for now. - * wanna make it readable? go ahead. */ - private final Creature creature; - - /** is the same if creature is the same */ - public int hashCode() - { - return creature.hashCode(); - } - - /** killvalue without terrain */ - private int killValue1; - final int getKillValue1() - { - return killValue1; - } - final void setKillValue1(final int v) - { - this.killValue1 = v; - } -} Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SimpleAI.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SimpleAI.java 2006-11-03 02:18:54 UTC (rev 2585) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SimpleAI.java 2006-11-03 02:46:57 UTC (rev 2586) @@ -30,22 +30,6 @@ Random random = new DevRandom(); String[] hintSectionUsed = { Constants.sectionOffensiveAI }; - static HashMap aiCreatureInfos; - - static - { - final List allCreatures = Creature.getCreatures(); - aiCreatureInfos = new HashMap(allCreatures.size()); - Iterator it = allCreatures.iterator(); - while (it.hasNext()) - { - final Creature creature = (Creature)it.next(); - AiCreatureInfo info = new AiCreatureInfo(creature); - aiCreatureInfos.put(creature, info); - } - } - - public SimpleAI(Client client) { this.client = client; @@ -2438,18 +2422,7 @@ return 0; } // get non-terrain modified part of kill value - if (creature.canChangeValue() || aiCreatureInfos == null) - { - // titans might change their value - val = creature.getKillValue(); - } - else - { - // use from pre-calced cache - final AiCreatureInfo info = - (AiCreatureInfo)aiCreatureInfos.get(creature); - val = info.getKillValue1(); - } + val = creature.getKillValue(); // modify with terrain if (terrain != null && MasterHex.isNativeCombatBonus(creature, terrain)) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Creature.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Creature.java 2006-11-03 02:18:54 UTC (rev 2585) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Creature.java 2006-11-03 02:46:57 UTC (rev 2586) @@ -590,14 +590,7 @@ } } - /** get the non-terrainified part of the kill-value. - * - * towi: Note that you have to take special care for creatures that - * might change their attributes -- like the Power of titans. - * since this modifies the return value. - * on the other hand... since titans have a killValue>1000 anyway, - * this might not matter at all. - */ + /** get the non-terrainified part of the kill-value. */ public int getKillValue() { int val = 10 * getPointValue(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ad...@us...> - 2006-11-07 04:19:58
|
Revision: 2594 http://svn.sourceforge.net/colossus/?rev=2594&view=rev Author: addaon Date: 2006-11-06 20:19:52 -0800 (Mon, 06 Nov 2006) Log Message: ----------- As discussed on the mailing list. This patch is intended simply to always act on Phases and BattlePhases as members of the appropriate type. Because the values of these type are all constants, I've left the new types as subclasses of Constants. Also because the values are all constants, the == comparison operator is both legal and recommended. There should be no user-visible change as the result of this pack. In particular, 1590644 is still not fixed. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleMap.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/Strike.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Battle.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleMap.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleMap.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleMap.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -138,7 +138,7 @@ { return; } - if (client.getBattlePhase() == Constants.MOVE) + if (client.getBattlePhase() == Constants.BattlePhase.MOVE) { selectedCritterTag = -1; client.undoLastBattleMove(); @@ -156,7 +156,7 @@ { return; } - if (client.getBattlePhase() == Constants.MOVE) + if (client.getBattlePhase() == Constants.BattlePhase.MOVE) { selectedCritterTag = -1; client.undoAllBattleMoves(); @@ -175,27 +175,25 @@ return; } - int phase = client.getBattlePhase(); - switch (phase) + Constants.BattlePhase phase = client.getBattlePhase(); + if (phase == Constants.BattlePhase.MOVE) { - case Constants.MOVE: - if (!client.getOption(Options.autoPlay) && - client.anyOffboardCreatures() && - !confirmLeavingCreaturesOffboard()) - { - return; - } - client.doneWithBattleMoves(); - break; - - case Constants.FIGHT: - case Constants.STRIKEBACK: - client.doneWithStrikes(); - break; - - default: - Log.error("Bogus phase"); + if (!client.getOption(Options.autoPlay) && + client.anyOffboardCreatures() && + !confirmLeavingCreaturesOffboard()) + { + return; + } + client.doneWithBattleMoves(); } + else if (phase.isFightPhase()) + { + client.doneWithStrikes(); + } + else + { + Log.error("Bogus phase"); + } } }; @@ -509,71 +507,54 @@ // XXX Put selected chit at the top of the z-order. // Then getGUIHexByLabel(hexLabel).repaint(); - - switch (client.getBattlePhase()) + Constants.BattlePhase phase = client.getBattlePhase(); + if (phase == Constants.BattlePhase.MOVE) { - case Constants.MOVE: - // Highlight all legal destinations for this critter. - highlightMoves(tag); - break; - - case Constants.FIGHT: - case Constants.STRIKEBACK: - client.leaveCarryMode(); - highlightStrikes(tag); - break; - - default: - break; + highlightMoves(tag); } + else if (phase.isFightPhase()) + { + client.leaveCarryMode(); + highlightStrikes(tag); + } } private void actOnHex(String hexLabel) { - switch (client.getBattlePhase()) + Constants.BattlePhase phase = client.getBattlePhase(); + if (phase == Constants.BattlePhase.MOVE) { - case Constants.MOVE: - if (selectedCritterTag != -1) - { - client.doBattleMove(selectedCritterTag, hexLabel); - selectedCritterTag = -1; - highlightMobileCritters(); - } - break; - - case Constants.FIGHT: - case Constants.STRIKEBACK: - if (selectedCritterTag != -1) - { - client.strike(selectedCritterTag, hexLabel); - selectedCritterTag = -1; - } - break; - - default: - break; + if (selectedCritterTag != -1) + { + client.doBattleMove(selectedCritterTag, hexLabel); + selectedCritterTag = -1; + highlightMobileCritters(); + } } + else if (phase.isFightPhase()) + { + if (selectedCritterTag != -1) + { + client.strike(selectedCritterTag, hexLabel); + selectedCritterTag = -1; + } + } } private void actOnMisclick() { - switch (client.getBattlePhase()) + Constants.BattlePhase phase = client.getBattlePhase(); + if (phase == Constants.BattlePhase.MOVE) { - case Constants.MOVE: - selectedCritterTag = -1; - highlightMobileCritters(); - break; - - case Constants.FIGHT: - case Constants.STRIKEBACK: - selectedCritterTag = -1; - client.leaveCarryMode(); - highlightCrittersWithTargets(); - break; - - default: - break; + selectedCritterTag = -1; + highlightMobileCritters(); } + else if (phase.isFightPhase()) + { + selectedCritterTag = -1; + client.leaveCarryMode(); + highlightCrittersWithTargets(); + } } public void mousePressed(MouseEvent e) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -110,11 +110,11 @@ private int turnNumber = -1; private String activePlayerName = ""; - private int phase = -1; + private Constants.Phase phase; private int battleTurnNumber = -1; private String battleActivePlayerName = null; - private int battlePhase = -1; + private Constants.BattlePhase battlePhase; private String attackerMarkerId = "none"; private String defenderMarkerId = "none"; @@ -1986,7 +1986,7 @@ } public void initBattle(String masterHexLabel, int battleTurnNumber, - String battleActivePlayerName, int battlePhase, + String battleActivePlayerName, Constants.BattlePhase battlePhase, String attackerMarkerId, String defenderMarkerId) { cleanupNegotiationDialogs(); @@ -2023,7 +2023,7 @@ map = null; } battleChits.clear(); - battlePhase = -1; + battlePhase = null; battleTurnNumber = -1; battleActivePlayerName = null; } @@ -2270,7 +2270,7 @@ this.activePlayerName = activePlayerName; this.turnNumber = turnNumber; - this.phase = Constants.SPLIT; + this.phase = Constants.Phase.SPLIT; numSplitsThisTurn = 0; @@ -2315,7 +2315,7 @@ public void setupMove() { - this.phase = Constants.MOVE; + this.phase = Constants.Phase.MOVE; clearUndoStack(); if (board != null) { @@ -2331,7 +2331,7 @@ public void setupFight() { clearUndoStack(); - this.phase = Constants.FIGHT; + this.phase = Constants.Phase.FIGHT; if (board != null) { board.setupFightMenu(); @@ -2361,7 +2361,7 @@ clearUndoStack(); cleanupNegotiationDialogs(); - this.phase = Constants.MUSTER; + this.phase = Constants.Phase.MUSTER; if (board != null) { @@ -2394,7 +2394,7 @@ public void setupBattleSummon(String battleActivePlayerName, int battleTurnNumber) { - this.battlePhase = Constants.SUMMON; + this.battlePhase = Constants.BattlePhase.SUMMON; setBattleActivePlayerName(battleActivePlayerName); this.battleTurnNumber = battleTurnNumber; @@ -2417,7 +2417,7 @@ public void setupBattleRecruit(String battleActivePlayerName, int battleTurnNumber) { - this.battlePhase = Constants.RECRUIT; + this.battlePhase = Constants.BattlePhase.RECRUIT; setBattleActivePlayerName(battleActivePlayerName); this.battleTurnNumber = battleTurnNumber; @@ -2453,7 +2453,7 @@ // really quickly. cleanupNegotiationDialogs(); resetAllBattleMoves(); - this.battlePhase = Constants.MOVE; + this.battlePhase = Constants.BattlePhase.MOVE; if (map != null && isMyBattlePhase()) { focusMap(); @@ -2507,12 +2507,12 @@ } /** Used for both strike and strikeback. */ - public void setupBattleFight(int battlePhase, + public void setupBattleFight(Constants.BattlePhase battlePhase, String battleActivePlayerName) { this.battlePhase = battlePhase; setBattleActivePlayerName(battleActivePlayerName); - if (battlePhase == Constants.FIGHT) + if (battlePhase == Constants.BattlePhase.FIGHT) { markOffboardCreaturesDead(); } @@ -2636,7 +2636,7 @@ return attackerMarkerId; } - int getBattlePhase() + Constants.BattlePhase getBattlePhase() { return battlePhase; } @@ -2644,10 +2644,12 @@ // public for IOracle public String getBattlePhaseName() { - if (phase == Constants.FIGHT && battlePhase >= Constants.SUMMON && - battlePhase <= Constants.STRIKEBACK) + if (phase == Constants.Phase.FIGHT) { - return Constants.getBattlePhaseName(battlePhase); + if (battlePhase != null) + { + return battlePhase.toString(); + } } return ""; } @@ -2892,7 +2894,7 @@ return activePlayerName; } - int getPhase() + Constants.Phase getPhase() { return phase; } @@ -2900,7 +2902,11 @@ // public for IOracle public String getPhaseName() { - return Constants.getPhaseName(getPhase()); + if (phase != null) + { + return phase.toString(); + } + return ""; } // public for IOracle Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -4,7 +4,9 @@ import java.util.List; import java.util.Set; +import net.sf.colossus.server.Constants; + /** * IClient is a remote interface for the client-accessible parts of Client. * @version $Id$ @@ -77,7 +79,7 @@ boolean wasCarry, int carryDamageLeft, Set carryTargetDescriptions); public void initBattle(String masterHexLabel, int battleTurnNumber, - String battleActivePlayerName, int battlePhase, + String battleActivePlayerName, Constants.BattlePhase battlePhase, String attackerMarkerId, String defenderMarkerId); public void cleanupBattle(); @@ -110,7 +112,7 @@ public void setupBattleMove(String battleActivePlayerName, int battleTurnNumber); - public void setupBattleFight(int battlePhase, + public void setupBattleFight(Constants.BattlePhase battlePhase, String battleActivePlayerName); public void tellLegionLocation(String markerId, String hexLabel); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -374,33 +374,32 @@ { public void actionPerformed(ActionEvent e) { - int phase = client.getPhase(); - switch (phase) + Constants.Phase phase = client.getPhase(); + if (phase == Constants.Phase.SPLIT) { - case Constants.SPLIT: - client.undoLastSplit(); - alignAllLegions(); - highlightTallLegions(); - repaint(); - break; - - case Constants.MOVE: - client.undoLastMove(); - highlightUnmovedLegions(); - break; - - case Constants.FIGHT: - Log.error("called undoLastAction in FIGHT"); - break; - - case Constants.MUSTER: - client.undoLastRecruit(); - highlightPossibleRecruits(); - break; - - default: - Log.error("Bogus phase"); + client.undoLastSplit(); + alignAllLegions(); + highlightTallLegions(); + repaint(); } + else if (phase == Constants.Phase.MOVE) + { + client.undoLastMove(); + highlightUnmovedLegions(); + } + else if (phase == Constants.Phase.FIGHT) + { + Log.error("called undoLastAction in FIGHT"); + } + else if (phase == Constants.Phase.MUSTER) + { + client.undoLastRecruit(); + highlightPossibleRecruits(); + } + else + { + Log.error("Bogus phase"); + } } }; @@ -408,33 +407,32 @@ { public void actionPerformed(ActionEvent e) { - int phase = client.getPhase(); - switch (phase) + Constants.Phase phase = client.getPhase(); + if (phase == Constants.Phase.SPLIT) { - case Constants.SPLIT: - client.undoAllSplits(); - alignAllLegions(); - highlightTallLegions(); - repaint(); - break; - - case Constants.MOVE: - client.undoAllMoves(); - highlightUnmovedLegions(); - break; - - case Constants.FIGHT: - Log.error("called undoAllAction in FIGHT"); - break; - - case Constants.MUSTER: - client.undoAllRecruits(); - highlightPossibleRecruits(); - break; - - default: - Log.error("Bogus phase"); + client.undoAllSplits(); + alignAllLegions(); + highlightTallLegions(); + repaint(); } + else if (phase == Constants.Phase.MOVE) + { + client.undoAllMoves(); + highlightUnmovedLegions(); + } + else if (phase == Constants.Phase.FIGHT) + { + Log.error("called undoAllAction in FIGHT"); + } + else if (phase == Constants.Phase.MUSTER) + { + client.undoAllRecruits(); + highlightPossibleRecruits(); + } + else + { + Log.error("Bogus phase"); + } } }; @@ -442,32 +440,31 @@ { public void actionPerformed(ActionEvent e) { - int phase = client.getPhase(); - switch (phase) + Constants.Phase phase = client.getPhase(); + if (phase == Constants.Phase.SPLIT) { - case Constants.SPLIT: - bottomBar.disableDoneButton(); - client.doneWithSplits(); - break; - - case Constants.MOVE: - bottomBar.disableDoneButton(); - client.doneWithMoves(); - break; - - case Constants.FIGHT: - bottomBar.disableDoneButton(); - client.doneWithEngagements(); - break; - - case Constants.MUSTER: - bottomBar.disableDoneButton(); - client.doneWithRecruits(); - break; - - default: - Log.error("Bogus phase"); + bottomBar.disableDoneButton(); + client.doneWithSplits(); } + else if (phase == Constants.Phase.MOVE) + { + bottomBar.disableDoneButton(); + client.doneWithMoves(); + } + else if (phase == Constants.Phase.FIGHT) + { + bottomBar.disableDoneButton(); + client.doneWithEngagements(); + } + else if (phase == Constants.Phase.MUSTER) + { + bottomBar.disableDoneButton(); + client.doneWithRecruits(); + } + else + { + Log.error("Bogus phase"); + } } }; @@ -1943,38 +1940,34 @@ void actOnMisclick() { - switch (client.getPhase()) + Constants.Phase phase = client.getPhase(); + if (phase == Constants.Phase.SPLIT) { - case Constants.SPLIT: - highlightTallLegions(); - break; - - case Constants.MOVE: - client.clearRecruitChits(); - client.setMoverId(null); - highlightUnmovedLegions(); - break; - - case Constants.FIGHT: - SummonAngel summonAngel = client.getSummonAngel(); - if (summonAngel != null) - { - highlightSummonableAngels(summonAngel.getMarkerId()); - summonAngel.repaint(); - } - else - { - highlightEngagements(); - } - break; - - case Constants.MUSTER: - highlightPossibleRecruits(); - break; - - default: - break; + highlightTallLegions(); } + else if (phase == Constants.Phase.MOVE) + { + client.clearRecruitChits(); + client.setMoverId(null); + highlightUnmovedLegions(); + } + else if (phase == Constants.Phase.FIGHT) + { + SummonAngel summonAngel = client.getSummonAngel(); + if (summonAngel != null) + { + highlightSummonableAngels(summonAngel.getMarkerId()); + summonAngel.repaint(); + } + else + { + highlightEngagements(); + } + } + else if (phase == Constants.Phase.MUSTER) + { + highlightPossibleRecruits(); + } } /** Return true if the MouseEvent e came from button 2 or 3. @@ -2080,62 +2073,58 @@ { return; } - switch (client.getPhase()) - { - case Constants.SPLIT: - client.doSplit(markerId); - break; - case Constants.MOVE: - // Allow spin cycle by clicking on chit again. - if (markerId.equals(client.getMoverId())) - { - actOnHex(hexLabel); - } - else - { - client.setMoverId(markerId); - getGUIHexByLabel(hexLabel).repaint(); - highlightMoves(markerId); - } - break; - - case Constants.FIGHT: - client.doFight(hexLabel); - break; - - case Constants.MUSTER: - client.doRecruit(markerId); - break; + Constants.Phase phase = client.getPhase(); + if (phase == Constants.Phase.SPLIT) + { + client.doSplit(markerId); } + else if (phase == Constants.Phase.MOVE) + { + // Allow spin cycle by clicking on chit again. + if (markerId.equals(client.getMoverId())) + { + actOnHex(hexLabel); + } + else + { + client.setMoverId(markerId); + getGUIHexByLabel(hexLabel).repaint(); + highlightMoves(markerId); + } + } + else if (phase == Constants.Phase.FIGHT) + { + client.doFight(hexLabel); + } + else if (phase == Constants.Phase.MUSTER) + { + client.doRecruit(markerId); + } } private void actOnHex(String hexLabel) { - switch (client.getPhase()) + Constants.Phase phase = client.getPhase(); + if (phase == Constants.Phase.SPLIT) { - case Constants.SPLIT: - highlightTallLegions(); - break; - + highlightTallLegions(); + } + else if (phase == Constants.Phase.MOVE) + { // If we're moving, and have selected a legion which // has not yet moved, and this hex is a legal // destination, move the legion here. - case Constants.MOVE: - client.clearRecruitChits(); - client.doMove(hexLabel); - actOnMisclick(); // Yes, even if the move was good. - break; - + client.clearRecruitChits(); + client.doMove(hexLabel); + actOnMisclick(); // Yes, even if the move was good. + } + else if (phase == Constants.Phase.FIGHT) + { // If we're fighting and there is an engagement here, // resolve it. If an angel is being summoned, mark // the donor legion instead. - case Constants.FIGHT: - client.engage(hexLabel); - break; - - default: - break; + client.engage(hexLabel); } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -283,7 +283,8 @@ String masterHexLabel = (String)args.remove(0); int battleTurnNumber = Integer.parseInt((String)args.remove(0)); String battleActivePlayerName = (String)args.remove(0); - int battlePhase = Integer.parseInt((String)args.remove(0)); + Constants.BattlePhase battlePhase = Constants.BattlePhase.fromInt( + Integer.parseInt((String)args.remove(0))); String attackerMarkerId = (String)args.remove(0); String defenderMarkerId = (String)args.remove(0); client.initBattle(masterHexLabel, battleTurnNumber, @@ -364,7 +365,8 @@ } else if (method.equals(Constants.setupBattleFight)) { - int battlePhase = Integer.parseInt((String)args.remove(0)); + Constants.BattlePhase battlePhase = Constants.BattlePhase.fromInt( + Integer.parseInt((String)args.remove(0))); String battleActivePlayerName = (String)args.remove(0); client.setupBattleFight(battlePhase, battleActivePlayerName); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Strike.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Strike.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Strike.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -60,8 +60,7 @@ * Returns true if a strike was made. */ boolean makeForcedStrikes(boolean rangestrike) { - if (client.getBattlePhase() != Constants.FIGHT && - client.getBattlePhase() != Constants.STRIKEBACK && + if (!client.getBattlePhase().isFightPhase() && !client.isMyBattlePhase()) { Log.error("Called Strike.makeForcedStrikes() in wrong phase"); @@ -151,7 +150,7 @@ // if the creature can strike normally, so only look for them if // no targets have yet been found. if (rangestrike && !adjacentEnemy && creature.isRangestriker() && - client.getBattlePhase() != Constants.STRIKEBACK) + client.getBattlePhase() != Constants.BattlePhase.STRIKEBACK) { Iterator it = client.getInactiveBattleChits().iterator(); while (it.hasNext()) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Battle.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Battle.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Battle.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -33,7 +33,7 @@ private String masterHexLabel; private String terrain; private int turnNumber; - private int phase; + private Constants.BattlePhase phase; private int summonState = Constants.NO_KILLS; private int carryDamage; private boolean attackerElim; @@ -50,7 +50,7 @@ Battle(Game game, String attackerId, String defenderId, int activeLegionNum, String masterHexLabel, - int turnNumber, int phase) + int turnNumber, Constants.BattlePhase phase) { this.game = game; server = game.getServer(); @@ -143,28 +143,27 @@ initBattleChits(getDefender()); boolean advance = false; - switch (getPhase()) + Constants.BattlePhase phase = getBattlePhase(); + if (phase == Constants.BattlePhase.SUMMON) { - case Constants.SUMMON: - advance = setupSummon(); - break; - - case Constants.RECRUIT: - advance = setupRecruit(); - break; - - case Constants.MOVE: - advance = setupMove(); - break; - - case Constants.FIGHT: - case Constants.STRIKEBACK: - advance = setupFight(); - break; - - default: - Log.error("Bogus phase"); + advance = setupSummon(); } + else if (phase == Constants.BattlePhase.RECRUIT) + { + advance = setupRecruit(); + } + else if (phase == Constants.BattlePhase.MOVE) + { + advance = setupMove(); + } + else if (phase.isFightPhase()) + { + advance = setupFight(); + } + else + { + Log.error("Bogus phase"); + } if (advance) { advancePhase(); @@ -268,7 +267,7 @@ return terrain; } - int getPhase() + Constants.BattlePhase getBattlePhase() { return phase; } @@ -303,23 +302,21 @@ public void advancePhaseInternal() { - if (phase == Constants.SUMMON) + if (phase == Constants.BattlePhase.SUMMON) { - phase = Constants.MOVE; - Log.event("Battle phase advances to " + - Constants.getBattlePhaseName(phase)); + phase = Constants.BattlePhase.MOVE; + Log.event("Battle phase advances to " + phase); again = setupMove(); } - else if (phase == Constants.RECRUIT) + else if (phase == Constants.BattlePhase.RECRUIT) { - phase = Constants.MOVE; - Log.event("Battle phase advances to " + - Constants.getBattlePhaseName(phase)); + phase = Constants.BattlePhase.MOVE; + Log.event("Battle phase advances to " + phase); again = setupMove(); } - else if (phase == Constants.MOVE) + else if (phase == Constants.BattlePhase.MOVE) { // IF the attacker makes it to the end of his first movement // phase without conceding, even if he left all legions @@ -328,25 +325,23 @@ { attackerEntered = true; } - phase = Constants.FIGHT; - Log.event("Battle phase advances to " + - Constants.getBattlePhaseName(phase)); + phase = Constants.BattlePhase.FIGHT; + Log.event("Battle phase advances to " + phase); again = setupFight(); } - else if (phase == Constants.FIGHT) + else if (phase == Constants.BattlePhase.FIGHT) { // We switch the active legion between the fight and strikeback // phases, not at the end of the player turn. activeLegionNum = (activeLegionNum + 1) & 1; driftDamageApplied = false; - phase = Constants.STRIKEBACK; - Log.event("Battle phase advances to " + - Constants.getBattlePhaseName(phase)); + phase = Constants.BattlePhase.STRIKEBACK; + Log.event("Battle phase advances to " + phase); again = setupFight(); } - else if (phase == Constants.STRIKEBACK) + else if (phase == Constants.BattlePhase.STRIKEBACK) { removeDeadCreatures(); checkForElimination(); @@ -369,7 +364,7 @@ // Active legion is the one that was striking back. if (activeLegionNum == Constants.ATTACKER) { - phase = Constants.SUMMON; + phase = Constants.BattlePhase.SUMMON; Log.event(getActivePlayerName() + "'s battle turn, number " + turnNumber); again = setupSummon(); @@ -383,7 +378,7 @@ } else { - phase = Constants.RECRUIT; + phase = Constants.BattlePhase.RECRUIT; again = setupRecruit(); if (getActivePlayer() != null) { @@ -473,7 +468,7 @@ Critter critter = attacker.getCritter(attacker.getHeight() - 1); placeCritter(critter); } - if (phase == Constants.SUMMON) + if (phase == Constants.BattlePhase.SUMMON) { advancePhase(); } @@ -704,7 +699,7 @@ { // Drift damage is applied only once per player turn, // during the strike phase. - if (phase == Constants.FIGHT && !driftDamageApplied) + if (phase == Constants.BattlePhase.FIGHT && !driftDamageApplied) { Iterator it = getAllCritters().iterator(); driftDamageApplied = true; @@ -980,18 +975,17 @@ boolean doneWithStrikes() { // Advance only if there are no unresolved strikes. - if (getPhase() < Constants.FIGHT || isForcedStrikeRemaining()) + Constants.BattlePhase phase = getBattlePhase(); + if (!isForcedStrikeRemaining() && phase.isFightPhase()) { - Log.error(server.getPlayerName() + - " called battle.doneWithStrikes() illegally"); - return false; - } - else - { commitStrikes(); advancePhase(); return true; } + + Log.error(server.getPlayerName() + + " called battle.doneWithStrikes() illegally"); + return false; } /** Return a set of hex labels for hexes containing targets that the @@ -1038,7 +1032,7 @@ // if the creature can strike normally, so only look for them if // no targets have yet been found. if (rangestrike && !adjacentEnemy && critter.isRangestriker() && - getPhase() != Constants.STRIKEBACK && + getBattlePhase() != Constants.BattlePhase.STRIKEBACK && critter.getLegion() == getActiveLegion()) { Iterator it = getInactiveLegion().getCritters().iterator(); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -14,11 +14,98 @@ public final class Constants { // Constants for phases of a turn. - public static final int SPLIT = 1; - public static final int MOVE = 2; - public static final int FIGHT = 3; - public static final int MUSTER = 4; + public static class Phase { + public static final Phase SPLIT = new Phase("Split", 1); + public static final Phase MOVE = new Phase("Move", 2); + public static final Phase FIGHT = new Phase("Fight", 3); + public static final Phase MUSTER = new Phase("Muster", 4); + public static Phase fromInt(int i) + { + switch(i) + { + case 1: return SPLIT; + case 2: return MOVE; + case 3: return FIGHT; + case 4: return MUSTER; + default: return null; + } + } + + public int toInt() + { + return value; + } + + + public String toString() + { + return name; + } + + private final String name; + private final int value; + + private Phase(String name, int value) + { + //private constructor + this.name = name; + this.value = value; + } + } + + // Phases of a battle turn + public static class BattlePhase { + public static final BattlePhase SUMMON + = new BattlePhase("Summon", 0); + public static final BattlePhase RECRUIT + = new BattlePhase("Recruit", 1); + public static final BattlePhase MOVE + = new BattlePhase("Move", 2); + public static final BattlePhase FIGHT + = new BattlePhase("Fight", 3); + public static final BattlePhase STRIKEBACK + = new BattlePhase("Strikeback", 4); + + public static BattlePhase fromInt(int i) + { + switch(i) + { + case 0: return SUMMON; + case 1: return RECRUIT; + case 2: return MOVE; + case 3: return FIGHT; + case 4: return STRIKEBACK; + default: return null; + } + } + + public int toInt() + { + return value; + } + + public boolean isFightPhase() + { + return value == 3 || value == 4; + } + + public String toString() + { + return name; + } + + private final String name; + private final int value; + + private BattlePhase(String name, int value) + { + //private constructor + this.name = name; + this.value = value; + } + } + /** Base path for all external game data files. */ public static final String gameDataPath = System.getProperty("user.home") + "/.colossus/"; @@ -40,13 +127,6 @@ public static final String xmlSnapshotStart = "snap"; public static final String xmlSnapshotVersion = "12"; - // Phases of a battle turn - public static final int SUMMON = 0; - public static final int RECRUIT = 1; - //public static final int MOVE = 2; - //public static final int FIGHT = 3; - public static final int STRIKEBACK = 4; - public static final int BIGNUM = 99; public static final int OUT_OF_RANGE = 5; @@ -375,51 +455,6 @@ } } - public static final String getPhaseName(int phase) - { - switch (phase) - { - case SPLIT: - return "Split"; - - case MOVE: - return "Move"; - - case FIGHT: - return "Fight"; - - case MUSTER: - return "Muster"; - - default: - return ""; - } - } - - public static String getBattlePhaseName(int phase) - { - switch (phase) - { - case Constants.SUMMON: - return "Summon"; - - case Constants.RECRUIT: - return "Recruit"; - - case Constants.MOVE: - return "Move"; - - case Constants.FIGHT: - return "Fight"; - - case Constants.STRIKEBACK: - return "Strikeback"; - - default: - return ""; - } - } - public static String getShortColorName(String c) { String temp = (String)shortNamesMap.get(c); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -47,7 +47,7 @@ private boolean gameOver; private Battle battle; private Caretaker caretaker = new Caretaker(this); - private int phase; + private Constants.Phase phase; private Server server; // Negotiation private Set[] proposals = new HashSet[2]; @@ -128,7 +128,7 @@ clearFlags(); turnNumber = 1; - phase = Constants.SPLIT; + phase = Constants.Phase.SPLIT; caretaker.resetAllCounts(); players.clear(); @@ -678,22 +678,22 @@ return loadingGame; } - int getPhase() + Constants.Phase getPhase() { return phase; } /** Advance to the next phase, only if the passed oldPhase and playerName * are current. */ - synchronized void advancePhase(final int oldPhase, final String playerName) + synchronized void advancePhase(final Constants.Phase oldPhase, final String playerName) { if (oldPhase != phase || pendingAdvancePhase || !playerName.equals(getActivePlayerName())) { Log.error("Called advancePhase illegally (reason: " + (oldPhase != phase ? "oldPhase (" + - Constants.getBattlePhaseName(oldPhase) + ") != phase (" + - Constants.getBattlePhaseName(phase) + ")" : + oldPhase + ") != phase (" + + phase + ")" : (pendingAdvancePhase ? "pendingAdvancePhase is true " : (!playerName.equals(getActivePlayerName()) ? "wrong player [" + playerName + @@ -728,17 +728,30 @@ /** Advance to the next phase, with no error checking. */ public void advancePhaseInternal() { - phase++; - if (phase > Constants.MUSTER || - (getActivePlayer().isDead() && getNumLivingPlayers() > 0)) + Constants.Phase oldPhase = phase; + if (oldPhase == Constants.Phase.SPLIT) { + phase = Constants.Phase.MOVE; + } + else if (oldPhase == Constants.Phase.MOVE) + { + phase = Constants.Phase.FIGHT; + } + else if (oldPhase == Constants.Phase.FIGHT) + { + phase = Constants.Phase.MUSTER; + } + + if (oldPhase == Constants.Phase.MUSTER || + (getActivePlayer().isDead() && getNumLivingPlayers() > 0)) + { advanceTurn(); } else { - Log.event("Phase advances to " + - Constants.getPhaseName(phase)); + Log.event("Phase advances to " + phase); } + pendingAdvancePhase = false; setupPhase(); } @@ -757,7 +770,7 @@ active player, for bookkeeping purpose */ CustomRecruitBase.everyoneAdvanceTurn(activePlayerNum); - phase = Constants.SPLIT; + phase = Constants.Phase.SPLIT; if (getActivePlayer().isDead() && getNumLivingPlayers() > 0) { advanceTurn(); @@ -773,27 +786,27 @@ private void setupPhase() { - switch (getPhase()) + Constants.Phase phase = getPhase(); + if (phase == Constants.Phase.SPLIT) { - case Constants.SPLIT: - setupSplit(); - break; - - case Constants.MOVE: - setupMove(); - break; - - case Constants.FIGHT: - setupFight(); - break; - - case Constants.MUSTER: - setupMuster(); - break; - - default: - Log.error("Bogus phase"); + setupSplit(); } + else if (phase == Constants.Phase.MOVE) + { + setupMove(); + } + else if (phase == Constants.Phase.FIGHT) + { + setupFight(); + } + else if (phase == Constants.Phase.MUSTER) + { + setupMuster(); + } + else + { + Log.error("Bogus phase"); + } } private void setupSplit() @@ -831,7 +844,7 @@ // still being around to advance the turn. if (player.isDead()) { - advancePhase(Constants.MUSTER, player.getName()); + advancePhase(Constants.Phase.MUSTER, player.getName()); } else { @@ -908,7 +921,7 @@ root.addContent(el); el = new Element("CurrentPhase"); - el.addContent("" + getPhase()); + el.addContent("" + getPhase().toInt()); root.addContent(el); Element car = new Element("Caretaker"); @@ -984,7 +997,7 @@ bat.setAttribute("turnNumber", "" + battle.getTurnNumber()); bat.setAttribute("activePlayer", "" + battle.getActivePlayerName()); - bat.setAttribute("phase", "" + battle.getPhase()); + bat.setAttribute("phase", "" + battle.getBattlePhase().toInt()); bat.setAttribute("summonState", "" + battle.getSummonState()); bat.setAttribute("carryDamage", "" + battle.getCarryDamage()); bat.setAttribute("driftDamageApplied", "" + @@ -1156,7 +1169,7 @@ activePlayerNum = Integer.parseInt(el.getTextTrim()); el = root.getChild("CurrentPhase"); - phase = Integer.parseInt(el.getTextTrim()); + phase = Constants.Phase.fromInt(Integer.parseInt(el.getTextTrim())); Element ct = root.getChild("Caretaker"); java.util.List kids = ct.getChildren(); @@ -1253,7 +1266,9 @@ bat.getAttribute("turnNumber").getIntValue(); String battleActivePlayerName = bat.getAttribute("activePlayer").getValue(); - int battlePhase = bat.getAttribute("phase").getIntValue(); + Constants.BattlePhase battlePhase = + Constants.BattlePhase.fromInt( + bat.getAttribute("phase").getIntValue()); int summonState = bat.getAttribute("summonState").getIntValue(); int carryDamage = @@ -2620,7 +2635,7 @@ battle = new Battle(this, attacker.getMarkerId(), defender.getMarkerId(), Constants.DEFENDER, hexLabel, - 1, Constants.MOVE); + 1, Constants.BattlePhase.MOVE); battle.init(); } } @@ -3105,7 +3120,7 @@ int mulligan() { - if (getPhase() != Constants.MOVE) + if (getPhase() != Constants.Phase.MOVE) { return -1; } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -371,7 +371,7 @@ getClient(getPlayerName()).nak(Constants.doneWithStrikes, "Wrong player"); } - else if (battle.getPhase() < Constants.FIGHT) + else if (!battle.getBattlePhase().isFightPhase()) { getClient(getPlayerName()).nak(Constants.doneWithStrikes, "Wrong phase"); @@ -574,7 +574,7 @@ IClient client = (IClient)it.next(); if (battle != null) { - client.setupBattleFight(battle.getPhase(), + client.setupBattleFight(battle.getBattlePhase(), battle.getActivePlayerName()); } } @@ -697,7 +697,7 @@ } if (legion != null && (legion.hasMoved() || game.getPhase() == - Constants.FIGHT) && legion.canRecruit()) + Constants.Phase.FIGHT) && legion.canRecruit()) { legion.sortCritters(); Creature recruit = null; @@ -725,7 +725,7 @@ } // Need to always call this to keep game from hanging. - if (game.getPhase() == Constants.FIGHT) + if (game.getPhase() == Constants.Phase.FIGHT) { if (game.getBattle() != null) { @@ -1103,7 +1103,7 @@ { IClient client = (IClient)it.next(); client.initBattle(masterHexLabel, battle.getTurnNumber(), - battle.getActivePlayerName(), battle.getPhase(), + battle.getActivePlayerName(), battle.getBattlePhase(), battle.getAttackerId(), battle.getDefenderId()); } } @@ -1196,7 +1196,7 @@ } else { - game.advancePhase(Constants.SPLIT, getPlayerName()); + game.advancePhase(Constants.Phase.SPLIT, getPlayerName()); } } @@ -1231,7 +1231,7 @@ else { player.recombineIllegalSplits(); - game.advancePhase(Constants.MOVE, getPlayerName()); + game.advancePhase(Constants.Phase.MOVE, getPlayerName()); } } @@ -1252,7 +1252,7 @@ } else { - game.advancePhase(Constants.FIGHT, getPlayerName()); + game.advancePhase(Constants.Phase.FIGHT, getPlayerName()); } } @@ -1273,7 +1273,7 @@ // Mulligans are only allowed on turn 1. player.setMulligansLeft(0); - game.advancePhase(Constants.MUSTER, getPlayerName()); + game.advancePhase(Constants.Phase.MUSTER, getPlayerName()); } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java 2006-11-07 04:05:17 UTC (rev 2593) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java 2006-11-07 04:19:52 UTC (rev 2594) @@ -489,12 +489,13 @@ } public void initBattle(String masterHexLabel, int battleTurnNumber, - String battleActivePlayerName, int battlePhase, + String battleActivePlayerName, Constants.BattlePhase battlePhase, String attackerMarkerId, String defenderMarkerId) { out.println(Constants.initBattle + sep + masterHexLabel + sep + battleTurnNumber + sep + battleActivePlayerName + sep + - battlePhase + sep + attackerMarkerId + sep + defenderMarkerId); + battlePhase.toInt() + sep + attackerMarkerId + sep + + defenderMarkerId); } public void cleanupBattle() @@ -573,11 +574,11 @@ battleActivePlayerName + sep + battleTurnNumber); } - public void setupBattleFight(int battlePhase, + public void setupBattleFight(Constants.BattlePhase battlePhase, String battleActivePlayerName) { - out.println(Constants.setupBattleFight + sep + battlePhase + sep + - battleActivePlayerName); + out.println(Constants.setupBattleFight + sep + + battlePhase.toInt() + sep + battleActivePlayerName); } public void tellLegionLocation(String markerId, String hexLabel) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pet...@us...> - 2006-11-11 15:44:09
|
Revision: 2597 http://svn.sourceforge.net/colossus/?rev=2597&view=rev Author: peterbecker Date: 2006-11-11 07:43:41 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Fixed a couple of Eclipse warnings. I turned on a number of warnings in my Eclipse installation and started going through them. So far only the obvious issues have been fixed and some empty blocks have been commented. There are some new todos which I'll discuss on the mailing list. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleHex.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleMap.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/CaretakerInfo.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/CreatureCollectionView.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/HexMap.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickCarry.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/RationalAI.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/SimpleAI.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/RemoteLogHandler.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleHex.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleHex.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleHex.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -272,10 +272,6 @@ : '?' ; } - final void testXLabel() - { - } - public void setHexside(int i, char hexside) { this.hexsides[i] = hexside; Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleMap.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleMap.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/BattleMap.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -216,7 +216,6 @@ Log.event(playerName + " concedes the battle"); client.concede(); } - ; } }; } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/CaretakerInfo.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/CaretakerInfo.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/CaretakerInfo.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -26,6 +26,7 @@ public CaretakerInfo() { + // nothing apart from initializers } public void updateCount(String creatureName, int count, int deadCount) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -1908,6 +1908,7 @@ } else if (reason.equals(Constants.doneWithBattleMoves)) { + // @todo: why can we ignore this? } else if (reason.equals(Constants.assignStrikePenalty)) { @@ -1927,9 +1928,11 @@ } else if (reason.equals(Constants.doRecruit)) { + // @todo: why can we ignore this? } else if (reason.equals(Constants.doneWithRecruits)) { + // @todo: why can we ignore this? } else { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/CreatureCollectionView.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/CreatureCollectionView.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/CreatureCollectionView.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -402,12 +402,15 @@ } public void componentMoved(ComponentEvent e) { + // necessary to implement interface } public void componentShown(ComponentEvent e) { + // necessary to implement interface } public void componentHidden(ComponentEvent e) { + // necessary to implement interface } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/HexMap.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/HexMap.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/HexMap.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -647,50 +647,62 @@ public void mousePressed(MouseEvent e) { + // necessary to implement interface } public void mouseReleased(MouseEvent e) { + // necessary to implement interface } public void mouseClicked(MouseEvent e) { + // necessary to implement interface } public void mouseEntered(MouseEvent e) { + // necessary to implement interface } public void mouseExited(MouseEvent e) { + // necessary to implement interface } public void windowActivated(WindowEvent e) { + // necessary to implement interface } public void windowClosed(WindowEvent e) { + // necessary to implement interface } public void windowClosing(WindowEvent e) { + // necessary to implement interface } public void windowDeactivated(WindowEvent e) { + // necessary to implement interface } public void windowDeiconified(WindowEvent e) { + // necessary to implement interface } public void windowIconified(WindowEvent e) { + // necessary to implement interface } public void windowOpened(WindowEvent e) { + // necessary to implement interface } public void paintComponent(Graphics g) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickCarry.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickCarry.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickCarry.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -46,6 +46,7 @@ // Don't allow exiting without making a choice, or the game will hang. addWindowListener(new WindowAdapter() { + // @todo: this could probably be done by using setDefaultCloseOperation() } ); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -42,6 +42,7 @@ // Don't allow exiting without making a choice, or the game will hang. addWindowListener(new WindowAdapter() { + // @todo: this could probably be done by using setDefaultCloseOperation() } ); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/RationalAI.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/RationalAI.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/RationalAI.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -1240,7 +1240,6 @@ int roll; int result = 0; - roll_loop: for (roll = 1; roll <= 6; roll++) { List enemies = (List)enemyAttackMap[roll].get(hex.getLabel()); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SimpleAI.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SimpleAI.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SimpleAI.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -3023,8 +3023,8 @@ { ArrayList critterMoves = (ArrayList)allCritterMoves.clone(); while (trimCritterMoves(critterMoves)) - { - } // Just trimming + { // Just trimming + } // Now that the list is as small as possible, start finding combos. List legionMoves = new ArrayList(); @@ -3631,6 +3631,7 @@ /** MoveList is an ArrayList of CritterMoves */ class MoveList extends ArrayList { + // @todo what is this inner class for? } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -62,9 +62,10 @@ private History history; - /** Public only for JUnit test setup. */ - public Game() + /** Package-private only for JUnit test setup. */ + Game() { + // nothing to do } /** For Start */ @@ -817,6 +818,7 @@ { Log.error("No players"); dispose(); + return; } player.resetTurnState(); server.allSetupSplit(); @@ -1592,15 +1594,15 @@ /** Add recruit to legion. */ void doRecruit(Legion legion, Creature recruit, Creature recruiter) { - // Check for recruiter legality. - java.util.List recruiters = findEligibleRecruiters( - legion.getMarkerId(), recruit.getName()); - if (recruit == null) { Log.error("null recruit in Game.doRecruit()"); return; } + // Check for recruiter legality. + java.util.List recruiters = findEligibleRecruiters( + legion.getMarkerId(), recruit.getName()); + if (recruiter == null) { // If recruiter can be anonymous, then this is okay. Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/RemoteLogHandler.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/RemoteLogHandler.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/RemoteLogHandler.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -38,5 +38,6 @@ } public void flush() { + // nothing to do } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java 2006-11-11 14:10:40 UTC (rev 2596) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java 2006-11-11 15:43:41 UTC (rev 2597) @@ -84,49 +84,61 @@ public void mouseClicked(MouseEvent e) { + // nothing to do } public void mouseEntered(MouseEvent e) { + // nothing to do } public void mouseExited(MouseEvent e) { + // nothing to do } public void mousePressed(MouseEvent e) { + // nothing to do } public void mouseReleased(MouseEvent e) { + // nothing to do } public void windowClosed(WindowEvent e) { + // nothing to do } public void windowActivated(WindowEvent e) { + // nothing to do } public void windowClosing(WindowEvent e) { + // nothing to do } public void windowDeactivated(WindowEvent e) { + // nothing to do } public void windowDeiconified(WindowEvent e) { + // nothing to do } public void windowIconified(WindowEvent e) { + // nothing to do } public void windowOpened(WindowEvent e) { + // nothing to do } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pet...@us...> - 2006-11-11 21:32:27
|
Revision: 2598 http://svn.sourceforge.net/colossus/?rev=2598&view=rev Author: peterbecker Date: 2006-11-11 13:32:14 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Fixed some checks for null. Some where obviously superflous, others I moved a bit forward since they were preceeded by code assuming the variable to be non-null. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2006-11-11 15:43:41 UTC (rev 2597) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2006-11-11 21:32:14 UTC (rev 2598) @@ -637,14 +637,13 @@ public synchronized void acquireAngel(String markerId, String angelType) { Legion legion = game.getLegionByMarkerId(markerId); - if (!getPlayerName().equals(legion.getPlayerName())) - { - Log.error(getPlayerName() + " illegally called acquireAngel()"); - return; - } - if (legion != null) { + if (!getPlayerName().equals(legion.getPlayerName())) + { + Log.error(getPlayerName() + " illegally called acquireAngel()"); + return; + } legion.addAngel(angelType); } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2006-11-11 15:43:41 UTC (rev 2597) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2006-11-11 21:32:14 UTC (rev 2598) @@ -331,7 +331,7 @@ fixFilename(filename)); // url will not be null even is the file doesn't exist, // so we need to check if connection can be opened - if ((url != null) && (url.openStream() != null)) + if (url.openStream() != null) { image = Toolkit.getDefaultToolkit().getImage(url); } @@ -370,7 +370,7 @@ fixFilename(filename)); // url will not be null even is the file doesn't exist, // so we need to check if connection can be opened - if ((url != null) && (url.openStream() != null)) + if (url.openStream() != null) { icon = new ImageIcon(url); } @@ -805,10 +805,8 @@ null); waitOnImage(bi); } - if (bi != null) - { - imageCache.put(mapKey, bi); - } + imageCache.put(mapKey, bi); + return bi; } @@ -1078,12 +1076,8 @@ 0, 0, width, height, null); + waitOnImage(bi); - if (bi != null) - { - waitOnImage(bi); - } - int[] pi; WritableRaster ra = bi.getRaster(); // rebuild the image from the Alpha Channel @@ -1446,20 +1440,17 @@ fixFilename(filename)); // url will not be null even is the file doesn't exist, // so we need to check if connection can be opened - if (url != null) + InputStream stream = url.openStream(); + if (stream != null) { - InputStream stream = url.openStream(); - if (url.openStream() != null) - { - BufferedImageTranscoder t = new BufferedImageTranscoder(); - t.addTranscodingHint(ImageTranscoder.KEY_WIDTH, - new Float(width)); - t.addTranscodingHint(ImageTranscoder.KEY_HEIGHT, - new Float(height)); - TranscoderInput input = new TranscoderInput(stream); - t.transcode(input, null); - image = t.getImage(); - } + BufferedImageTranscoder t = new BufferedImageTranscoder(); + t.addTranscodingHint(ImageTranscoder.KEY_WIDTH, + new Float(width)); + t.addTranscodingHint(ImageTranscoder.KEY_HEIGHT, + new Float(height)); + TranscoderInput input = new TranscoderInput(stream); + t.transcode(input, null); + image = t.getImage(); } } catch (FileNotFoundException e) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dr...@us...> - 2006-11-18 02:19:23
|
Revision: 2603 http://svn.sourceforge.net/colossus/?rev=2603&view=rev Author: dripton Date: 2006-11-17 18:19:21 -0800 (Fri, 17 Nov 2006) Log Message: ----------- Add a SaveWindow to almost every window. (Dual monitors merged into one big desktop makes popping dialogs up in the center of the screen very annoying.) Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AcquireAngel.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickCarry.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickColor.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickIntValue.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickLord.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickMarker.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickRecruit.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickRecruiter.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/SplitLegion.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/StartClient.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/SummonAngel.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/AcquireAngel.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AcquireAngel.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/AcquireAngel.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -34,9 +35,9 @@ private List recruits; private Client client; private String markerId; - private static int numberOpen = 0; private static final int basicXOffset = 16; private static final int basicYOffset = 32; + private SaveWindow saveWindow; AcquireAngel(JFrame parentFrame, Client client, String markerId, List recruits) @@ -75,9 +76,16 @@ cancelButton.addActionListener(this); pack(); - numberOpen++; - centerOnScreen(basicXOffset * numberOpen, - basicYOffset * numberOpen); + saveWindow = new SaveWindow(client, "AcquireAngel"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); repaint(); } @@ -85,7 +93,7 @@ void cleanup(String angelType) { client.acquireAngelCallback(markerId, angelType); - numberOpen--; + saveWindow.saveLocation(getLocation()); dispose(); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -2947,7 +2947,7 @@ } else { - return PickLord.pickLord(board.getFrame(), lords); + return PickLord.pickLord(this, board.getFrame(), lords); } } } @@ -3921,7 +3921,7 @@ do { color = PickColor.pickColor(board.getFrame(), playerName, - colorsLeft); + colorsLeft, this); } while (color == null); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -654,7 +654,7 @@ { final int oldScale = Scale.get(); final int newScale = PickIntValue.pickIntValue(masterFrame, - oldScale, "Pick scale", 5, 25, 1); + oldScale, "Pick scale", 5, 25, 1, client); if (newScale != oldScale) { client.setOption(Options.scale, newScale); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickCarry.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickCarry.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickCarry.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -2,6 +2,7 @@ import java.awt.GridLayout; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; @@ -22,6 +23,7 @@ { private Client client; private static final String cancel = "Decline carry"; + private SaveWindow saveWindow; /** Each choice is a String of form "Warbear in Plains Hex G3" */ PickCarry(JFrame parentFrame, Client client, int carryDamage, @@ -46,12 +48,22 @@ // Don't allow exiting without making a choice, or the game will hang. addWindowListener(new WindowAdapter() { - // @todo: this could probably be done by using setDefaultCloseOperation() + // @todo: this could probably be done by using + // setDefaultCloseOperation() } ); pack(); - centerOnScreen(); + saveWindow = new SaveWindow(client, "PickCarry"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); } @@ -74,6 +86,7 @@ String targetHex = desc.substring(desc.length() - 2); client.applyCarries(targetHex); } + saveWindow.saveLocation(getLocation()); dispose(); } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickColor.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickColor.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickColor.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -5,6 +5,7 @@ import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowListener; @@ -18,6 +19,7 @@ import net.sf.colossus.server.Constants; import net.sf.colossus.util.HTMLColor; import net.sf.colossus.util.KDialog; +import net.sf.colossus.util.Options; /** @@ -31,8 +33,8 @@ { private static final Color[] background; private static final Color[] foreground; - private static String color; + private SaveWindow saveWindow; static { @@ -52,7 +54,7 @@ } private PickColor(JFrame parentFrame, String playerName, - List colorsLeft) + List colorsLeft, IOptions options) { super(parentFrame, playerName + ", Pick a Color", true); @@ -81,15 +83,24 @@ } pack(); - centerOnScreen(); + saveWindow = new SaveWindow(options, "PickColor"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } addWindowListener(this); setVisible(true); } static String pickColor(JFrame parentFrame, String playerName, - List colorsLeft) + List colorsLeft, IOptions options) { - new PickColor(parentFrame, playerName, colorsLeft); + new PickColor(parentFrame, playerName, colorsLeft, options); return color; } @@ -129,6 +140,7 @@ public void actionPerformed(ActionEvent e) { color = e.getActionCommand(); + saveWindow.saveLocation(getLocation()); dispose(); } @@ -136,7 +148,8 @@ { Logger logger = Logger.getLogger(PickColor.class.getName()); List colorsLeft = Arrays.asList(Constants.colorNames); - String color = pickColor(new JFrame(), "Player", colorsLeft); + Options options = new Options("Player"); + String color = pickColor(new JFrame(), "Player", colorsLeft, options); logger.info("Picked " + color); System.exit(0); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickIntValue.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickIntValue.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickIntValue.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -3,6 +3,7 @@ import java.awt.Color; import java.awt.Container; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowListener; @@ -33,9 +34,10 @@ private JSpinner spinner; private SpinnerNumberModel model; + private SaveWindow saveWindow; private PickIntValue(JFrame parentFrame, int oldValue, String title, - int min, int max, int step) + int min, int max, int step, IOptions options) { super(parentFrame, title, true); this.newValue = oldValue; // oldValue is also the new unless changed @@ -66,7 +68,16 @@ buttonBar.add(cancel); pack(); - centerOnScreen(); + saveWindow = new SaveWindow(options, "PickIntValue"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); repaint(); } @@ -74,9 +85,10 @@ /** Return the new value if the user accepted it, or oldValue if * user cancelled the dialog. */ public static int pickIntValue(JFrame parentFrame, int oldValue, - String title, int min, int max, int step) + String title, int min, int max, int step, IOptions options) { - PickIntValue dialog = new PickIntValue(parentFrame, oldValue, title, min, max, step); + PickIntValue dialog = new PickIntValue(parentFrame, oldValue, title, + min, max, step, options); return dialog.newValue; } @@ -97,4 +109,10 @@ dispose(); } } + + public void dispose() + { + saveWindow.saveLocation(getLocation()); + super.dispose(); + } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickLord.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickLord.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickLord.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; +import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.WindowListener; @@ -29,8 +30,9 @@ private List chits = new ArrayList(); private static String lordType; private List imageNames; + private SaveWindow saveWindow; - private PickLord(JFrame parentFrame, List imageNames) + private PickLord(IOptions options, JFrame parentFrame, List imageNames) { super(parentFrame, "Reveal Which Lord?", true); @@ -56,14 +58,24 @@ } pack(); - centerOnScreen(); + saveWindow = new SaveWindow(options, "PickLord"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); repaint(); } - static String pickLord(JFrame parentFrame, List imageNames) + static String pickLord(IOptions options, JFrame parentFrame, + List imageNames) { - new PickLord(parentFrame, imageNames); + new PickLord(options, parentFrame, imageNames); return lordType; } @@ -78,6 +90,7 @@ { lordType = Constants.titan; } + saveWindow.saveLocation(getLocation()); dispose(); } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickMarker.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickMarker.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickMarker.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.Container; import java.awt.GridLayout; +import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.WindowEvent; @@ -29,6 +30,7 @@ { private List markers = new ArrayList(); private Client client; + private SaveWindow saveWindow; PickMarker(JFrame parentFrame, String name, Set markerIds, Client client) { @@ -62,7 +64,16 @@ } pack(); - centerOnScreen(); + saveWindow = new SaveWindow(client, "PickMarker"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); } @@ -70,6 +81,7 @@ * the player aborts the selection. */ private void cleanup(String markerId) { + saveWindow.saveLocation(getLocation()); dispose(); client.pickMarkerCallback(markerId); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickRecruit.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickRecruit.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickRecruit.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -41,6 +42,7 @@ private List legionChits = new ArrayList(); private static String recruit; private static boolean active; + private SaveWindow saveWindow; private PickRecruit(JFrame parentFrame, List recruits, String hexDescription, String markerId, Client client) @@ -104,7 +106,16 @@ recruitPane.add(cancelButton); pack(); - centerOnScreen(); + saveWindow = new SaveWindow(client, "PickRecruit"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); repaint(); } @@ -146,4 +157,10 @@ { dispose(); } + + public void dispose() + { + saveWindow.saveLocation(getLocation()); + super.dispose(); + } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickRecruiter.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickRecruiter.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickRecruiter.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -3,6 +3,7 @@ import java.awt.Color; import java.awt.Container; +import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.WindowEvent; @@ -33,6 +34,7 @@ private List recruiterChits = new ArrayList(); private Marker legionMarker; private static String recruiterName; + private SaveWindow saveWindow; /** recruiters is a list of creature name strings */ private PickRecruiter(JFrame parentFrame, List recruiters, @@ -86,7 +88,16 @@ } pack(); - centerOnScreen(); + saveWindow = new SaveWindow(client, "PickRecruiter"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); repaint(); } @@ -120,4 +131,10 @@ { dispose(); } + + public void dispose() + { + saveWindow.saveLocation(getLocation()); + super.dispose(); + } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -2,6 +2,7 @@ import java.awt.GridLayout; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; @@ -21,6 +22,7 @@ final class PickStrikePenalty extends KDialog implements ActionListener { private Client client; + private SaveWindow saveWindow; PickStrikePenalty(JFrame parentFrame, Client client, List choices) @@ -42,18 +44,29 @@ // Don't allow exiting without making a choice, or the game will hang. addWindowListener(new WindowAdapter() { - // @todo: this could probably be done by using setDefaultCloseOperation() + // @todo: this could probably be done by using + // setDefaultCloseOperation() } ); pack(); - centerOnScreen(); + saveWindow = new SaveWindow(client, "PickStrikePenalty"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); } public void actionPerformed(ActionEvent e) { client.assignStrikePenalty(e.getActionCommand()); + saveWindow.saveLocation(getLocation()); dispose(); } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SplitLegion.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SplitLegion.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SplitLegion.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.Container; import java.awt.Dimension; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -55,6 +56,8 @@ private int totalChits; private int scale; + private SaveWindow saveWindow; + private SplitLegion(Client client, String parentId, String selectedMarkerId) { @@ -129,7 +132,16 @@ buttonBox.add(button2); pack(); - centerOnScreen(); + saveWindow = new SaveWindow(client, "SplitLegion"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); } @@ -242,6 +254,15 @@ dispose(); } + public void dispose() + { + if (saveWindow != null) + { + saveWindow.saveLocation(getLocation()); + } + super.dispose(); + } + public void mousePressed(MouseEvent e) { Object source = e.getSource(); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/StartClient.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/StartClient.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/StartClient.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -3,6 +3,8 @@ import java.awt.Dimension; import java.awt.GridLayout; +import java.awt.Point; +import java.awt.event.WindowListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowEvent; @@ -39,6 +41,7 @@ static String hostname; int port; static net.sf.colossus.util.Options clientOptions; + SaveWindow saveWindow; JComboBox nameBox; JComboBox hostBox; @@ -108,7 +111,16 @@ addWindowListener(this); pack(); - centerOnScreen(); + saveWindow = new SaveWindow(clientOptions, "StartClient"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); } @@ -132,6 +144,7 @@ else if (e.getActionCommand().equals("Go")) { dispose(); + saveWindow.saveLocation(getLocation()); connect(playerName, hostname, port); } else // A combo box was changed. Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SummonAngel.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SummonAngel.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SummonAngel.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -48,6 +48,7 @@ " Selected Legion is "; private static final String noSourceSummonString = " No selected Legion"; + private SaveWindow saveWindow; private SummonAngel(Client client, String markerId) { @@ -103,9 +104,16 @@ pack(); - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - setLocation(new Point(d.width / 2 - getSize().width / 2, - d.height / 2 - getSize().height / 2)); + saveWindow = new SaveWindow(client, "SummonAngel"); + Point location = saveWindow.loadLocation(); + if (location == null) + { + centerOnScreen(); + } + else + { + setLocation(location); + } setVisible(true); repaint(); @@ -131,6 +139,7 @@ private void cleanup(String donorId, String angel) { client.doSummon(markerId, donorId, angel); + saveWindow.saveLocation(getLocation()); dispose(); active = false; } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -508,7 +508,7 @@ { final int newDelay = PickIntValue.pickIntValue(parentFrame, oldDelay, "Pick AI Delay (in ms)", Constants.MIN_AI_DELAY, - Constants.MAX_AI_DELAY, 100); + Constants.MAX_AI_DELAY, 100, options); if (newDelay != oldDelay) { options.setOption(Options.aiDelay, newDelay); @@ -517,12 +517,10 @@ } else if (e.getActionCommand().equals(Options.aiTimeLimit)) { - final int newLimit = PickIntValue.pickIntValue( - parentFrame, + final int newLimit = PickIntValue.pickIntValue(parentFrame, oldLimit, "Pick AI Time Limit (in s)", - Constants.MIN_AI_TIME_LIMIT, - Constants.MAX_AI_TIME_LIMIT, - 1); + Constants.MIN_AI_TIME_LIMIT, Constants.MAX_AI_TIME_LIMIT, + 1, options); if (newLimit != oldLimit) { options.setOption(Options.aiTimeLimit, newLimit); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2006-11-18 02:15:41 UTC (rev 2602) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2006-11-18 02:19:21 UTC (rev 2603) @@ -6,13 +6,16 @@ import net.sf.colossus.server.Constants; +// TODO move to util +import net.sf.colossus.client.IOptions; + /** Class Options lists game options for Colossus. * @version $Id$ * @author David Ripton */ -public final class Options +public final class Options implements IOptions { // Everything is public because we use this class in both the client // and server packages. (With separate data.) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pet...@us...> - 2007-03-10 17:19:50
|
Revision: 2617 http://svn.sourceforge.net/colossus/?rev=2617&view=rev Author: peterbecker Date: 2007-03-10 09:19:43 -0800 (Sat, 10 Mar 2007) Log Message: ----------- Option to see only own legions. This is another patch from Clemens Katzer: an option on startup so players can not use the Colossus interface to see the contents of other player's legions. I did a slight change regarding the window placement, otherwise this is the patch as posted by Clemens on the mailing list. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowLegion.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java 2007-02-17 20:01:47 UTC (rev 2616) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java 2007-03-10 17:19:43 UTC (rev 2617) @@ -15,6 +15,7 @@ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JLabel; import net.sf.colossus.util.KDialog; import net.sf.colossus.util.Options; @@ -28,12 +29,20 @@ private JScrollPane scrollPane; - public AutoInspector(JFrame frame, IOptions options) + private String playerName; + + private boolean onlyOwnLegionsOption = false; + + + public AutoInspector(JFrame frame, IOptions options, + String playerName, boolean onlyOwnLegions) { super(frame, "Inspector", false); this.options = options; - + this.playerName = playerName; + this.onlyOwnLegionsOption = onlyOwnLegions; + setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) @@ -75,7 +84,18 @@ JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // TODO for some reason the marker won't display itself properly here //panel.add(marker); - panel.add(new LegionInfoPanel(legion, 4 * Scale.get(), 5, 2, false)); + + String legionOwner = legion.getPlayerName(); + if ( onlyOwnLegionsOption && !playerName.equals(legionOwner) ) + { + int count = legion.getHeight(); + panel.add(new JLabel("Sorry, legion " + marker + " (" + + count + " creatures) is not your legion.")); + } + else + { + panel.add(new LegionInfoPanel(legion, 4 * Scale.get(), 5, 2, false)); + } scrollPane.getViewport().add(panel); repaint(); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-02-17 20:01:47 UTC (rev 2616) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-03-10 17:19:43 UTC (rev 2617) @@ -623,7 +623,9 @@ { parent = board.getFrame(); } - autoInspector = new AutoInspector(parent, this); + boolean onlyOwnLegions = getOption(Options.onlyOwnLegions); + autoInspector = new AutoInspector(parent, this, playerName, + onlyOwnLegions); } } else Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-02-17 20:01:47 UTC (rev 2616) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-03-10 17:19:43 UTC (rev 2617) @@ -155,6 +155,7 @@ private static Set towerSet = null; private boolean playerLabelDone; + private boolean onlyOwnLegionsOption; private JMenu lfMenu; private SaveWindow saveWindow; @@ -314,7 +315,8 @@ MasterBoard(final Client client) { this.client = client; - + this.onlyOwnLegionsOption = client.getOption(Options.onlyOwnLegions); + masterFrame = new JFrame("MasterBoard"); masterFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); contentPane = masterFrame.getContentPane(); @@ -1987,8 +1989,10 @@ if (isPopupButton(e)) { LegionInfo legion = client.getLegionInfo(markerId); + String playerName = client.getPlayerName(); new ShowLegion(masterFrame, marker, legion, - point, scrollPane, 4 * Scale.get()); + point, scrollPane, 4 * Scale.get(), playerName, + onlyOwnLegionsOption); return; } else if (client.isMyLegion(markerId)) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowLegion.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowLegion.java 2007-02-17 20:01:47 UTC (rev 2616) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowLegion.java 2007-03-10 17:19:43 UTC (rev 2617) @@ -9,6 +9,7 @@ import java.awt.event.WindowListener; import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JScrollPane; import net.sf.colossus.util.KDialog; @@ -24,7 +25,8 @@ WindowListener { ShowLegion(JFrame parentFrame, Marker marker, LegionInfo legion, - Point point, JScrollPane pane, int scale) + Point point, JScrollPane pane, int scale, + String playerName, boolean onlyOwnLegionsOption) { super(parentFrame, "Legion " + legion.getMarkerId(), false); @@ -37,10 +39,26 @@ setBackground(Color.lightGray); addWindowListener(this); - placeRelative(parentFrame, point, pane); - getContentPane().add(new LegionInfoPanel(legion, scale, 5, 2, false)); - + // this check for owner is duplicated both here and in Autoinspector. + // Would perhaps be better to have that in the LegionInfoPanel, + // but I didn't manage to display a JLabel there instead of chits... + + String legionOwner = legion.getPlayerName(); + if ( onlyOwnLegionsOption && !playerName.equals(legionOwner) ) + { + int count = legion.getHeight(); + getContentPane().add(new JLabel("Sorry, legion " + marker + " (" + + count + " creatures) is not your legion.")); + // window will be above mouse if not shifted a bit + placeRelative(parentFrame, new Point(point.x, point.y + 10), pane); + } + else + { + getContentPane().add(new LegionInfoPanel(legion, scale, 5, 2, false)); + placeRelative(parentFrame, point, pane); + } + pack(); addMouseListener(this); setVisible(true); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-02-17 20:01:47 UTC (rev 2616) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-03-10 17:19:43 UTC (rev 2617) @@ -106,6 +106,7 @@ addCheckbox(Options.logDebug, checkboxPane); addCheckbox(Options.balancedTowers, checkboxPane); addCheckbox(Options.allStacksVisible, checkboxPane); + addCheckbox(Options.onlyOwnLegions, checkboxPane); addCheckbox(Options.autoStop, checkboxPane); addCheckbox(Options.autoQuit, checkboxPane); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java 2007-02-17 20:01:47 UTC (rev 2616) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java 2007-03-10 17:19:43 UTC (rev 2617) @@ -34,7 +34,7 @@ Point origin = new Point(point.x + parentOrigin.x - viewOrigin.x, point.y + parentOrigin.y - viewOrigin.y); - + setLocation(origin); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-02-17 20:01:47 UTC (rev 2616) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-03-10 17:19:43 UTC (rev 2617) @@ -39,6 +39,7 @@ public static final String balancedTowers = "Balanced starting towers"; public static final String allStacksVisible = "All stacks visible"; + public static final String onlyOwnLegions = "Only own legions viewable"; public static final String cumulativeSlow = "Slowing is cumulative"; public static final String oneHexAllowed = "Always allows one hex"; public static final String nonRandomBattleDice = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pet...@us...> - 2007-03-10 17:41:14
|
Revision: 2618 http://svn.sourceforge.net/colossus/?rev=2618&view=rev Author: peterbecker Date: 2007-03-10 09:41:12 -0800 (Sat, 10 Mar 2007) Log Message: ----------- Patch for en- and disabling done button. Another patch from Clemens Katzer. This time the done button should behave better in terms of being enabled when it should be. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-03-10 17:19:43 UTC (rev 2617) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-03-10 17:41:12 UTC (rev 2618) @@ -2098,6 +2098,10 @@ } */ } + if (findEngagements().isEmpty() && board != null ) + { + board.enableBottomBarDoneButton(); + } } } @@ -2312,6 +2316,10 @@ board.fullRepaint(); // Ensure that movement die goes away if (isMyTurn()) { + if ( turnNumber == 1 ) + { + board.disableBottomBarDoneButton(); + } focusBoard(); defaultCursor(); if (!getOption(Options.autoSplit) && @@ -3107,7 +3115,8 @@ } public void didMove(String markerId, String startingHexLabel, - String currentHexLabel, String entrySide, boolean teleport) + String currentHexLabel, String entrySide, boolean teleport, + boolean splitLegionHasForcedMove) { removeRecruitChit(startingHexLabel); if (isMyLegion(markerId)) @@ -3128,12 +3137,16 @@ board.alignLegions(currentHexLabel); board.highlightUnmovedLegions(); board.repaint(); + if ( isMyLegion(markerId) && ! splitLegionHasForcedMove ) + { + board.enableBottomBarDoneButton(); + } } kickMoves(); } public void undidMove(String markerId, String formerHexLabel, - String currentHexLabel) + String currentHexLabel, boolean splitLegionHasForcedMove) { removeRecruitChit(formerHexLabel); removeRecruitChit(currentHexLabel); @@ -3145,6 +3158,10 @@ board.alignLegions(formerHexLabel); board.alignLegions(currentHexLabel); board.highlightUnmovedLegions(); + if ( isUndoStackEmpty() || splitLegionHasForcedMove ) + { + board.disableBottomBarDoneButton(); + } } } @@ -3608,6 +3625,14 @@ server.undoSplit(splitoffId); getPlayerInfo().addMarkerAvailable(splitoffId); numSplitsThisTurn--; + if ( turnNumber == 1 && numSplitsThisTurn == 0 ) + { + // must split in first turn - Done not allowed now + if ( board != null ) + { + board.disableBottomBarDoneButton(); + } + } Log.debug("called server.undoSplit"); } @@ -3908,6 +3933,10 @@ } numSplitsThisTurn++; + if ( turnNumber == 1 && board != null ) + { + board.enableBottomBarDoneButton(); + } if (board != null) { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2007-03-10 17:19:43 UTC (rev 2617) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2007-03-10 17:41:12 UTC (rev 2618) @@ -121,10 +121,11 @@ String endingHexLabel, boolean undo); public void didMove(String markerId, String startingHexLabel, - String currentHexLabel, String entrySide, boolean teleport); + String currentHexLabel, String entrySide, boolean teleport, + boolean splitLegionHasForcedMove); public void undidMove(String markerId, String formerHexLabel, - String currentHexLabel); + String currentHexLabel, boolean splitLegionHasForcedMove); public void undidSplit(String splitoffId, String survivorId, int turn); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-03-10 17:19:43 UTC (rev 2617) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-03-10 17:41:12 UTC (rev 2618) @@ -1395,7 +1395,8 @@ if (client.getPlayerName().equals(activePlayerName)) { bottomBar.setOwnPhase("Movement"); - + bottomBar.disableDoneButton(); + JMenuItem mi; mi = phaseMenu.add(clearRecruitChitsAction); @@ -2404,6 +2405,11 @@ doneButton.setEnabled(false); } + void enableDoneButton() + { + doneButton.setEnabled(true); + } + BottomBar() { super(); @@ -2423,4 +2429,15 @@ } } + + public void enableBottomBarDoneButton() + { + bottomBar.enableDoneButton(); + } + + public void disableBottomBarDoneButton() + { + bottomBar.disableDoneButton(); + } + } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2007-03-10 17:19:43 UTC (rev 2617) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2007-03-10 17:41:12 UTC (rev 2618) @@ -393,15 +393,30 @@ String entrySide = (String)args.remove(0); boolean teleport = Boolean.valueOf((String)args.remove(0)).booleanValue(); + boolean splitLegionHasForcedMove = false; + // servers from older versions might not send this arg + if ( ! args.isEmpty() ) + { + splitLegionHasForcedMove = + Boolean.valueOf((String)args.remove(0)).booleanValue(); + } client.didMove(markerId, startingHexLabel, currentHexLabel, - entrySide, teleport); + entrySide, teleport, splitLegionHasForcedMove); } else if (method.equals(Constants.undidMove)) { String markerId = (String)args.remove(0); String formerHexLabel = (String)args.remove(0); String currentHexLabel = (String)args.remove(0); - client.undidMove(markerId, formerHexLabel, currentHexLabel); + boolean splitLegionHasForcedMove = false; + // servers from older versions might not send this arg + if ( ! args.isEmpty() ) + { + splitLegionHasForcedMove = + Boolean.valueOf((String)args.remove(0)).booleanValue(); + } + client.undidMove(markerId, formerHexLabel, currentHexLabel, + splitLegionHasForcedMove); } else if (method.equals(Constants.undidSplit)) { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2007-03-10 17:19:43 UTC (rev 2617) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2007-03-10 17:41:12 UTC (rev 2618) @@ -1162,11 +1162,17 @@ String formerHexLabel = legion.getCurrentHexLabel(); game.getActivePlayer().undoMove(markerId); String currentHexLabel = legion.getCurrentHexLabel(); + + Player player = game.getPlayer(game.getActivePlayerName()); + // needed in undidMove to decide whether to dis/enable button + boolean splitLegionHasForcedMove = player.splitLegionHasForcedMove(); + Iterator it = clients.iterator(); while (it.hasNext()) { IClient client = (IClient)it.next(); - client.undidMove(markerId, formerHexLabel, currentHexLabel); + client.undidMove(markerId, formerHexLabel, currentHexLabel, + splitLegionHasForcedMove); } } @@ -1437,12 +1443,16 @@ void allTellDidMove(String markerId, String startingHexLabel, String endingHexLabel, String entrySide, boolean teleport) { + Player player = game.getPlayer(game.getActivePlayerName()); + // needed in didMove to decide whether to dis/enable button + boolean splitLegionHasForcedMove = player.splitLegionHasForcedMove(); + Iterator it = clients.iterator(); while (it.hasNext()) { IClient client = (IClient)it.next(); client.didMove(markerId, startingHexLabel, endingHexLabel, - entrySide, teleport); + entrySide, teleport, splitLegionHasForcedMove); } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java 2007-03-10 17:19:43 UTC (rev 2617) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java 2007-03-10 17:41:12 UTC (rev 2618) @@ -595,18 +595,20 @@ } public void didMove(String markerId, String startingHexLabel, - String currentHexLabel, String entrySide, boolean teleport) + String currentHexLabel, String entrySide, boolean teleport, + boolean splitLegionHasForcedMove) { out.println(Constants.didMove + sep + markerId + sep + startingHexLabel + sep + currentHexLabel + sep + entrySide + - sep + teleport); + sep + teleport + sep + splitLegionHasForcedMove); } public void undidMove(String markerId, String formerHexLabel, - String currentHexLabel) + String currentHexLabel, boolean splitLegionHasForcedMove) { out.println(Constants.undidMove + sep + markerId + sep + - formerHexLabel + sep + currentHexLabel); + formerHexLabel + sep + currentHexLabel + sep + + splitLegionHasForcedMove); } public void undidSplit(String splitoffId, String survivorId, int turn) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-03-19 07:13:24
|
Revision: 2621 http://svn.sourceforge.net/colossus/?rev=2621&view=rev Author: cleka Date: 2007-03-19 00:13:22 -0700 (Mon, 19 Mar 2007) Log Message: ----------- Added in MasterBoard Help menu a "Show Variant Readme". Some lines of code from GetPlayers.java taken out into a new ShowReadme.java; both GetPlayer selection and the Masterboard use that code to display the Variant README file to the user (MasterBoard in own frame that can be minimized and restored independently). Besides, cleaned up the mnemonic chars for the main menu ("Player" had "H" ;-), Look&Feel no char at all, Help had none.) Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java Added Paths: ----------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-03-19 02:49:52 UTC (rev 2620) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-03-19 07:13:22 UTC (rev 2621) @@ -126,6 +126,7 @@ public static final String chooseScreen = "Choose Screen For Info Windows"; public static final String about = "About"; + public static final String viewReadme = "Show Variant Readme"; private AbstractAction newGameAction; private AbstractAction loadGameAction; @@ -150,6 +151,7 @@ private AbstractAction chooseScreenAction; private AbstractAction aboutAction; + private AbstractAction viewReadmeAction; /* a Set of label (String) of all Tower hex */ private static Set towerSet = null; @@ -671,6 +673,14 @@ "java.version: " + System.getProperty("java.version")); } }; + + viewReadmeAction = new AbstractAction(viewReadme) + { + public void actionPerformed(ActionEvent e) + { + new ShowReadme(masterFrame, client); + } + }; } private void setupPopupMenu() @@ -729,7 +739,7 @@ // Then per-player options JMenu playerMenu = new JMenu("Player"); - playerMenu.setMnemonic(KeyEvent.VK_P); + playerMenu.setMnemonic(KeyEvent.VK_Y); menuBar.add(playerMenu); addCheckBox(playerMenu, Options.autoPickColor, KeyEvent.VK_C); @@ -780,6 +790,7 @@ // Then Look & Feel lfMenu = new JMenu("Look & Feel"); + lfMenu.setMnemonic(KeyEvent.VK_L); menuBar.add(lfMenu); UIManager.LookAndFeelInfo[] lfInfo = UIManager.getInstalledLookAndFeels(); @@ -796,10 +807,12 @@ // Then help menu JMenu helpMenu = new JMenu("Help"); - playerMenu.setMnemonic(KeyEvent.VK_H); + helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); mi = helpMenu.add(aboutAction); + mi = helpMenu.add(viewReadmeAction); + mi.setMnemonic(KeyEvent.VK_V); } class ChangeLookFeelAction extends AbstractAction Added: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java (rev 0) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java 2007-03-19 07:13:22 UTC (rev 2621) @@ -0,0 +1,96 @@ +package net.sf.colossus.client; + + +import java.awt.Dimension; +import java.awt.GridLayout; + +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.text.Document; + +import net.sf.colossus.server.Constants; +import net.sf.colossus.server.VariantSupport; +import net.sf.colossus.util.Options; +import net.sf.colossus.util.ResourceLoader; + + +/** + * Provides a JScrollPane to display the Variant README, + * either within GetPlayer selection tab, + * or from main boards help (then in own JFrame). + * @version $Id: ShowReadme.java 0000 2007-02-16 00:00:00Z cleka $ + * @author Clemens Katzer + */ + + +public final class ShowReadme +{ + private static JFrame viewFrame; + + ShowReadme(JFrame parentFrame, IOptions options) + { + // primitive way to avoid having more than one. How to do better? + if ( viewFrame != null ) + { + viewFrame.dispose(); + viewFrame = null; + } + + String variantName = options.getStringOption(Options.variant); + + // XXX Make sure chosen variant is in the list. + // XXX2 Same code in GetPlayer.java + if (variantName == null || variantName.length() == 0) + { + // Default variant + variantName = Constants.variantArray[0]; + } + + String title = new String("README for variant " + variantName); + + viewFrame = new JFrame(title); + + JEditorPane readme = new JEditorPane(); + + JScrollPane content = readmeContentScrollPane(readme, variantName); + viewFrame.getContentPane().add(content); + viewFrame.pack(); + viewFrame.setVisible(true); + } + + + /** + * Return a scrollable pane that displays the Readme. + * Also used by GetPlayer.java + */ + public static final JScrollPane readmeContentScrollPane( + JEditorPane readme, String variantName) + { + JPanel readmePane = new JPanel(); + JScrollPane readmeScrollPane = new JScrollPane(readmePane, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + readmePane.setLayout(new GridLayout(0, 1)); + readme.setEditable(false); + // Must be tall enough for biggest variant readme file. + Dimension readmeMaxSize = new Dimension(580, 2000); + Dimension readmePrefSize = new Dimension(580, 2000); + Dimension readmeScrollMaxSize = new Dimension(600, 2000); + Dimension readmeScrollPrefSize = new Dimension(600, 500); + readmePane.setMaximumSize(readmeMaxSize); + readmePane.setPreferredSize(readmePrefSize); + readmeScrollPane.setMaximumSize(readmeScrollMaxSize); + readmeScrollPane.setPreferredSize(readmeScrollPrefSize); + readmePane.add(readme); + + Document doc = VariantSupport.loadVariant(variantName, true); + readme.setContentType((String)doc.getProperty( + ResourceLoader.keyContentType)); + readme.setDocument(doc); + + return readmeScrollPane; + } +} + Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-03-19 02:49:52 UTC (rev 2620) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-03-19 07:13:22 UTC (rev 2621) @@ -16,8 +16,8 @@ import net.sf.colossus.util.Options; import net.sf.colossus.util.Log; import net.sf.colossus.client.PickIntValue; +import net.sf.colossus.client.ShowReadme; - /** * Class GetPlayers is a dialog used to enter players' * names, types, variant, etc. @@ -179,30 +179,14 @@ variantPane.add(buttonVariant); buttonVariant.addActionListener(this); - JPanel readmePane = new JPanel(); - JScrollPane readmeScrollPane = new JScrollPane(readmePane, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - readmePane.setLayout(new GridLayout(0, 1)); - readme.setEditable(false); - // Must be tall enough for biggest variant readme file. - Dimension readmeMaxSize = new Dimension(600, 2000); - Dimension readmePrefSize = new Dimension(600, 2000); - Dimension readmeScrollMaxSize = new Dimension(600, 2000); - Dimension readmeScrollPrefSize = new Dimension(600, 500); - readmePane.setMaximumSize(readmeMaxSize); - readmePane.setPreferredSize(readmePrefSize); - readmeScrollPane.setMaximumSize(readmeScrollMaxSize); - readmeScrollPane.setPreferredSize(readmeScrollPrefSize); - readmePane.add(readme); - tabbedPane.addTab("Variant README", readmeScrollPane); - - Document doc = VariantSupport.loadVariant(variantName, true); - readme.setContentType((String)doc.getProperty( - ResourceLoader.keyContentType)); - readme.setDocument(doc); options.setOption(Options.variant, variantName); + // if we don't pass the JEditorPane ("readme"), + // it won't be updated when Variant changes. + JScrollPane readmeScrollPane = ShowReadme.readmeContentScrollPane( + readme, variantName); + tabbedPane.addTab("Variant README", readmeScrollPane); + JPanel gamePane = new JPanel(); gamePane.setBorder(new TitledBorder("Game Startup")); gamePane.setLayout(new GridLayout(0, 4)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-03-21 21:00:53
|
Revision: 2628 http://svn.sourceforge.net/colossus/?rev=2628&view=rev Author: cleka Date: 2007-03-21 14:00:36 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Modified loading of MarkersName file(s) so that it would only complain if no such file found at all (console warnings). Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java 2007-03-21 20:48:01 UTC (rev 2627) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java 2007-03-21 21:00:36 UTC (rev 2628) @@ -341,6 +341,7 @@ load all files in order, so that we get the default mapping at the end */ ListIterator it = directories.listIterator(directories.size()); + boolean foundOne = false; while (it.hasPrevious()) { List singleDirectory = new java.util.ArrayList(); @@ -348,11 +349,12 @@ try { InputStream mmfIS = - ResourceLoader.getInputStream(Constants.markersNameFile, + ResourceLoader.getInputStreamIgnoreFail(Constants.markersNameFile, singleDirectory); if (mmfIS != null) { allNames.load(mmfIS); + foundOne = true; } } catch (Exception e) @@ -360,6 +362,11 @@ Log.warn("Markers name loading partially failed."); } } + if (!foundOne) + { + Log.warn("No file "+Constants.markersNameFile+ + " found anywhere in directories "+directories.toString()); + } return allNames; } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2007-03-21 20:48:01 UTC (rev 2627) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2007-03-21 21:00:36 UTC (rev 2628) @@ -398,6 +398,20 @@ /** * Return the first InputStream from file of name filename in the + * list of directories, tell the getInputStream not to complain + * if not found. + * @param filename Name of the file to load. + * @param directories List of directories to search (in order). + * @return The InputStream, or null if it was not found. + */ + public static InputStream getInputStreamIgnoreFail(String filename, + List directories) + { + return getInputStream(filename, directories, server != null, false, true); + } + + /** + * Return the first InputStream from file of name filename in the * list of directories. * @param filename Name of the file to load. * @param directories List of directories to search (in order). @@ -406,19 +420,24 @@ public static InputStream getInputStream(String filename, List directories) { - return getInputStream(filename, directories, server != null, false); + return getInputStream(filename, directories, server != null, false, false); } + /** * Return the first InputStream from file of name filename in * the list of directories. * @param filename Name of the file to load. * @param directories List of directories to search (in order). * @param remote Ask the server for the stream. + * @param cachedOnly Only look in the cache file, + * do not try to load the file from permanent storage. + * @param ignoreFail (=don't complain) if file not found * @return The InputStream, or null if it was not found. */ public static InputStream getInputStream(String filename, - List directories, boolean remote, boolean cachedOnly) + List directories, boolean remote, boolean cachedOnly, + boolean ignoreFail) { String mapKey = getMapKey(filename, directories); Object cached = fileCache.get(mapKey); @@ -458,11 +477,15 @@ } if (stream == null) { - Log.warn("getInputStream:: " + - " Couldn't get InputStream for file " + - filename + " in " + directories + - (cachedOnly ? " (cached only)" : "")); - // @TODO this sounds more serious than just a warning in the logs + if (!ignoreFail) + { + Log.warn("getInputStream:: " + + " Couldn't get InputStream for file " + + filename + " in " + directories + + (cachedOnly ? " (cached only)" : "")); + // @TODO this sounds more serious than just a warning in the logs + // Anyway now at least MarkersLoader does not complain any more... + } } else { @@ -520,7 +543,7 @@ } } - return( data == null ? null : getInputStreamFromBytes(data)); + return( data==null ? null : getInputStreamFromBytes(data)); } /** @@ -537,7 +560,7 @@ boolean cachedOnly) { InputStream is = getInputStream(filename, directories, - server != null, cachedOnly); + server != null, cachedOnly, false); if (is == null) { Log.warn("getBytesFromFile:: " + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-03-21 21:16:39
|
Revision: 2629 http://svn.sourceforge.net/colossus/?rev=2629&view=rev Author: cleka Date: 2007-03-21 14:16:32 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Fixing tabs etc. from previous change (MarkersName loading) Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java 2007-03-21 21:00:36 UTC (rev 2628) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java 2007-03-21 21:16:32 UTC (rev 2629) @@ -348,9 +348,8 @@ singleDirectory.add(it.previous()); try { - InputStream mmfIS = - ResourceLoader.getInputStreamIgnoreFail(Constants.markersNameFile, - singleDirectory); + InputStream mmfIS = ResourceLoader.getInputStreamIgnoreFail( + Constants.markersNameFile, singleDirectory); if (mmfIS != null) { allNames.load(mmfIS); @@ -364,8 +363,8 @@ } if (!foundOne) { - Log.warn("No file "+Constants.markersNameFile+ - " found anywhere in directories "+directories.toString()); + Log.warn("No file "+Constants.markersNameFile+ + " found anywhere in directories "+directories.toString()); } return allNames; } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2007-03-21 21:00:36 UTC (rev 2628) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2007-03-21 21:16:32 UTC (rev 2629) @@ -477,15 +477,15 @@ } if (stream == null) { - if (!ignoreFail) - { - Log.warn("getInputStream:: " + - " Couldn't get InputStream for file " + - filename + " in " + directories + - (cachedOnly ? " (cached only)" : "")); - // @TODO this sounds more serious than just a warning in the logs - // Anyway now at least MarkersLoader does not complain any more... - } + if (!ignoreFail) + { + Log.warn("getInputStream:: " + + " Couldn't get InputStream for file " + + filename + " in " + directories + + (cachedOnly ? " (cached only)" : "")); + // @TODO this sounds more serious than just a warning in the logs + // Anyway now at least MarkersLoader does not complain any more... + } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-04-11 21:20:06
|
Revision: 2645 http://svn.sourceforge.net/colossus/?rev=2645&view=rev Author: cleka Date: 2007-04-11 14:20:03 -0700 (Wed, 11 Apr 2007) Log Message: ----------- The different viewModes (1.Only own, 2.All, 3. only what had been revealed or could be concluded). Mostly same as what I had sent as a patch recently, except that the last mode (= only what was revealed during last turn) is not visible in selection because it is not implemented yet. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/Chit.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/LegionInfoPanel.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowLegion.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -15,7 +15,6 @@ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JLabel; import net.sf.colossus.util.KDialog; import net.sf.colossus.util.Options; @@ -31,17 +30,20 @@ private String playerName; - private boolean onlyOwnLegionsOption = false; + private int viewMode; + + private boolean dubiousAsBlanks; public AutoInspector(JFrame frame, IOptions options, - String playerName, boolean onlyOwnLegions) + String playerName, int viewMode, boolean dubiousAsBlanks) { super(frame, "Inspector", false); this.options = options; this.playerName = playerName; - this.onlyOwnLegionsOption = onlyOwnLegions; + this.viewMode = viewMode; + this.dubiousAsBlanks = dubiousAsBlanks; setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); addWindowListener(new WindowAdapter(){ @@ -82,20 +84,10 @@ { scrollPane.getViewport().removeAll(); JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - // TODO for some reason the marker won't display itself properly here - //panel.add(marker); + + panel.add(new LegionInfoPanel(legion, 4 * Scale.get(), 5, 2, false, + viewMode, playerName, dubiousAsBlanks)); - String legionOwner = legion.getPlayerName(); - if ( onlyOwnLegionsOption && !playerName.equals(legionOwner) ) - { - int count = legion.getHeight(); - panel.add(new JLabel("Sorry, legion " + marker + " (" - + count + " creatures) is not your legion.")); - } - else - { - panel.add(new LegionInfoPanel(legion, 4 * Scale.get(), 5, 2, false)); - } scrollPane.getViewport().add(panel); repaint(); } @@ -109,4 +101,10 @@ })); repaint(); } + + // public so that client can update it when option is changed. + public void setDubiousAsBlanks(boolean newVal) + { + this.dubiousAsBlanks = newVal; + } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Chit.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Chit.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Chit.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -62,11 +62,17 @@ Chit(int scale, String id, boolean inverted) { - this(scale, id, inverted, false); + this(scale, id, inverted, false, false); } Chit(int scale, String id, boolean inverted, boolean dubious) { + this(scale, id, inverted, dubious, false); + } + + Chit(int scale, String id, boolean inverted, boolean dubious, + boolean dubiousAsBlank) + { super(); this.id = id; @@ -85,8 +91,14 @@ setBackground(Color.lightGray); - if (Creature.isCreature(id)) + if (dubious && dubiousAsBlank) { + String[] names = new String[1]; + names[0] = "QuestionMarkMask"; + icon = getImageIcon(names, scale); + } + else if (Creature.isCreature(id)) + { Creature cre = Creature.getCreatureByName(id); String[] names = cre.getImageNames(); if (dubious) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -163,6 +163,7 @@ private Hashtable recruitReservations = new Hashtable(); private LogWindow logWindow; + private int viewMode; public Client(String host, int port, String playerName, boolean remote) { @@ -192,6 +193,9 @@ TerrainRecruitLoader.setCaretakerInfo(caretakerInfo); net.sf.colossus.server.CustomRecruitBase.addCaretakerInfo( caretakerInfo); + + String viewModeName = options.getStringOption(Options.viewMode); + viewMode = options.getNumberForViewMode(viewModeName); } boolean isRemote() @@ -556,6 +560,11 @@ setOption(optname, String.valueOf(value)); } + public int getViewMode() + { + return this.viewMode; + } + /** Fully sync the board state by running all option triggers. */ private void runAllOptionTriggers() { @@ -650,9 +659,10 @@ { parent = board.getFrame(); } - boolean onlyOwnLegions = getOption(Options.onlyOwnLegions); + boolean dubiousAsBlanks = + getOption(Options.dubiousAsBlanks); autoInspector = new AutoInspector(parent, this, playerName, - onlyOwnLegions); + viewMode, dubiousAsBlanks); } } else @@ -665,6 +675,18 @@ } } } + else if (optname.equals(Options.viewMode)) + { + String viewModeName = options.getStringOption(Options.viewMode); + viewMode = options.getNumberForViewMode(viewModeName); + } + else if (optname.equals(Options.dubiousAsBlanks)) + { + if ( autoInspector != null ) + { + autoInspector.setDubiousAsBlanks(bval); + } + } else if (optname.equals(Options.showEngagementResults)) { showEngagementResults(bval); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/LegionInfoPanel.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/LegionInfoPanel.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/LegionInfoPanel.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -7,38 +7,158 @@ import java.awt.Dimension; import java.util.Iterator; import java.util.List; +import java.util.ArrayList; import javax.swing.Box; import javax.swing.JPanel; +import javax.swing.JLabel; import net.sf.colossus.util.HTMLColor; +import net.sf.colossus.util.Options; -public final class LegionInfoPanel extends JPanel { - public LegionInfoPanel(LegionInfo legion, int scale, int margin, int padding, boolean usePlayerColor) { - setLayout(null); +public final class LegionInfoPanel extends JPanel +{ + public LegionInfoPanel(LegionInfo legion, int scale, int margin, + int padding, boolean usePlayerColor, int viewMode, + String playerName, boolean dubiousAsBlanks) + { + + if ( viewMode == Options.viewableAllNum ) + { + viewAll(legion, usePlayerColor, scale, margin, padding, + dubiousAsBlanks, false); + } + else if ( viewMode == Options.viewableOwnNum ) + { + String legionOwner = legion.getPlayerName(); + if ( playerName.equals(legionOwner) ) + { + viewAll(legion, usePlayerColor, scale, margin, padding, + dubiousAsBlanks, false); + } + else + { + viewAll(legion, usePlayerColor, scale, margin, padding, + false, true); + } + } + else if ( viewMode == Options.viewableEverNum ) + { + // for this mode, in Game/Server broadcasting of revealed info + // is limited to those that are entitled to know; + // thus we can use the splitPrediction to decide what is + // "has ever been shown or can be concluded". + viewAll(legion, usePlayerColor, scale, margin, padding, + dubiousAsBlanks, false); + } + else + { + viewOtherText("not implemented..."); + } + } + + private void viewOtherText(String text) + { + add(new JLabel(text)); + } + + private void viewAll(LegionInfo legion, boolean usePlayerColor, int scale, + int margin, int padding, boolean dubiousAsBlanks, boolean hideAll) + { + setLayout(null); - if(usePlayerColor) { - Color playerColor = - HTMLColor.stringToColor( - legion.getPlayerInfo().getColor() + - "Colossus"); - setBackground(playerColor); + if(usePlayerColor) + { + Color playerColor = + HTMLColor.stringToColor(legion.getPlayerInfo().getColor() + + "Colossus"); + setBackground(playerColor); } + int i = 0; + int effectiveChitSize = 0; // Chit treats scale as a hint, + // actual size might differ + + // We could add the marker, if we want: + boolean showMarker = false; + if (showMarker) + { + Chit marker = new Chit(scale, legion.getMarkerId(), + false, true, false); + if (effectiveChitSize == 0) + { + effectiveChitSize = marker.getWidth(); // they should be all the same size + } + add(marker); + marker.setLocation(i * (effectiveChitSize + padding) + margin, margin); + i++; + } + List imageNames = legion.getImageNames(); List certain = legion.getCertainties(); + + // if uncertain shall be shown ones only as blanks, then + // also sort the blanks all to the end: + // (just unnecessary work if hideAll is set.) + if (dubiousAsBlanks && !hideAll) + { + Iterator iIt = imageNames.iterator(); + Iterator cIt = certain.iterator(); + List cNames = new ArrayList(); + List cCertain = new ArrayList(); + List ucNames = new ArrayList(); + List ucCertain = new ArrayList(); + while (iIt.hasNext()) + { + String imageName = (String)iIt.next(); + Boolean sure = (Boolean) cIt.next(); + if (sure.booleanValue()) + { + cNames.add(imageName); + cCertain.add(sure); + } + else + { + ucNames.add(imageName); + ucCertain.add(sure); + } + } + + imageNames.clear(); + imageNames.addAll(cNames); + imageNames.addAll(ucNames); + cNames.clear(); + ucNames.clear(); + + certain.clear(); + certain.addAll(cCertain); + certain.addAll(ucCertain); + cCertain.clear(); + ucCertain.clear(); + } + Iterator it = imageNames.iterator(); Iterator it2 = certain.iterator(); - int i = 0; - int effectiveChitSize = 0; // Chit treats scale as a hint, actual size might differ + + // now add the chits one by one to the panel: while (it.hasNext()) { String imageName = (String)it.next(); + Chit chit; boolean sure = ((Boolean)it2.next()).booleanValue(); - Chit chit = new Chit(scale, imageName, false, !sure); - if (effectiveChitSize == 0) { - effectiveChitSize = chit.getWidth(); // they should be all the same size - } + if (hideAll) + { + chit = new Chit(scale, "QuestionMarkMask", false, true, false); + } + else + { + chit = new Chit(scale, imageName, false, !sure, dubiousAsBlanks); + } + if (effectiveChitSize == 0) + { + // they should be all the same size + effectiveChitSize = chit.getWidth(); + } add(chit); chit.setLocation(i * (effectiveChitSize + padding) + margin, margin); i++; @@ -50,11 +170,11 @@ add(Box.createRigidArea(new Dimension(scale, scale))); } - setSize(legion.getImageNames().size() * (effectiveChitSize + padding) - padding + - 2 * margin, + setSize((legion.getImageNames().size()+(showMarker?1:0)) + * (effectiveChitSize + padding) - padding + 2 * margin, effectiveChitSize + 2 * margin); setMinimumSize(getSize()); setPreferredSize(getSize()); setMaximumSize(getSize()); - } -} \ No newline at end of file + } +} Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -156,7 +156,6 @@ private static Set towerSet = null; private boolean playerLabelDone; - private boolean onlyOwnLegionsOption; private JMenu lfMenu; private SaveWindow saveWindow; @@ -176,6 +175,8 @@ public void keyPressed(KeyEvent e) { + String playerName = client.getPlayerName(); + int viewMode = client.getViewMode(); if (e.getKeyCode() == POPUP_KEY) { if (legionFlyouts == null) @@ -186,10 +187,14 @@ legionFlyouts = new JPanel[markers.size()]; for (int i = 0; i < markerArray.length; i++) { Marker marker = markerArray[i]; - LegionInfo legion = client.getLegionInfo( marker.getId()); + LegionInfo legion = client.getLegionInfo(marker.getId()); int scale = 2*Scale.get(); - final JPanel panel = new LegionInfoPanel(legion, scale, PANEL_MARGIN, PANEL_PADDING, true); + boolean dubiousAsBlanks = client.getOption( + Options.dubiousAsBlanks); + final JPanel panel = new LegionInfoPanel(legion, + scale, PANEL_MARGIN, PANEL_PADDING, true, + viewMode, playerName, dubiousAsBlanks); add(panel); legionFlyouts[i] = panel; @@ -316,7 +321,6 @@ MasterBoard(final Client client) { this.client = client; - this.onlyOwnLegionsOption = client.getOption(Options.onlyOwnLegions); masterFrame = new JFrame("MasterBoard"); masterFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); @@ -766,6 +770,12 @@ addCheckBox(graphicsMenu, Options.showEngagementResults, KeyEvent.VK_E); addCheckBox(graphicsMenu, Options.showAutoInspector, KeyEvent.VK_I); + // This option makes only sense with the + // "view what SplitPrediction tells us" mode. + if (client.getViewMode() == Options.viewableEverNum) + { + addCheckBox(graphicsMenu, Options.dubiousAsBlanks, KeyEvent.VK_D); + } addCheckBox(graphicsMenu, Options.showLogWindow, KeyEvent.VK_L); addCheckBox(graphicsMenu, Options.antialias, KeyEvent.VK_N); addCheckBox(graphicsMenu, Options.useOverlay, KeyEvent.VK_V); @@ -1976,9 +1986,12 @@ { LegionInfo legion = client.getLegionInfo(markerId); String playerName = client.getPlayerName(); + int viewMode = client.getViewMode(); + boolean dubiousAsBlanks = + client.getOption(Options.dubiousAsBlanks); new ShowLegion(masterFrame, marker, legion, point, scrollPane, 4 * Scale.get(), playerName, - onlyOwnLegionsOption); + viewMode, dubiousAsBlanks); return; } else if (client.isMyLegion(markerId)) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowLegion.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowLegion.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowLegion.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -9,7 +9,6 @@ import java.awt.event.WindowListener; import javax.swing.JFrame; -import javax.swing.JLabel; import javax.swing.JScrollPane; import net.sf.colossus.util.KDialog; @@ -26,7 +25,7 @@ { ShowLegion(JFrame parentFrame, Marker marker, LegionInfo legion, Point point, JScrollPane pane, int scale, - String playerName, boolean onlyOwnLegionsOption) + String playerName, int viewMode, boolean dubiousAsBlanks) { super(parentFrame, "Legion " + legion.getMarkerId(), false); @@ -39,26 +38,11 @@ setBackground(Color.lightGray); addWindowListener(this); + getContentPane().add(new LegionInfoPanel(legion, scale, 5, 2, false, + viewMode, playerName, dubiousAsBlanks)); + + placeRelative(parentFrame, point, pane); - // this check for owner is duplicated both here and in Autoinspector. - // Would perhaps be better to have that in the LegionInfoPanel, - // but I didn't manage to display a JLabel there instead of chits... - - String legionOwner = legion.getPlayerName(); - if ( onlyOwnLegionsOption && !playerName.equals(legionOwner) ) - { - int count = legion.getHeight(); - getContentPane().add(new JLabel("Sorry, legion " + marker + " (" - + count + " creatures) is not your legion.")); - // window will be above mouse if not shifted a bit - placeRelative(parentFrame, new Point(point.x, point.y + 10), pane); - } - else - { - getContentPane().add(new LegionInfoPanel(legion, scale, 5, 2, false)); - placeRelative(parentFrame, point, pane); - } - pack(); addMouseListener(this); setVisible(true); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -2454,7 +2454,11 @@ String hexLabel = legion.getCurrentHexLabel(); server.didSplit(hexLabel, parentId, childId, newLegion.getHeight()); - if (getOption(Options.allStacksVisible)) + + // viewableAll depends on the splitPrediction to tell then true contents, + // and viewableOwn it does not harm; it only helps the AIs :) + if ( options.getStringOption(Options.viewMode).equals(Options.viewableAll) || + options.getStringOption(Options.viewMode).equals(Options.viewableOwn)) { server.allRevealLegion(legion); server.allRevealLegion(newLegion); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -41,6 +41,7 @@ private JEditorPane readme = new JEditorPane(); private JComboBox variantBox; + private JComboBox viewModeBox; /** This is Game's options, which we will modify directly. */ private Options options; @@ -107,11 +108,28 @@ addCheckbox(Options.autosave, checkboxPane); addCheckbox(Options.logDebug, checkboxPane); addCheckbox(Options.balancedTowers, checkboxPane); - addCheckbox(Options.allStacksVisible, checkboxPane); - addCheckbox(Options.onlyOwnLegions, checkboxPane); addCheckbox(Options.autoStop, checkboxPane); addCheckbox(Options.autoQuit, checkboxPane); + + String viewmodeName = options.getStringOption(Options.viewMode); + if ( viewmodeName == null ) + { + viewmodeName = Options.viewableAll; + } + + JPanel viewModePane = new JPanel(new GridLayout(0, 2)); + viewModePane.setBorder(new TitledBorder("Viewability of legions")); + optionPane.add(viewModePane); + + viewModeBox = new JComboBox(Options.viewModeArray); + viewModeBox.addActionListener(this); + viewModeBox.setSelectedItem(viewmodeName); + viewModePane.add(new JLabel("Viewable legion content:")); + viewModePane.add(viewModeBox); + + options.setOption(Options.viewMode, viewmodeName); + JPanel teleportPane = new JPanel(new GridLayout(0, 2)); teleportPane.setBorder(new TitledBorder("Teleport")); optionPane.add(teleportPane); @@ -581,6 +599,11 @@ } } } + else if ( source == viewModeBox ) + { + String value = (String) viewModeBox.getSelectedItem(); + options.setOption(Options.viewMode, value); + } else { for (int i = 0; i < Constants.MAX_MAX_PLAYERS; i++) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-04-11 20:28:09 UTC (rev 2644) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-04-11 21:20:03 UTC (rev 2645) @@ -36,7 +36,29 @@ // Rules options public static final String variant = "Variant"; + public static final String viewMode = "ViewMode"; + public static final String dubiousAsBlanks = "Uncertain as blank (Autoinspector etc.)"; + /* selections for viewable Legions */ + public static final String viewableOwn = "Only own legions"; + public static final String viewableLast = "Revealed during last turn"; + public static final String viewableEver = "Ever revealed (or concludable) since start"; + public static final String viewableAll = "True content for all legions"; + + public static final String[] viewModeArray = + { + viewableOwn, +// viewableLast, // not implemented yet. + viewableEver, + viewableAll + }; + + public static final int viewableOwnNum = 1; + public static final int viewableLastNum = 2; + public static final int viewableEverNum = 3; + public static final int viewableAllNum = 4; + + public static final String balancedTowers = "Balanced starting towers"; public static final String allStacksVisible = "All stacks visible"; public static final String onlyOwnLegions = "Only own legions viewable"; @@ -263,4 +285,17 @@ { return props.toString(); } + + // client compares then only numeric modes (easier and faster in runtime) + public int getNumberForViewMode(String viewMode) + { + int val = Options.viewableAllNum; + if (viewMode == null) return val; + if (viewMode.equals(Options.viewableAll)) val = Options.viewableAllNum; + if (viewMode.equals(Options.viewableEver)) val = Options.viewableEverNum; + if (viewMode.equals(Options.viewableLast)) val = Options.viewableLastNum; + if (viewMode.equals(Options.viewableOwn)) val = Options.viewableOwnNum; + return val; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-04-11 22:45:52
|
Revision: 2647 http://svn.sourceforge.net/colossus/?rev=2647&view=rev Author: cleka Date: 2007-04-11 15:45:48 -0700 (Wed, 11 Apr 2007) Log Message: ----------- This brings the new feature "event viewer window", which shows the information revealed in events like split, recruit, summon, teleport, winner and legion eliminated (lost battle). Seems there come occasionally NPEs when changing the checkboxes :-/ Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java Added Paths: ----------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealedCreature.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-04-11 21:21:01 UTC (rev 2646) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-04-11 22:45:48 UTC (rev 2647) @@ -67,6 +67,7 @@ private MovementDie movementDie; private EngagementResults engagementResults; private AutoInspector autoInspector; + private EventViewer eventViewer; /** hexLabel of MasterHex for current or last engagement. */ private String battleSite; @@ -129,6 +130,7 @@ /** One per player. */ private PlayerInfo[] playerInfo; + private Hashtable playerInfoByName = new Hashtable(12); /** One per player. */ private PredictSplits[] predictSplits; @@ -161,7 +163,7 @@ // XXX Make private and wrap consistently. boolean showAllRecruitChits = false; private Hashtable recruitReservations = new Hashtable(); - + private LogWindow logWindow; private int viewMode; @@ -302,7 +304,7 @@ engagementResults.maybeShow(); } } - + private void showEngagementResults(boolean show) { if (engagementResults == null && show) @@ -330,6 +332,24 @@ public void tellEngagementResults(String winnerId, String method, int points, int turns) { + if (winnerId == null) + { + // mutual elimination + storeRevealEvent(RevealEvent.eventEliminated, + this.attackerMarkerId, 0, null, null, 0); + storeRevealEvent(RevealEvent.eventEliminated, + this.defenderMarkerId, 0, null, null, 0); + } + else + { + storeRevealEvent(RevealEvent.eventWinner, + winnerId, 0, null, null, 0); + String eliminatedId = (winnerId.equals(this.attackerMarkerId) ? + this.defenderMarkerId : this.attackerMarkerId); + storeRevealEvent(RevealEvent.eventEliminated, + eliminatedId, 0, null, null, 0); + } + JFrame frame = getMapOrBoardFrame(); if (frame == null) { @@ -356,6 +376,59 @@ } } + /* Create the event viewer, so that it can collect data from beginning on. + * EventViewer shows itself depending on whether the option for it is set. + */ + private void initEventViewer() + { + if (eventViewer == null) + { + JFrame parent = secondaryParent; + if((parent == null) && (board != null)) + { + parent = board.getFrame(); + } + + // How many turns back data is kept; default to 1 if no such + // option found from user options file. + int turnsToKeep = 1; + String expiringOption = options.getStringOption( + Options.eventExpiring); + if (expiringOption != null) + { + int exp = Integer.parseInt(expiringOption); + if (exp > 0 && exp < 99) + { + turnsToKeep = exp; + } + else + { + System.out.println("Invalid value "+exp +" from option "+ + Options.eventExpiring); + } + } + + eventViewer = new EventViewer(parent, this, viewMode, turnsToKeep); + } + else + { + System.out.println("initEventViewer - nothing to do, " + + "eventViewer != null"); + } + } + + void storeRevealEvent(int eventType, String markerId1, int height1, + ArrayList rcList, String markerId2, int height2) + { + RevealEvent e = new RevealEvent(this, turnNumber, getActivePlayerNum(), + eventType, markerId1, height1, rcList, markerId2, height2); + + if (eventViewer != null) + { + eventViewer.addEvent(e); + } + } + /** * Displays the marker and its legion if possible. */ @@ -368,7 +441,7 @@ autoInspector.showLegion(marker, legion); } } - + /** * Displays the recruit tree of the hex if possible. */ @@ -379,7 +452,7 @@ autoInspector.showHexRecruitTree(hex); } } - + /** Legion summoner summons unit from legion donor. */ void doSummon(String summoner, String donor, String unit) { @@ -395,6 +468,20 @@ } } + public void didSummon(String summonerId, String donorId, String summon) + { + int summonerHeight = getLegionInfo(summonerId).getHeight(); + int donorHeight = getLegionInfo(donorId).getHeight(); + + RevealedCreature rc = new RevealedCreature(summon); + rc.setWasSummoned(true); + ArrayList rcList = new ArrayList(1); + rcList.add(rc); + + storeRevealEvent(RevealEvent.eventSummon, + donorId, donorHeight, rcList, summonerId, summonerHeight); + } + /** This player quits the whole game. The server needs to always honor * this request, because if it doesn't players will just drop * connections when they want to quit in a hurry. */ @@ -675,6 +762,18 @@ } } } + else if (optname.equals(Options.showEventViewer)) + { + if (eventViewer == null) + { + // no board (not yet, or not at all) => no eventviewer + } + else + { + // Eventviewer takes care of showing/hiding itself + eventViewer.setVisibleMaybe(); + } + } else if (optname.equals(Options.viewMode)) { String viewModeName = options.getStringOption(Options.viewMode); @@ -779,7 +878,9 @@ playerInfo = new PlayerInfo[numPlayers]; for (int i = 0; i < numPlayers; i++) { - playerInfo[i] = new PlayerInfo(this); + PlayerInfo info = new PlayerInfo(this); + playerInfo[i] = info; + String name = info.getName(); } } for (int i = 0; i < numPlayers; i++) @@ -836,14 +937,8 @@ PlayerInfo getPlayerInfo(String name) { - for (int i = 0; i < playerInfo.length; i++) - { - if (name.equals(playerInfo[i].getName())) - { - return playerInfo[i]; - } - } - return null; + int num = getPlayerNum(name); + return (num == -1 ? null : playerInfo[num]); } PlayerInfo getPlayerInfo() @@ -861,12 +956,25 @@ return names; } + // TODO: temporarily, do both hash and loop lookup and compare. + // if it turns out that this works reliably, we can change it + // so that it loops only if it does not find it ( = first call?) int getPlayerNum(String pName) { + PlayerInfo tryHash = (PlayerInfo) playerInfoByName.get(pName); for (int i = 0; i < playerInfo.length; i++) { if (pName.equals(playerInfo[i].getName())) { + if (tryHash == null) + { + playerInfoByName.put(pName, playerInfo[i]); + } + // should never happen... just for to be sure. + else if (tryHash != playerInfo[i]) + { + System.out.println("Wooooah! Found by hash differs from loop?"); + } return i; } } @@ -959,12 +1067,22 @@ } } + void disposeEventViewer() + { + if (eventViewer != null) + { + eventViewer.dispose(); + eventViewer = null; + } + } + public void dispose() { sct.setGoingDown(); cleanupBattle(); disposeMovementDie(); disposeStatusScreen(); + disposeEventViewer(); disposeMasterBoard(); if (isRemote()) { @@ -1202,12 +1320,17 @@ // public for IOracle public List getLegionCreatureCertainties(String markerId) { - try + LegionInfo info = getLegionInfo(markerId); + if (info != null) { - return getLegionInfo(markerId).getCertainties(); + return info.getCertainties(); } - catch (NullPointerException exc) - { // TODO: is this the right thing? + else + { + // System.out.println("Client "+playerName + ": FATAL: getLegionCreatureCertainties getLegionInfo for " + markerId + " returned null!"); + // Log.error("FATAL: getLegionCreatureCertainties getLegionInfo for " + markerId + " returned null!"); + + // TODO: is this the right thing? List l = new ArrayList(42/4); // just longer then max for (int idx = 0; idx < (42/4); idx++) { @@ -1252,7 +1375,10 @@ } } - /** Reveal creatures in this legion, some of which already may be known. */ + /** Reveal creatures in this legion, some of which already may be known. + * - this "reveal" is related to data coming from server being + * revealed to the split prediction + * */ public void revealCreatures(String markerId, final List names) { String pName = getPlayerNameByMarkerId(markerId); @@ -1261,7 +1387,20 @@ initPredictSplits(pName, markerId, names); createLegionInfo(markerId); } - getLegionInfo(markerId).revealCreatures(names); + try + { + getLegionInfo(markerId).revealCreatures(names); + } + catch (NullPointerException e) + { + Log.warn("NPE in revealCreatures, markerId="+markerId+ + ", names="+names.toString()); + // in stresstest uncomment those, to get logs and autosaves + // copied for troubleshooting... + // System.out.println("NPE in revealCreatures, markerId="+ + // markerId+", names="+names.toString()); + // System.exit(1); + } } /** additionally remember the images list for later, the engagement report @@ -1484,12 +1623,12 @@ possibleRecruitChits.add(chit); } } - + // all hexes public void addPossibleRecruitChits(String markerId, Set set) { clearPossibleRecruitChits(); - + // set is a set of possible target hexes Iterator it = set.iterator(); while (it.hasNext()) @@ -1513,8 +1652,8 @@ } } } - - + + void removeRecruitChit(String hexLabel) { Iterator it = recruitedChits.iterator(); @@ -1547,7 +1686,7 @@ { clearRecruitChits(); } - + void clearRecruitChits() { recruitedChits.clear(); @@ -1616,12 +1755,14 @@ if (propViewBoard != null && propViewBoard.equalsIgnoreCase("yes")) { forceViewBoard = true; + options.setOption(Options.showEventViewer, new String("true")); options.setOption(Options.showStatusScreen, new String("true")); } if (!getOption(Options.autoPlay) || ( playerName.endsWith("1") && forceViewBoard)) { + disposeEventViewer(); disposeMasterBoard(); board = new MasterBoard(this); if ( getOption(Options.showAutoInspector) ) @@ -1644,6 +1785,7 @@ initShowEngagementResults(); } + initEventViewer(); focusBoard(); } } @@ -1811,7 +1953,7 @@ info.removeAllLegions(); predictSplits[getPlayerNum(deadPlayerName)] = null; - + if (this.playerName.equals(deadPlayerName)) { playerAlive = false; @@ -2338,19 +2480,34 @@ pushUndoStack(markerId); } + ArrayList rcList = new ArrayList(); + RevealedCreature rc; + if (numRecruiters >= 1 && recruiterName != null) { List recruiters = new ArrayList(); for (int i = 0; i < numRecruiters; i++) { recruiters.add(recruiterName); + rc = new RevealedCreature(recruiterName); + rc.setDidRecruit(true); + rcList.add(rc); } revealCreatures(markerId, recruiters); } addCreature(markerId, recruitName); - getLegionInfo(markerId).setRecruited(true); - getLegionInfo(markerId).setLastRecruit(recruitName); + LegionInfo info = getLegionInfo(markerId); + info.setRecruited(true); + info.setLastRecruit(recruitName); + + rc = new RevealedCreature(recruitName); + rc.setWasRecruited(true); + rcList.add(rc); + + storeRevealEvent(RevealEvent.eventRecruit, + markerId, info.getHeight(), rcList, null, 0); + if (board != null) { GUIMasterHex hex = board.getGUIHexByLabel(hexLabel); @@ -2365,6 +2522,11 @@ String hexLabel = getHexForLegion(markerId); removeCreature(markerId, recruitName); getLegionInfo(markerId).setRecruited(false); + if (eventViewer != null) + { + eventViewer.undoEvent(RevealEvent.eventRecruit, markerId, null, + turnNumber, recruitName); + } if (board != null) { GUIMasterHex hex = board.getGUIHexByLabel(hexLabel); @@ -2411,6 +2573,12 @@ { this.activePlayerName = activePlayerName; this.turnNumber = turnNumber; + + if (eventViewer != null) + { + eventViewer.turnOrPlayerChange(this, turnNumber, + getPlayerNum(activePlayerName)); + } } private void resetAllMoves() @@ -2448,6 +2616,12 @@ this.activePlayerName = activePlayerName; this.turnNumber = turnNumber; + if (eventViewer != null) + { + eventViewer.turnOrPlayerChange(this, turnNumber, + getPlayerNum(activePlayerName)); + } + this.phase = Constants.Phase.SPLIT; numSplitsThisTurn = 0; @@ -3078,6 +3252,11 @@ return activePlayerName; } + public int getActivePlayerNum() + { + return getPlayerNum(activePlayerName); + } + Constants.Phase getPhase() { return phase; @@ -3263,20 +3442,27 @@ public void didMove(String markerId, String startingHexLabel, String currentHexLabel, String entrySide, boolean teleport, - boolean splitLegionHasForcedMove) + String teleportingLord, boolean splitLegionHasForcedMove) { removeRecruitChit(startingHexLabel); if (isMyLegion(markerId)) { pushUndoStack(markerId); } - getLegionInfo(markerId).setHexLabel(currentHexLabel); - getLegionInfo(markerId).setMoved(true); - getLegionInfo(markerId).setEntrySide( - BattleMap.entrySideNum(entrySide)); + LegionInfo info = getLegionInfo(markerId); + info.setHexLabel(currentHexLabel); + info.setMoved(true); + info.setEntrySide(BattleMap.entrySideNum(entrySide)); + if (teleport) { getLegionInfo(markerId).setTeleported(true); + RevealedCreature rc = new RevealedCreature(teleportingLord); + rc.setDidTeleport(true); + ArrayList rcList = new ArrayList(1); + rcList.add(rc); + storeRevealEvent(RevealEvent.eventTeleport, + markerId, info.getHeight(), rcList, null, 0); } if (board != null) { @@ -3322,7 +3508,7 @@ { recruitReservations.clear(); } - + /* * Reserve one. Expects that getReservedCount() had been called in this * turn for same creature before called reserveRecruit (= to cache the @@ -3347,7 +3533,7 @@ " not fround from hash, should have been created during getReservedCount!" ); remain = getCreatureCount(recruitName); } - + if (remain > 0) { remain--; @@ -3389,13 +3575,13 @@ recruitReservations.remove(recruitName); } recruitReservations.put(recruitName, new Integer(remain)); - + // System.out.println("getReservedCount: "+recruitName+" remaining: "+remain); return remain; } - - + + /** Return a list of Creatures (ignore reservations). */ List findEligibleRecruits(String markerId, String hexLabel) { @@ -3452,7 +3638,7 @@ { Creature recruit = (Creature)it.next(); int remaining = getCreatureCount(recruit); - + if ( remaining > 0 && considerReservations ) { String recruitName = recruit.toString(); @@ -3896,6 +4082,19 @@ LegionInfo info = getLegionInfo(survivorId); info.merge(splitoffId, turn); removeLegion(splitoffId); + // do the eventViewer stuff before the board, so we are sure to get + // a repaint. + if (eventViewer != null) + { + eventViewer.undoEvent(RevealEvent.eventSplit, survivorId, + splitoffId, turn, null); + } + else + { + // fine. So this client does not even have eventViewer + // (probably then not even a masterBoard, i.e. AI) + } + if (board != null) { board.alignLegions(info.getHexLabel()); @@ -4167,6 +4366,9 @@ childInfo.setHexLabel(hexLabel); + storeRevealEvent(RevealEvent.eventSplit, parentId, + parentInfo.getHeight(), null, childId, childInfo.getHeight()); + if (board != null) { Marker marker = new Marker(3 * Scale.get(), childId, this); Added: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java (rev 0) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-04-11 22:45:48 UTC (rev 2647) @@ -0,0 +1,650 @@ +package net.sf.colossus.client; + + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Container; +import java.awt.GridLayout; +import java.awt.Point; + +// import java.awt.event.ActionEvent; +// import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +// import java.awt.event.ActionListener; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.util.ArrayList; +import java.util.List; +import java.util.Iterator; +import java.util.Collections; + +import javax.swing.*; +// import javax.swing.JScrollPane; +// import javax.swing.JTextArea; +import javax.swing.BoxLayout; +import javax.swing.border.TitledBorder; + + +import net.sf.colossus.util.KDialog; +import net.sf.colossus.util.Options; + + +/** + * Event Revealing dialog. + * + * It collects all revealed events and displays all or + * only the recent ones of them. + * + * + * @version $Id: EventViewer.java 2591 2006-01-01 23:41:26Z cleka $ + * @author Clemens Katzer + */ + +final class EventViewer extends KDialog implements WindowListener, +ItemListener, ActionListener +{ + + private IOptions options; + + // private int viewMode; + + private boolean visible; + + // private ArrayList eventList = new ArrayList(); + + private List syncdEventList = Collections.synchronizedList(new ArrayList()); + + + private int turnNr; + private int playerNr; + + private int expireTurns; + + private SaveWindow saveWindow; + + private final static String windowTitle = "Event Viewer"; + + private Container eventPane; + + private Box settingsPane; + + private JScrollPane eventScrollPane; + + private JScrollBar eventScrollBar; + + // Event Viewer Filter (evf) settings (= option names): + public static final String evfSplit = "Split events"; + public static final String evfRecruit = "Recruit events"; + public static final String evfSummon = "Summon events"; + public static final String evfTeleport = "Teleport events"; + public static final String evfAcquire = "Acquire events"; + public static final String evfWinner = "Battle won events"; + public static final String evfEliminated = "Battle lost events"; + + public static final String evfTurnChange = "Turn change info"; + public static final String evfPlayerChange = "Player change info"; + + public static final String evAutoScroll = "Auto-scroll to end"; + public static final String evMaxTurns = "Maximum number of turns to display"; + + // boolean flags for them as local flags for quick access: + // Index for this are the EventXXX constants in RevealEvent.java. + private boolean[] showEventType; + + private boolean autoScroll; + private JComboBox maxTurnsDisplayExpiringBox; + + private int maxTurns = 1; + + /** + * Inits the dialog, not necessarily displays it. + * + * @param frame is the parent window + * @param options + * @viewMode viewMode, related to AutoInspector, currently not used + * @expireTurns events older than that are deleted from list + */ + + + EventViewer(final JFrame frame, final IOptions options, int viewMode, int expireTurns) + { + super(frame, windowTitle, false); + setFocusable(false); + + this.expireTurns = expireTurns; + this.options = options; + // this.viewMode = viewMode; + + showEventType = new boolean[10]; + showEventType[RevealEvent.eventRecruit] = getBoolOption(evfRecruit, true); + showEventType[RevealEvent.eventSplit] = getBoolOption(evfRecruit, true); + showEventType[RevealEvent.eventTeleport] = getBoolOption(evfTeleport, true); + showEventType[RevealEvent.eventSummon] = getBoolOption(evfSummon, true); + showEventType[RevealEvent.eventAcquire] = getBoolOption(evfAcquire, true); + showEventType[RevealEvent.eventWinner] = getBoolOption(evfWinner, false); + showEventType[RevealEvent.eventEliminated] = getBoolOption(evfEliminated, false); + + showEventType[RevealEvent.eventTurnChange] = getBoolOption(evfTurnChange, true); + showEventType[RevealEvent.eventPlayerChange] = getBoolOption(evfPlayerChange, false); + + autoScroll = getBoolOption(evAutoScroll, true); + + setupGUI(); + + setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + this.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { + options.setOption(Options.showEventViewer, false); + } + } + ); + + this.saveWindow = new SaveWindow(options, windowTitle); + setVisibleMaybe(); + } + + private boolean getBoolOption(String name, boolean defaultVal) + { + boolean bVal = defaultVal; + + String sVal = options.getStringOption(name); + if (sVal == null) + { + options.setOption(name, defaultVal); + } + else + { + bVal = sVal.equals("true"); + } + + return bVal; + } + + private void addCheckbox(String optname, Container pane) + { + JCheckBox cb = new JCheckBox(optname); + boolean selected = getBoolOption(optname, true); + cb.setSelected(selected); + cb.setAlignmentX(Component.LEFT_ALIGNMENT); + cb.setAlignmentY(Component.TOP_ALIGNMENT); + cb.addItemListener(this); + pane.add(cb); + } + + private void setupGUI() + { + // A tabbed pane, one tab the events, one tab the settings + JTabbedPane tabbedPane = new JTabbedPane(); + tabbedPane.setPreferredSize(new Dimension(220, 250)); + + // Events: + Box eventTabPane = new Box(BoxLayout.Y_AXIS); + tabbedPane.addTab("Events", eventTabPane); + eventTabPane.setAlignmentX(Component.LEFT_ALIGNMENT); + eventTabPane.setPreferredSize(new Dimension(200, 400)); + + eventPane = new Box(BoxLayout.Y_AXIS); + eventTabPane.setAlignmentX(Component.LEFT_ALIGNMENT); + //eventPane.setPreferredSize(new Dimension(200, 200)); + + eventScrollPane = new JScrollPane(eventPane, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + eventTabPane.add(eventScrollPane); + + eventScrollBar = eventScrollPane.getVerticalScrollBar(); + + // eventScrollPane.setPreferredSize(new Dimension(200, 380)); + + eventPane.add(Box.createVerticalGlue()); + + // The settings: + settingsPane = new Box(BoxLayout.Y_AXIS); + tabbedPane.addTab("Settings", settingsPane); + + JPanel checkboxPane = new JPanel(new GridLayout(0,1)); + checkboxPane.setAlignmentX(Component.LEFT_ALIGNMENT); + checkboxPane.setBorder(new TitledBorder("Event Filter")); +// checkboxPane.setMinimumSize(new Dimension(200, 100)); + checkboxPane.setPreferredSize(new Dimension(200, 300)); + checkboxPane.setMaximumSize(new Dimension(600, 300)); + settingsPane.add(checkboxPane); + settingsPane.add(Box.createRigidArea(new Dimension(0,5))); + + addCheckbox(evfRecruit, checkboxPane); + addCheckbox(evfSplit, checkboxPane); + addCheckbox(evfSummon, checkboxPane); + addCheckbox(evfTeleport, checkboxPane); + // addCheckbox(evfAcquire, checkboxPane); + addCheckbox(evfWinner, checkboxPane); + addCheckbox(evfEliminated, checkboxPane); + checkboxPane.add(new JLabel("NOTE: Teleport events remain in list even if undone.")); + checkboxPane.add(Box.createRigidArea(new Dimension(0,5))); + addCheckbox(evfTurnChange, checkboxPane); + addCheckbox(evfPlayerChange, checkboxPane); + + + JPanel miscPane = new JPanel(new GridLayout(0,2)); + miscPane.setAlignmentX(Component.LEFT_ALIGNMENT); + miscPane.setBorder(new TitledBorder("Other Settings")); + miscPane.setMinimumSize(new Dimension(200, 100)); + miscPane.setPreferredSize(new Dimension(200, 100)); + miscPane.setMaximumSize(new Dimension(600, 100)); + settingsPane.add(miscPane); + + settingsPane.add(Box.createVerticalGlue()); + settingsPane.add(Box.createRigidArea(new Dimension(0,5))); + + addCheckbox(evAutoScroll, miscPane); + miscPane.add(new JLabel("")); + + // selection for how many turns to display the data + // (must be less or equal the expiry Option from getPlayers setting) + String eventExpiringVal = options.getStringOption(Options.eventExpiring); + if ( eventExpiringVal == null ) + { + eventExpiringVal = "1"; + } + int maxVal = Integer.parseInt(eventExpiringVal); + + ArrayList alChoices = new ArrayList(); + int i; + for (i=1 ; i <= maxVal ; i++) + { + alChoices.add(new Integer(i).toString()); + } + + Object[] Choices = alChoices.toArray(); + + maxTurnsDisplayExpiringBox = new JComboBox(Choices); + maxTurnsDisplayExpiringBox.addActionListener(this); + maxTurnsDisplayExpiringBox.setSelectedItem(eventExpiringVal); + miscPane.add(new JLabel("Display max. (turns):")); + miscPane.add(maxTurnsDisplayExpiringBox); + + + // add all to the main contentPane + Container contentPane = this.getContentPane(); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); + contentPane.add(tabbedPane); + contentPane.validate(); + + this.pack(); + } + + + private void addEventToEventPane(RevealEvent e) + { + Container pane = eventPane; + + // System.out.println("Adding event panel for event " + e.getEventTypeText()); + + int oldEventTurn = e.getTurn(); + int oldPlayerNr = e.getPlayerNr(); + int type = e.getEventType(); + boolean display = true; + + if (turnNr-oldEventTurn > maxTurns-(playerNr>=oldPlayerNr?1:0)) + { +// System.out.println("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + +// " - older than max turns value!"); + display = false; + } + else if ( !showEventType[type] ) + { +// System.out.println("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + +// " - type " + type + " false."); + display = false; + } + + if (display) + { + JPanel panelForEvent = e.toPanel(); + if (panelForEvent != null) + { + pane.add(panelForEvent); + pane.add(Box.createRigidArea(new Dimension(0,5))); + } + else + { + System.out.println("WARNING: EventViewer.addEventToEventPane: event.toPanel returned null!!"); + } + } + } + + private synchronized void addEventToList(RevealEvent e) + { + synchronized(syncdEventList) + { + syncdEventList.add(e); + } + } + + public void addEvent(RevealEvent e) + { + addEventToList(e); + + if (this.visible) + { + addEventToEventPane(e); + getContentPane().validate(); + if (autoScroll) + { + eventScrollBar.setValue(eventScrollBar.getMaximum()); + } + getContentPane().validate(); + } + } + + /* + * Remove all, and add those again which are still in the eventList + */ + private void updatePanels() + { + Container pane = this.eventPane; + + pane.removeAll(); + + synchronized(syncdEventList) + { + Iterator it = syncdEventList.iterator(); + while (it.hasNext()) + { + RevealEvent e = (RevealEvent) it.next(); + addEventToEventPane(e); + } + } + + getContentPane().validate(); + if (autoScroll) + { + eventScrollBar.setValue(eventScrollBar.getMaximum()); + } + getContentPane().validate(); + this.repaint(); + } + + public void turnOrPlayerChange(Client client, int turnNr, int playerNr) + { + if (turnNr != this.turnNr) + { + RevealEvent e = new RevealEvent(client, turnNr, playerNr, + RevealEvent.eventTurnChange, null, 0, null, null, 0); + addEvent(e); + } + if (playerNr != this.playerNr || turnNr != this.turnNr) + { + RevealEvent e = new RevealEvent(client, turnNr, playerNr, + RevealEvent.eventPlayerChange, null, 0, null, null, 0); + addEvent(e); + } + + this.turnNr = turnNr; + this.playerNr = playerNr; + purgeOldEvents(); + if (this.visible) + { + updatePanels(); + } + } + + + + /* + * User undid one action. + * So far, this deletes that event from the event list and redisplays all. + * + * Better (long term plan/future improvement idea): + * mark as "undone"; if viewMode/Inspector asks for "what do we know" + * the information revealed by the undone event is + * - even if undone - nevertheless "known to the public". As in real life :) + * Until then, we simply remove e.g. Split and Recruit events. + * They are removed, because they have side effect to their legion content. + * Teleport event is not removed (not "necessary", because no side effects, + * and somewhat difficult to detect in client) + */ + public void undoEvent(int type, String parentId, String childId, int turn, String recruitName) + { +// System.out.println("Undoing event "+type+ ": splitoff "+childId+ +// ", parent "+parentId+" turn "+turn); + + + int found = 0; + if (type == RevealEvent.eventSplit) + { + synchronized(syncdEventList) + { + Iterator it = syncdEventList.iterator(); + while (it.hasNext()) + { + RevealEvent e = (RevealEvent)it.next(); + if (e.getEventType() == type && e.getTurn() == turn && + e.getMarkerId().equals(parentId) && + e.getMarkerId2().equals(childId) ) + + { + // System.out.println("Split event to be undone found."); + found++; + it.remove(); + } + } + } + + // HACK: if not found, search split event also from previous round + // Sometimes server/game gives us wrong (different) turn number for + // the split and the unsplit event. For now, if this happens, + // search also in the previous round. + // TODO: investigate, why does server gives us different turn numbers + // in those events? + if (found == 0) + { + synchronized(syncdEventList) + { + Iterator it2 = syncdEventList.iterator(); + while (it2.hasNext()) + { + RevealEvent e = (RevealEvent)it2.next(); + if (e.getEventType() == type && e.getTurn()+1 == turn && + e.getMarkerId().equals(parentId) && + e.getMarkerId2().equals(childId) + ) + { + // System.out.println("NOTE: Split event to be undone found only from previous turn!!"); + found++; + it2.remove(); + } + } + } + } + } + else if (type == RevealEvent.eventRecruit) + { + synchronized(syncdEventList) + { + Iterator it = syncdEventList.iterator(); + while (it.hasNext()) + { + RevealEvent e = (RevealEvent)it.next(); + if (e.getEventType() == type && e.getTurn() == turn && + e.getMarkerId().equals(parentId) ) + { + // System.out.println("Recruit event to be undone found."); + found++; + it.remove(); + } + } + } + } + else + { + System.out.println("WARNING: undo event for unknown type "+type+" attempted."); + return; + } + + if (found == 0) + { + System.out.println("WARNING: '"+type+"' EVENT to undo ("+ + parentId+", "+childId+", turn "+turn+") not found"); + System.exit(1); + } + if (found > 1) + { + System.out.println("ERROR: '"+type+"' EVENT found " + found + " times!!"); + System.exit(1); + } + if (this.visible) + { + updatePanels(); + } + } + + /* throw away all events which are expireTurns turns older + * than the given turnNr/playerNr combination. + */ + public void purgeOldEvents() + { +// System.out.println("Purging events, if necessary..."); + + int purged = 0; + + synchronized(syncdEventList) + { + Iterator it = syncdEventList.iterator(); + + while (it.hasNext()) + { + RevealEvent e = (RevealEvent)it.next(); + int oldEventTurn = e.getTurn(); + int oldPlayerNr = e.getPlayerNr(); + +// System.out.println("turn "+turnNr+ "oldTurn "+oldEventTurn+" plNum" + +// playerNr + " oldPlNum "+oldPlayerNr); + if (turnNr-oldEventTurn > expireTurns-(playerNr>=oldPlayerNr?1:0)) + { +// int oldEventPlayer = e.getPlayerNr(); +// System.out.println("Purging: newest event turn "+turnNr+", player" + playerNr + +// " - purging old event (turn="+oldEventTurn+", player " + oldEventPlayer + ")"); + it.remove(); + purged++; + } + } + } + if (purged > 0) + { + // System.out.println("Purged " + purged + " old events."); + getContentPane().validate(); + } + } + + public void cleanup() + { + synchronized(syncdEventList) + { + syncdEventList.clear(); + } + } + + public void dispose() + { + saveWindow.save(this); + cleanup(); + super.dispose(); + } + + public void setVisibleMaybe() + { + boolean visible = options.getOption(Options.showEventViewer); + setVisible(visible); + } + + public void setVisible(boolean visible) + { + if (visible) + { + saveWindow.restore(this, new Point(0,0)); + settingsPane.setMinimumSize(settingsPane.getSize()); + // eventPane.setMinimumSize(eventPane.getSize()); + this.visible = true; + updatePanels(); + } + else + { + saveWindow.save(this); + this.visible = false; + } + super.setVisible(visible); + } + + public synchronized void actionPerformed(ActionEvent e) + { + // A combo box was changed. + Object source = e.getSource(); + if ( source == maxTurnsDisplayExpiringBox ) + { + String value = (String) maxTurnsDisplayExpiringBox.getSelectedItem(); + options.setOption(evMaxTurns, value); + maxTurns = Integer.parseInt(value); + updatePanels(); + } + + } + + public void itemStateChanged(ItemEvent e) + { + // one of the checkboxes was changed. + JToggleButton source = (JToggleButton)e.getSource(); + String text = source.getText(); + boolean selected = (e.getStateChange() == ItemEvent.SELECTED); + options.setOption(text, selected); + + if (text.equals(evAutoScroll)) + { + this.autoScroll = selected; + } + + if (text.equals(evfRecruit)) + { + this.showEventType[RevealEvent.eventRecruit] = selected; + } + else if (text.equals(evfSplit)) + { + this.showEventType[RevealEvent.eventSplit] = selected; + } + else if (text.equals(evfTeleport)) + { + this.showEventType[RevealEvent.eventTeleport] = selected; + } + else if (text.equals(evfSummon)) + { + this.showEventType[RevealEvent.eventSummon] = selected; + } + else if (text.equals(evfWinner)) + { + this.showEventType[RevealEvent.eventWinner] = selected; + } + else if (text.equals(evfEliminated)) + { + this.showEventType[RevealEvent.eventEliminated] = selected; + } + else if (text.equals(evfAcquire)) + { + this.showEventType[RevealEvent.eventAcquire] = selected; + } + else if (text.equals(evfTurnChange)) + { + this.showEventType[RevealEvent.eventTurnChange] = selected; + } + else if (text.equals(evfPlayerChange)) + { + this.showEventType[RevealEvent.eventPlayerChange] = selected; + } + + updatePanels(); + } +} Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2007-04-11 21:21:01 UTC (rev 2646) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2007-04-11 22:45:48 UTC (rev 2647) @@ -122,11 +122,13 @@ public void didMove(String markerId, String startingHexLabel, String currentHexLabel, String entrySide, boolean teleport, - boolean splitLegionHasForcedMove); + String teleportingLord, boolean splitLegionHasForcedMove); public void undidMove(String markerId, String formerHexLabel, String currentHexLabel, boolean splitLegionHasForcedMove); + public void didSummon(String summonerId, String donorId, String summon); + public void undidSplit(String splitoffId, String survivorId, int turn); public void didSplit(String hexLabel, String parentId, String childId, Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-04-11 21:21:01 UTC (rev 2646) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-04-11 22:45:48 UTC (rev 2647) @@ -770,6 +770,7 @@ addCheckBox(graphicsMenu, Options.showEngagementResults, KeyEvent.VK_E); addCheckBox(graphicsMenu, Options.showAutoInspector, KeyEvent.VK_I); + addCheckBox(graphicsMenu, Options.showEventViewer, KeyEvent.VK_E); // This option makes only sense with the // "view what SplitPrediction tells us" mode. if (client.getViewMode() == Options.viewableEverNum) Added: trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java (rev 0) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java 2007-04-11 22:45:48 UTC (rev 2647) @@ -0,0 +1,353 @@ +package net.sf.colossus.client; + +import java.awt.Component; +import java.awt.Dimension; +import java.util.ArrayList; +import java.util.Iterator; + +import javax.swing.*; +import javax.swing.border.TitledBorder; + +import net.sf.colossus.server.Constants; + + +public class RevealEvent +{ + private Client client; + private int turnNumber; + private int playerNr; + private int eventType; + private String markerId; + private int height; + private ArrayList knownCreatures; + + private int scale; + private JPanel p; + + + public final static int eventSplit = 0; + public final static int eventRecruit = 1; + public final static int eventSummon = 2; + public final static int eventTeleport = 3; + public final static int eventAcquire = 4; + public final static int eventWinner = 5; + public final static int eventEliminated = 6; + public final static int eventTurnChange = 7; + public final static int eventPlayerChange = 8; + + private final static String eventSplitText = "Split"; + private final static String eventRecruitText = "Recruit"; + private final static String eventSummonText = "Summon"; + private final static String eventTeleportText = "Teleport"; + private final static String eventAcquireText = "Acquire"; + private final static String eventWinnerText = "Winner"; + private final static String eventEliminatedText = "Eliminated"; + private final static String eventTurnChangeText = "TurnChange"; + private final static String eventPlayerChangeText = "PlayerChange"; + + private static String[] eventTypeToString = { + eventSplitText, eventRecruitText, eventSummonText, eventTeleportText, + eventAcquireText, eventWinnerText, eventEliminatedText, + eventTurnChangeText, eventPlayerChangeText + }; + + + + // child legion or summoner: + private String markerId2; + private int height2; + + + public RevealEvent(Client client, int turnNumber, int playerNr, int eventType, + String markerId, int height, ArrayList knownCreatures, + String markerId2, int height2) + { + if (markerId == null && eventType != eventPlayerChange && eventType != eventTurnChange) + { + System.out.println("ERROR: null marker for event "+getEventTypeText(eventType)); + return; + } + this.client = client; + this.turnNumber = turnNumber; + this.playerNr = playerNr; + this.eventType = eventType; + // affected legion; split: parent; summon: donor + this.markerId = markerId; + this.height = height; + this.knownCreatures = knownCreatures; + // next 2: child legion or summoner + this.markerId2 = markerId2; + this.height2 = height2; + + // System.out.println("NEW RevealEvent: "+this.toString()); + } + + // TODO: Info events, e.g. + // took mulligan, turn change as event instead of hacked in viewer, + // player requested to see legions, ... ? + + + + public int getEventType() + { + return eventType; + } + + public String getEventTypeText() + { + return eventTypeToString[eventType]; + } + + public String getEventTypeText(int type) + { + return eventTypeToString[type]; + } + + public String getMarkerId() + { + return markerId; + } + + public String getMarkerId2() + { + return markerId2; + } + + public int getTurn() + { + return turnNumber; + } + + public String getPlayer() + { + return client.getPlayerInfo(playerNr).getName(); + } + + public int getPlayerNr() + { + return playerNr; + } + + public String toString() + { + String msg = "<unknown event?>"; + if (eventType == eventSplit) + { + msg = "Revealing event: \"" + getEventTypeText() + "\" (turn "+turnNumber+"):\n" + + "- Legion with marker: "+ markerId + " (now height: " + height+"\n" + + "- Splitoff to marker: "+ markerId2 + " (now height: " + height2+"\n"; + } + else if (eventType == eventSummon) + { + RevealedCreature rc = (RevealedCreature) this.knownCreatures.get(0); + String summoned = rc.getName(); + + msg = "Revealing event: \"" + getEventTypeText() + "\":\n" + + " Summonable \"" + summoned + "\" from " + markerId + + "(" + height + ") to " + markerId2 + "("+height2+")"; + } + + else if (eventType == eventWinner) + { + msg = "Revealing event: Winner = "+markerId; + } + + else if (eventType == eventEliminated) + { + msg = "Revealing event: Eliminated = "+markerId; + } + + else if (eventType == eventTurnChange) + { + msg = "Revealing event: Turn change, now player "+getPlayerNr()+ + " ("+getPlayer()+"), Turn "+getTurn(); + } + else if (eventType == eventPlayerChange) + { + msg = "Revealing event: Player change, now player "+getPlayerNr()+ + " ("+getPlayer()+"), Turn "+getTurn(); + } + + else + { + StringBuffer msgBuf = new StringBuffer(1000); + + msgBuf.append("Revealing event: \"" + getEventTypeText() + "\" for marker " + markerId + "\n"); + Iterator it = knownCreatures.iterator(); + + int i = 0; + while (it.hasNext()) + { + i++; + RevealedCreature rc = (RevealedCreature)it.next(); + msgBuf.append(i + ". " + rc.toString()+"\n"); + // System.out.println(i + ". " + rc.toDetails()); + } + msgBuf.append(" => legion " + markerId + " now " + height + " creatures."); + msg = msgBuf.toString(); + } + + return msg; + } + + private void addLabel(String text) + { + JLabel label = new JLabel(text); + label.setAlignmentX(Component.LEFT_ALIGNMENT); + p.add(label); + } + + // Todo: paint height on top of marker possible? + private void addMarker(String markerId) + { + if (markerId == null) + { + System.out.println("ERROR: markerId null, event type "+getEventTypeText()+" turn" +getTurn()); + } + try + { + Chit marker = new Chit(scale, markerId); + marker.setAlignmentX(Component.LEFT_ALIGNMENT); + p.add(marker); + } + catch(Exception e) + { + System.out.println("\n\nCATCH: ERROR: markerId null, event type "+getEventTypeText()+" turn" +getTurn()); + + + }; + + } + + // TODO duplicated from LegionInfo.java: + /** Return the full basename for a titan in legion markerId, + * first finding that legion's player, player color, and titan size. + * Default to Constants.titan if the info is not there. */ + String getTitanBasename() + { + try + { + PlayerInfo info = client.getPlayerInfo(playerNr); + String color = info.getColor(); + int power = info.getTitanPower(); + return "Titan-" + power + "-" + color; + } + catch (Exception ex) + { + return Constants.titan; + } + } + + private void addCreature(String creatureName) + { + String name = new String(creatureName); + if (name.equals(Constants.titan)) + { + name = getTitanBasename(); + } + if (name == null) + { + System.out.println("ERROR: creature name null, event type "+getEventTypeText()+" turn" +getTurn()); + } + + Chit creature = new Chit(scale, name); + creature.setAlignmentX(Component.LEFT_ALIGNMENT); + p.add(creature); + } + + private JPanel infoEvent(String text) + { + JPanel p = new JPanel(); + + p.setBorder(new TitledBorder("")); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.setAlignmentX(Component.LEFT_ALIGNMENT); + JLabel label = new JLabel(text); + label.setAlignmentX(Component.LEFT_ALIGNMENT); + p.add(label); + // p.add(Box.createRigidArea(new Dimension(5,0))); + + return p; + } + + public JPanel toPanel() + { + this.scale = 2 * Scale.get(); + + if (eventType == eventTurnChange) + { + return infoEvent("Turn "+turnNumber+" starts"); + } + if (eventType == eventPlayerChange) + { + return infoEvent("Turn "+turnNumber+", player "+getPlayer()); + } + + JPanel p = new JPanel(); + this.p = p; + + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.setAlignmentX(Component.LEFT_ALIGNMENT); + + addMarker(markerId); + p.add(Box.createRigidArea(new Dimension(5,0))); + + if (eventType == eventWinner || eventType == eventEliminated) + { + addLabel(getEventTypeText()); + return p; + } + + + addLabel(getEventTypeText()+": "); + + if (eventType == eventSplit) + { + int oldHeight = height+height2; + addLabel("("+oldHeight+") ==> "); + addMarker(markerId); + addLabel("("+height+")"); + addMarker(markerId2); + addLabel("("+height2+")"); + } + else if (eventType == eventRecruit) + { + Iterator it = knownCreatures.iterator(); + while (it.hasNext()) + { + RevealedCreature rc = (RevealedCreature)it.next(); + if (rc.wasRecruited()) + { + addLabel( " => "); + } + String creature = rc.getName(); + addCreature(creature); + } + } + else if (eventType == eventSummon) + { + Iterator it = knownCreatures.iterator(); + while (it.hasNext()) + { + RevealedCreature rc = (RevealedCreature)it.next(); + String creature = rc.getName(); + addCreature(creature); + } + addLabel(" to "); + addMarker(markerId2); + } + + else if ( knownCreatures != null ) + { + Iterator it = knownCreatures.iterator(); + while (it.hasNext()) + { + RevealedCreature rc = (RevealedCreature)it.next(); + String creature = rc.getName(); + addCreature(creature); + } + } + + return p; + } +} Added: trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealedCreature.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealedCreature.java (rev 0) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealedCreature.java 2007-04-11 22:45:48 UTC (rev 2647) @@ -0,0 +1,135 @@ +package net.sf.colossus.client; + + +import net.sf.colossus.util.Log; + + +/* + * Contains info about one revealed creature. + */ +public class RevealedCreature +{ + private String creatureName; + + // possible reasons why this creature was revealed: + private boolean didRecruit = false; + private boolean wasRecruited = false; + private boolean didTeleport = false; + // private boolean didTowerTeleport = false; + // private boolean didTitanTeleport = false; + private boolean wasSummoned = false; + private boolean dead = false; + + public RevealedCreature(String name) + { + if (name == null) + { + Log.error("Tried to create RevealedCreature with null name"); + return; + } + this.creatureName = name; + } + + public String getName() + { + return creatureName; + } + + public String toString() + { + String infoString = creatureName + ": " + + (didRecruit ? "did recruit; " : "") + + (wasRecruited ? "was recruited; " : "") + + (didTeleport ? "teleported; " : "") +// + (didTowerTeleport ? "tower teleported; " : "") +// + (didTitanTeleport ? "titan teleported; " : "") + + (wasSummoned ? "was summoned; " : "") + + (dead ? "is dead; " : ""); + + return infoString; + } + + public String toDetails() + { + String infoString = creatureName + + ": didRecruit " + didRecruit + ", wasRecruited " + wasRecruited + + ", didTeleport" + didTeleport +// + ", didTowerTP " + didTowerTeleport +// + ", didTitanTeleport" + didTitanTeleport + + ", wasSummoned " + wasSummoned + "; dead " + dead; + + return infoString; + } + + public void setDidRecruit(boolean value) + { + this.didRecruit = value; + } + + public boolean didRecruit() + { + return didRecruit; + } + + public void setWasRecruited(boolean value) + { + this.wasRecruited = value; + } + + public boolean wasRecruited() + { + return wasRecruited; + } + + public void setDidTeleport(boolean value) + { + this.didTeleport = value; + } + + public boolean didTeleport() + { + return didTeleport; + } + +/* + public void setDidTowerTeleport(boolean value) + { + this.didTowerTeleport = value; + } + + public boolean didTowerTeleport() + { + return didTowerTeleport; + } + + public void setDidTitanTeleport(boolean value) + { + this.didTitanTeleport = value; + } + + public boolean didTitanTeleport() + { + return didTitanTeleport; + } +*/ + public void setWasSummoned(boolean value) + { + this.wasSummoned = value; + } + + public boolean wasSummoned() + { + return wasSummoned; + } + + public void setDead(boolean value) + { + this.dead = value; + } + + public boolean isDead() + { + return dead; + } + +} Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2007-04-11 21:21:01 UTC (rev 2646) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2007-04-11 22:45:48 UTC (rev 2647) @@ -406,6 +406,8 @@ String entrySide = (String)args.remove(0); boolean teleport = Boolean.valueOf((String)args.remove(0)).booleanValue(); + String teleportingLord = (String)args.remove(0); + if (teleportingLord.equals("null")) teleportingLord = null; boolean splitLegionHasForcedMove = false; // servers from older versions might not send this arg if ( ! args.isEmpty() ) @@ -414,7 +416,7 @@ Boolean.valueOf((String)args.remove(0)).booleanValue(); } client.didMove(markerId, startingHexLabel, currentHexLabel, - entrySide, teleport, splitLegionHasForcedMove); + entrySide, teleport, teleportingLord, splitLegionHasForcedMove); } else if (method.equals(Constants.undidMove)) { @@ -431,6 +433,13 @@ client.undidMove(markerId, formerHexLabel, currentHexLabel, splitLegionHasForcedMove); } + else if (method.equals(Constants.didSummon)) + { + String summonerId = (String)args.remove(0); + String donorId = (String)args.remove(0); + String summon = (String)args.remove(0); + client.didSummon(summonerId, donorId, summon); + } else if (method.equals(... [truncated message content] |
From: <cl...@us...> - 2007-04-16 15:31:14
|
Revision: 2657 http://svn.sourceforge.net/colossus/?rev=2657&view=rev Author: cleka Date: 2007-04-16 08:31:11 -0700 (Mon, 16 Apr 2007) Log Message: ----------- Show mulligans now by default set to true (quite rare anyway), "Turns expire after" in GetPlayers defaults now to 5, "and show events for turns" in EventViewer defaults now to 3. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-04-16 15:03:47 UTC (rev 2656) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-04-16 15:31:11 UTC (rev 2657) @@ -129,7 +129,7 @@ showEventType[RevealEvent.eventWinner] = getBoolOption(evfWinner, false); showEventType[RevealEvent.eventEliminated] = getBoolOption(evfEliminated, false); - showEventType[RevealEvent.eventMulligan] = getBoolOption(evfMulligan, false); + showEventType[RevealEvent.eventMulligan] = getBoolOption(evfMulligan, true); showEventType[RevealEvent.eventTurnChange] = getBoolOption(evfTurnChange, true); showEventType[RevealEvent.eventPlayerChange] = getBoolOption(evfPlayerChange, false); @@ -265,10 +265,25 @@ } Object[] Choices = alChoices.toArray(); - + + // read user's setting for this, but cannot exceed the Game's + // general setting. + String maxTurnsOptString = + options.getStringOption(evMaxTurns); + if ( maxTurnsOptString == null ) + { + maxTurnsOptString = "3"; + } + int maxTurnsOpt = Integer.parseInt(maxTurnsOptString); + if (maxTurnsOpt > maxVal) + { + maxTurnsOpt = maxVal; + maxTurnsOptString = new Integer(maxTurnsOpt).toString(); + } + maxTurnsDisplayExpiringBox = new JComboBox(Choices); maxTurnsDisplayExpiringBox.addActionListener(this); - maxTurnsDisplayExpiringBox.setSelectedItem(eventExpiringVal); + maxTurnsDisplayExpiringBox.setSelectedItem(maxTurnsOptString); miscPane.add(new JLabel("Display max. (turns):")); miscPane.add(maxTurnsDisplayExpiringBox); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-04-16 15:03:47 UTC (rev 2656) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-04-16 15:31:11 UTC (rev 2657) @@ -132,7 +132,7 @@ String eventExpiringVal = options.getStringOption(Options.eventExpiring); if ( eventExpiringVal == null ) { - eventExpiringVal = "1"; + eventExpiringVal = "5"; } eventExpiringBox = new JComboBox(Options.eventExpiringChoices); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-04-27 21:00:10
|
Revision: 2664 http://svn.sourceforge.net/colossus/?rev=2664&view=rev Author: cleka Date: 2007-04-27 13:59:50 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Properly fixing the undo Recruit causes NPE bug, for which 2614 was the workaround. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-04-27 18:52:31 UTC (rev 2663) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-04-27 20:59:50 UTC (rev 2664) @@ -4139,6 +4139,10 @@ void undoRecruit(String markerId) { + if (undoStack.contains(markerId)) + { + undoStack.remove(markerId); + } server.undoRecruit(markerId); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java 2007-04-27 18:52:31 UTC (rev 2663) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java 2007-04-27 20:59:50 UTC (rev 2664) @@ -556,11 +556,9 @@ Log.error("Player.undoRecruit: legion for markerId " + markerId + " is null"); return; } - // this one happens if one presses "U" twice - when there is - // no recruiting to undo any more. - // TODO fix the actual bug (this method being called when it shouldn't) - // to reproduce: use auto-recruit, deselect an auto-recruited creature, - // select your own and undo twice + // This check for null was workaround for the case if someone did undo + // twice it would give here a NPE. Now properly fixed in Player.java, + // still leaving this here in place ... just in case :) String recruitName = legion.getRecruitName(); if ( recruitName == null ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-04-30 19:23:47
|
Revision: 2670 http://svn.sourceforge.net/colossus/?rev=2670&view=rev Author: cleka Date: 2007-04-30 12:23:46 -0700 (Mon, 30 Apr 2007) Log Message: ----------- Lot of changes to EventViewer: Engagement won/lost now fully supported (renamed options from Winner and Eliminated); undo for all events (does mark as undone, not just delete); ExpireEvents and DisplayTurns value support "show forever" setting; corrections and cleanup; History is NOT handled yet. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/EngagementResults.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealedCreature.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Battle.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/History.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Legion.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/SocketServerThread.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-04-30 19:11:30 UTC (rev 2669) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-04-30 19:23:46 UTC (rev 2670) @@ -214,6 +214,7 @@ clearRecruitChits(); tookMulligan = true; + // TODO: should not be needed any more here? mulliganOldRoll = movementRoll; server.mulligan(); @@ -277,6 +278,22 @@ this.attackerMarkerId = attackerId; this.defenderMarkerId = defenderId; + if (eventViewer != null) + { + attackerEventLegion = new RevealEvent(this, turnNumber, + getActivePlayerNum(), RevealEvent.eventBattle, attackerId, + getLegionInfo(attackerId).getHeight(), new ArrayList(), null, 0); + attackerEventLegion.setEventInfo(Constants.reasonBattleStarts); + attackerEventLegion.setRealPlayer(getPlayerNameByMarkerId(attackerId)); + + defenderEventLegion = new RevealEvent(this, turnNumber, + getActivePlayerNum(), RevealEvent.eventBattle, defenderId, + getLegionInfo(attackerId).getHeight(), new ArrayList(), null, 0); + + defenderEventLegion.setEventInfo(Constants.reasonBattleStarts); + defenderEventLegion.setRealPlayer(getPlayerNameByMarkerId(defenderId)); + } + // remember for end of battle. _tellEngagementResults_attackerStartingContents = getLegionImageNames(attackerId); @@ -332,33 +349,116 @@ } } - public void tellEngagementResults(String winnerId, String method, - int points, int turns) + RevealEvent winnerLegion; + RevealEvent loserLegion; + + public void tellEngagementResultsEventHandling( + String winnerId, String method) { + // if those are not set, we are new version client with old + // version server, who does not provide the reason argument + // to some other methods; then they do not set up those + // eventLegions we would need here. So, can't do anything. + if (attackerEventLegion == null || defenderEventLegion == null) + { + Log.debug("tellEngagementResultHandling, both are null"); + return; + } + if (winnerId == null) { + Log.debug("winnerId is null value"); + } + else if (winnerId.equals("null")) + { + Log.debug("winnerId is string 'null'"); + } + else + { + Log.debug("winnerId is '"+winnerId+"'"); + } + + if (winnerId == null || winnerId.equals("null")) + { + // null value = normal mutual + // string with content "null": one legion contained titan, + // titan killed, some others survived, + // titan-killing-legion eliminated. + // The above is for normal game. What if load from history?? + Log.debug("tellEngagementResultHandling, winner " + + (winnerId == null ? null : "string 'null'")); + // mutual elimination - storeRevealEvent(RevealEvent.eventEliminated, - this.attackerMarkerId, 0, null, null, 0); - storeRevealEvent(RevealEvent.eventEliminated, - this.defenderMarkerId, 0, null, null, 0); + // attackerEventLegion.setAllDead(); + attackerEventLegion.setEventType(RevealEvent.eventLost); + attackerEventLegion.setEventInfo("mutual"); + eventViewer.addEvent(attackerEventLegion); + + // defenderEventLegion.setAllDead(); + defenderEventLegion.setEventType(RevealEvent.eventLost); + defenderEventLegion.setEventInfo("mutual"); + eventViewer.addEvent(defenderEventLegion); } else { - storeRevealEvent(RevealEvent.eventWinner, - winnerId, 0, null, null, 0); - String eliminatedId = (winnerId.equals(this.attackerMarkerId) ? - this.defenderMarkerId : this.attackerMarkerId); - storeRevealEvent(RevealEvent.eventEliminated, - eliminatedId, 0, null, null, 0); + Log.event("tellEngagementResultHandling, winner = " + winnerId); + if (winnerId.equals(this.attackerMarkerId)) + { // attacker won: + winnerLegion = attackerEventLegion; + loserLegion = defenderEventLegion; + } + else + { // defender + winnerLegion = defenderEventLegion; + loserLegion = attackerEventLegion; + } + + // fled or concession there didn't come removeCreature messages, + // thus make sure they are really shown dead. + loserLegion.setAllDead(); + loserLegion.setEventType(RevealEvent.eventLost); + loserLegion.setEventInfo(method); + eventViewer.addEvent(loserLegion); + + int winnerHeight = getLegionInfo(winnerId).getHeight(); + int winnerEventHeight = winnerLegion.getHeight(); + if ( winnerEventHeight != winnerHeight) + { + if (winnerEventHeight != 0) + { + // @TODO: is that a problem? + Log.debug("Winner legion " + winnerId + + " event height mismatch: Eventheight="+ + winnerLegion.getHeight() + ", actual height=" + + winnerHeight); + } + } + winnerLegion.setEventType(RevealEvent.eventWon); + winnerLegion.setEventInfo(method); + eventViewer.addEvent(winnerLegion); } - + + lastAttackerEventLegion = attackerEventLegion; + lastDefenderEventLegion = defenderEventLegion; + + attackerEventLegion = null; + defenderEventLegion = null; + winnerLegion = null; + loserLegion = null; + } + + + public void tellEngagementResults(String winnerId, String method, + int points, int turns) + { JFrame frame = getMapOrBoardFrame(); if (frame == null) { return; } + tellEngagementResultsEventHandling(winnerId, method); + if (getOption(Options.showEngagementResults)) { if (engagementResults == null) @@ -525,6 +625,8 @@ public void tellMovementRoll(int roll) { + // for eventviewer: if oldroll is -2, this is the first roll; + // otherwise, player took mulligan. if (mulliganOldRoll == -2) { mulliganOldRoll = roll; @@ -959,6 +1061,10 @@ // so that it loops only if it does not find it ( = first call?) int getPlayerNum(String pName) { + if (pName == null) + { + return -1; + } PlayerInfo tryHash = (PlayerInfo) playerInfoByName.get(pName); for (int i = 0; i < playerInfo.length; i++) { @@ -1325,8 +1431,8 @@ } else { - // System.out.println("Client "+playerName + ": FATAL: getLegionCreatureCertainties getLegionInfo for " + markerId + " returned null!"); - // Log.error("FATAL: getLegionCreatureCertainties getLegionInfo for " + markerId + " returned null!"); + // Log.error("getLegionCreatureCertainties getLegionInfo for " + + // markerId + " returned null!"); // TODO: is this the right thing? List l = new ArrayList(42/4); // just longer then max @@ -1339,7 +1445,7 @@ } /** Add a new creature to this legion. */ - public void addCreature(String markerId, String name) + public void addCreature(String markerId, String name, String reason) { getLegionInfo(markerId).addCreature(name); if (board != null) @@ -1348,11 +1454,80 @@ GUIMasterHex hex = board.getGUIHexByLabel(hexLabel); hex.repaint(); } + + if (eventViewer != null) + { + RevealEvent battleEvent = null; + if (attackerEventLegion != null && + attackerEventLegion.getMarkerId().equals(markerId)) + { + battleEvent = attackerEventLegion; + + } + else if (defenderEventLegion != null && + defenderEventLegion.getMarkerId().equals(markerId)) + { + battleEvent = defenderEventLegion; + } + + if (battleEvent != null) + { + RevealedCreature rc = new RevealedCreature(name); + rc.setReason(reason); + battleEvent.addCreature(rc); + } + else + { + // no battle events where to add creature + } + + // create also the separate acquire event: + if (reason.equals(Constants.reasonAcquire)) + { + int newHeight = getLegionInfo(markerId).getHeight(); + RevealedCreature rc = new RevealedCreature(name); + rc.setWasAcquired(true); + ArrayList rcList = new ArrayList(1); + rcList.add(rc); + storeRevealEvent(RevealEvent.eventAcquire, + markerId, newHeight, rcList, null, 0); + + if (attackerEventLegion == null || defenderEventLegion == null) + { + // This should now never happen any more: + Log.error("no attacker nor defender legion event for acquiring!!" + + " turn" + turnNumber + " player " + activePlayerName + + " phase " + phase + " markerid " + markerId + " marker owner" + + getLegionInfo(markerId).getPlayerName() + "last engagement were" + + " attacker " + lastAttackerEventLegion.getMarkerId() + + " defender " + lastDefenderEventLegion.getMarkerId() + ); + System.exit(1); + } + } + else if (reason.equals(Constants.reasonUndoSummon)) + { + // addCreature adds summoned creature back to donor: + eventViewer.undoEvent(RevealEvent.eventSummon, markerId, null, + turnNumber, name); + if (!attackerEventLegion.undoSummon(turnNumber, name)) + { + // this should never happen... + Log.warn("Un-Summon "+ name + " out of attacker event failed!"); + } + } + } } - public void removeCreature(String markerId, String name) + public void removeCreature(String markerId, String name, String reason) { LegionInfo info = getLegionInfo(markerId); + + if (eventViewer != null) + { + removeCreatureEventHandling(markerId, name, reason); + } + String hexLabel = info.getHexLabel(); int height = info.getHeight(); info.removeCreature(name); @@ -1373,18 +1548,47 @@ } } + public void removeCreatureEventHandling(String markerId, String name, + String reason) + { + if (attackerMarkerId != null && attackerEventLegion != null && + attackerMarkerId.equals(markerId) ) + { + Log.debug("During battle, remove creature " + name + + " from attacker legion " + markerId); + + attackerEventLegion.setCreatureDied(name, + getLegionInfo(attackerMarkerId).getHeight()); + } + + else if (defenderMarkerId != null && defenderEventLegion != null && + defenderMarkerId.equals(markerId) ) + { + Log.debug("During battle, remove creature " + name + + " from defender legion " + markerId); + defenderEventLegion.setCreatureDied(name, + getLegionInfo(defenderMarkerId).getHeight()); + } + } + /** Reveal creatures in this legion, some of which already may be known. * - this "reveal" is related to data coming from server being * revealed to the split prediction * */ - public void revealCreatures(String markerId, final List names) + + public void revealCreatures(String markerId, final List names, + String reason) { + // looks as if right now we don't need the reason here in this + // method - recruit info is handled by separate didRecruit... + String pName = getPlayerNameByMarkerId(markerId); if (predictSplits == null || getPredictSplits(pName) == null) { initPredictSplits(pName, markerId, names); createLegionInfo(markerId); } + try { getLegionInfo(markerId).revealCreatures(names); @@ -1392,7 +1596,8 @@ catch (NullPointerException e) { Log.warn("NPE in revealCreatures, markerId="+markerId+ - ", names="+names.toString()); + ", reason="+reason+ ", names="+names.toString()); + Thread.dumpStack(); // in stresstest uncomment those, to get logs and autosaves // copied for troubleshooting... // System.out.println("NPE in revealCreatures, markerId="+ @@ -1401,12 +1606,22 @@ } } - /** additionally remember the images list for later, the engagement report - * */ + + // For EventViewer: + RevealEvent attackerEventLegion = null; + RevealEvent defenderEventLegion = null; + + RevealEvent lastAttackerEventLegion = null; + RevealEvent lastDefenderEventLegion = null; + + + /* pass revealed info to the SplitPrediction, and + * additionally remember the images list for later, the engagement report + */ public void revealEngagedCreatures( - String markerId, final List names, boolean isAttacker) + String markerId, final List names, boolean isAttacker, String reason) { - revealCreatures(markerId, names); + revealCreatures(markerId, names, reason); // in engagment we need to update the remembered list, too. if (isAttacker) { @@ -1424,7 +1639,50 @@ _tellEngagementResults_defenderLegionCertainities = getLegionCreatureCertainties(markerId); } + + if (eventViewer != null) + { + revealEngagedCreaturesEventHandling( + markerId, names, isAttacker, reason); + } + + } + + public void revealEngagedCreaturesEventHandling(String markerId, + final List names, boolean isAttacker, String reason) + { + // can't co anything if (old) server or history do not provide + // us the reason + if (reason == null || reason.equals("<Unknown>")) + { + return; + } + + if (reason.equals(Constants.reasonBattleStarts) || + reason.equals(Constants.reasonFled) || + reason.equals(Constants.reasonConcession) ) + { + RevealEvent event; + event = isAttacker ? attackerEventLegion : defenderEventLegion; + + ArrayList rcNames = new ArrayList(); + Iterator it = names.iterator(); + while (it.hasNext()) + { + String name = (String) it.next(); + RevealedCreature rc = new RevealedCreature(name); + rcNames.add(rc); + } + event.updateKnownCreatures(rcNames); + event.setEventInfo(reason); + } + else + { + // perhaps load from history? + Log.error("revealEngagedCreatures, unknown reason " + reason); + } + } List getBattleChits() @@ -1487,11 +1745,23 @@ String name = chit.getId(); if (chit.isInverted()) { - getLegionInfo(defenderMarkerId).removeCreature(name); + LegionInfo info = getLegionInfo(defenderMarkerId); + info.removeCreature(name); + if (board != null) + { + defenderEventLegion.setCreatureDied(name, + info.getHeight()); + } } else { - getLegionInfo(attackerMarkerId).removeCreature(name); + LegionInfo info = getLegionInfo(attackerMarkerId); + info.removeCreature(name); + if (board != null) + { + attackerEventLegion.setCreatureDied(name, + info.getHeight()); + } } } } @@ -2491,9 +2761,9 @@ rc.setDidRecruit(true); rcList.add(rc); } - revealCreatures(markerId, recruiters); + revealCreatures(markerId, recruiters, Constants.reasonRecruiter); } - addCreature(markerId, recruitName); + addCreature(markerId, recruitName, Constants.reasonRecruited); LegionInfo info = getLegionInfo(markerId); info.setRecruited(true); @@ -2518,7 +2788,7 @@ public void undidRecruit(String markerId, String recruitName) { String hexLabel = getHexForLegion(markerId); - removeCreature(markerId, recruitName); + removeCreature(markerId, recruitName, Constants.reasonUndidRecruit); getLegionInfo(markerId).setRecruited(false); if (eventViewer != null) { @@ -3462,7 +3732,9 @@ info.setMoved(true); info.setEntrySide(BattleMap.entrySideNum(entrySide)); - if (teleport) + // old version server does not send the teleportingLord, + // socketCLientThread sets then it to null. + if (teleport && teleportingLord != null) { getLegionInfo(markerId).setTeleported(true); RevealedCreature rc = new RevealedCreature(teleportingLord); @@ -3493,6 +3765,7 @@ removeRecruitChit(currentHexLabel); getLegionInfo(markerId).setHexLabel(currentHexLabel); getLegionInfo(markerId).setMoved(false); + boolean didTeleport = getLegionInfo(markerId).hasTeleported(); getLegionInfo(markerId).setTeleported(false); if (board != null) { @@ -3503,6 +3776,12 @@ { board.disableBottomBarDoneButton(); } + + if (didTeleport && eventViewer != null) + { + eventViewer.undoEvent(RevealEvent.eventTeleport, + markerId, null, turnNumber, null); + } } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EngagementResults.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EngagementResults.java 2007-04-30 19:11:30 UTC (rev 2669) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/EngagementResults.java 2007-04-30 19:23:46 UTC (rev 2670) @@ -26,6 +26,7 @@ import net.sf.colossus.util.KDialog; import net.sf.colossus.util.Options; +import net.sf.colossus.server.Constants; /** @@ -520,17 +521,17 @@ public String getResultText() { String result = "bogus method"; - if (method.equals("flee")) + if (method.equals(Constants.erMethodFlee)) { result = winnerId + " won when " + loserId + " fled and earned " + this.points + " points"; } - else if (method.equals("concede")) + else if (method.equals(Constants.erMethodConcede)) { result = winnerId + " won when " + loserId + " conceded and earned " + this.points + " points"; } - else if (method.equals("negotiate")) + else if (method.equals(Constants.erMethodConcede)) { if (winnerId != null) { @@ -543,7 +544,7 @@ result = "Negotiated mutual elimination"; } } - else if (method.equals("fight")) + else if (method.equals(Constants.erMethodFight)) { if (winnerId != null) { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-04-30 19:11:30 UTC (rev 2669) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-04-30 19:23:46 UTC (rev 2670) @@ -7,10 +7,7 @@ import java.awt.GridLayout; import java.awt.Point; -// import java.awt.event.ActionEvent; -// import java.awt.event.ActionListener; import java.awt.event.ActionEvent; -// import java.awt.event.ActionListener; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -23,23 +20,44 @@ import java.util.Collections; import javax.swing.*; -// import javax.swing.JScrollPane; -// import javax.swing.JTextArea; import javax.swing.BoxLayout; import javax.swing.border.TitledBorder; import net.sf.colossus.util.KDialog; import net.sf.colossus.util.Options; +import net.sf.colossus.util.Log; - /** * Event Revealing dialog. * * It collects all revealed events and displays all or * only the recent ones of them. * - * + * @TODO: + * @IMPORTANT + * - Check compatibility with previous version + * - History: make history events carry the "reason" tag so that reloaded + * games have same event view as in running game + * "TODO: investigate, why does server gives us different turn numbers + * in those Split/undoSplit events?" (=> see undoEvent) + * @Nice to have: + * - Player dead events + * - Legion eliminated (when player dead) events + * - Game over, who wins event :) + * - scale change: own setting, relative to main board scale or absolut? + * react more quickly when scale changed? + * - checkbox "don't show Dead creatures" + * - RevealedCreature could cache the panels + * - combined "battle event" - one bordered panel, containing + * all relevant events ( [teleport?], summon, acquire, won, lost) + * plus text info what now in Engagement result window + * - interface for inspector & Co: for viewMode return info revealed during + * one last turn + * - Engagement won (fled...), instead of "not revealed" show contents + * depending on what the viewMode says + * - "SolidMarker" instead of Titan for mulligan + * * @version $Id: EventViewer.java 2591 2006-01-01 23:41:26Z cleka $ * @author Clemens Katzer */ @@ -47,7 +65,6 @@ final class EventViewer extends KDialog implements WindowListener, ItemListener, ActionListener { - private IOptions options; private boolean visible; @@ -59,6 +76,7 @@ // how long back are they kept (from global settings) private int expireTurns; + private String maxString; private SaveWindow saveWindow; @@ -78,14 +96,15 @@ public static final String evfSummon = "Summon events"; public static final String evfTeleport = "Teleport events"; public static final String evfAcquire = "Acquire events"; - public static final String evfWinner = "Battle won events"; - public static final String evfEliminated = "Battle lost events"; + public static final String evfWon = "Engagement won events"; + public static final String evfLoser = "Engagement lost events"; public static final String evfMulligan = "Mulligans"; public static final String evfTurnChange = "Turn change info"; public static final String evfPlayerChange = "Player change info"; public static final String evAutoScroll = "Auto-scroll to end"; + public static final String evHideUndone = "Hide undone events"; public static final String evMaxTurns = "Maximum number of turns to display"; // boolean flags for them as local flags for quick access: @@ -93,6 +112,7 @@ private boolean[] showEventType; private boolean autoScroll; + private boolean hideUndoneEvents; private JComboBox maxTurnsDisplayExpiringBox; // how many back are currently displayed @@ -123,14 +143,15 @@ showEventType[RevealEvent.eventTeleport] = getBoolOption(evfTeleport, true); showEventType[RevealEvent.eventSummon] = getBoolOption(evfSummon, true); showEventType[RevealEvent.eventAcquire] = getBoolOption(evfAcquire, true); - showEventType[RevealEvent.eventWinner] = getBoolOption(evfWinner, false); - showEventType[RevealEvent.eventEliminated] = getBoolOption(evfEliminated, false); + showEventType[RevealEvent.eventWon] = getBoolOption(evfWon, true); + showEventType[RevealEvent.eventLost] = getBoolOption(evfLoser, true); showEventType[RevealEvent.eventMulligan] = getBoolOption(evfMulligan, true); showEventType[RevealEvent.eventTurnChange] = getBoolOption(evfTurnChange, true); showEventType[RevealEvent.eventPlayerChange] = getBoolOption(evfPlayerChange, false); autoScroll = getBoolOption(evAutoScroll, true); + hideUndoneEvents = getBoolOption(evHideUndone, false); setupGUI(); @@ -156,15 +177,31 @@ String expOption = options.getStringOption(Options.eventExpiring); if (expOption != null) { - int exp = Integer.parseInt(expOption); - if (exp > 0 && exp < 99) + if ( expOption.equals(Options.eventExpiringNever)) { - turnsToKeep = exp; + turnsToKeep = -1; } else { - System.out.println("Invalid value "+exp +" from option "+ - Options.eventExpiring); + int exp; + try + { + exp = Integer.parseInt(expOption); + if (exp > 0 && exp < 9999) + { + turnsToKeep = exp; + } + else + { + Log.error("Invalid value "+exp +" from option '"+ + Options.eventExpiring+"' - using default " + turnsToKeep); + } + } + catch(NumberFormatException e) + { + Log.error("Invalid value "+ expOption +" from option '"+ + Options.eventExpiring + "' - using default " + turnsToKeep); + } } } this.expireTurns = turnsToKeep; @@ -242,11 +279,12 @@ addCheckbox(evfSplit, checkboxPane); addCheckbox(evfSummon, checkboxPane); addCheckbox(evfTeleport, checkboxPane); - // addCheckbox(evfAcquire, checkboxPane); - addCheckbox(evfWinner, checkboxPane); - addCheckbox(evfEliminated, checkboxPane); - checkboxPane.add(new JLabel("NOTE: Teleport events remain in list even if undone.")); + addCheckbox(evfAcquire, checkboxPane); + addCheckbox(evfWon, checkboxPane); + addCheckbox(evfLoser, checkboxPane); checkboxPane.add(Box.createRigidArea(new Dimension(0,5))); + addCheckbox(evHideUndone, checkboxPane); + checkboxPane.add(Box.createRigidArea(new Dimension(0,5))); addCheckbox(evfMulligan, checkboxPane); addCheckbox(evfTurnChange, checkboxPane); @@ -265,23 +303,38 @@ settingsPane.add(Box.createRigidArea(new Dimension(0,5))); addCheckbox(evAutoScroll, miscPane); - miscPane.add(new JLabel("")); + miscPane.add(Box.createRigidArea(new Dimension(0,5))); + // selection for how many turns to display the data // (must be less or equal the expireTurns value set in getPlayers) - String eventExpiringVal = options.getStringOption(Options.eventExpiring); - if ( eventExpiringVal == null ) - { - eventExpiringVal = "1"; - } - int maxVal = Integer.parseInt(eventExpiringVal); + + int maxVal = this.expireTurns == -1 ? 1000 : this.expireTurns; ArrayList alChoices = new ArrayList(); int i; for (i=1 ; i <= maxVal ; i++) { - alChoices.add(new Integer(i).toString()); + // 1, 2, 3, 4, 5, + if (i<=5 || i==maxVal) + { + alChoices.add(new Integer(i).toString()); + } + // 10, 50, 100, 500, 1000 if applicable. + else if (i==10 || i==50 || i==100 || i==500 || i==1000) + { + alChoices.add(new Integer(i).toString()); + } } + if (this.expireTurns == -1) + { + alChoices.add("all"); + } + else + { + maxString = "max (="+this.expireTurns+")"; + alChoices.add(maxString); + } Object[] Choices = alChoices.toArray(); @@ -289,16 +342,44 @@ // general setting. String maxTurnsOptString = options.getStringOption(evMaxTurns); - if ( maxTurnsOptString == null ) + if (maxTurnsOptString == null ) { maxTurnsOptString = "3"; } - int maxTurnsOpt = Integer.parseInt(maxTurnsOptString); - if (maxTurnsOpt > maxVal) + + if (maxTurnsOptString.equals("all") || maxTurnsOptString.startsWith("max")) { - maxTurnsOpt = maxVal; - maxTurnsOptString = new Integer(maxTurnsOpt).toString(); + if (this.expireTurns == -1) + { + maxTurns = -1; + maxTurnsOptString = "all"; + } + else + { + maxTurns = this.expireTurns; + maxTurnsOptString = maxString; + } } + else + { + int maxTurnsOpt = 1; + try + { + maxTurnsOpt = Integer.parseInt(maxTurnsOptString); + if (maxTurnsOpt > maxVal) + { + maxTurnsOpt = maxVal; + maxTurnsOptString = new Integer(maxTurnsOpt).toString(); + } + } + catch(NumberFormatException e) + { + Log.error("Illegal value '"+maxTurnsOptString + "' for option '" + + evMaxTurns + "' - using default 1"); + maxTurnsOptString = "1"; + maxTurnsOpt = 1; + } + } maxTurnsDisplayExpiringBox = new JComboBox(Choices); maxTurnsDisplayExpiringBox.addActionListener(this); @@ -321,25 +402,32 @@ { Container pane = eventPane; - // System.out.println("Adding event panel for event " + e.getEventTypeText()); + Log.debug("Adding event panel for event " + e.getEventTypeText()); int oldEventTurn = e.getTurn(); int oldPlayerNr = e.getPlayerNr(); int type = e.getEventType(); boolean display = true; - if (turnNr-oldEventTurn > maxTurns-(playerNr>=oldPlayerNr?1:0)) + if ( maxTurns != -1 && + turnNr-oldEventTurn > maxTurns-(playerNr>=oldPlayerNr?1:0)) { -// System.out.println("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + +// Log.debug("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + // " - older than max turns value!"); display = false; } else if ( !showEventType[type] ) { -// System.out.println("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + +// Log.debug("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + // " - type " + type + " false."); display = false; } + else if ( hideUndoneEvents && e.wasUndone()) + { + Log.debug("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + + " - was undone and hideUndoneEvents is true."); + display = false; + } if (display) { @@ -351,7 +439,7 @@ } else { - System.out.println("WARNING: EventViewer.addEventToEventPane: event.toPanel returned null!!"); + Log.warn("EventViewer.addEventToEventPane: event.toPanel returned null!"); } } } @@ -425,7 +513,10 @@ this.turnNr = turnNr; this.playerNr = playerNr; - purgeOldEvents(); + if (this.expireTurns != -1) + { + purgeOldEvents(); + } if (this.visible) { updatePanels(); @@ -435,24 +526,14 @@ /* - * User undid one action. - * So far, this deletes that event from the event list and redisplays all. - * - * Better (long term plan/future improvement idea): - * mark as "undone"; if viewMode/Inspector asks for "what do we know" - * the information revealed by the undone event is - * - even if undone - nevertheless "known to the public". As in real life :) - * Until then, we simply remove e.g. Split and Recruit events. - * They are removed, because they have side effect to their legion content. - * Teleport event is not removed (not "necessary", because no side effects, - * and somewhat difficult to detect in client) + * User undid one action. Event is just marked as undone, but not deleted + * - information once revealed is known to the public, as in real life :) */ - public void undoEvent(int type, String parentId, String childId, int turn, String recruitName) + public void undoEvent(int type, String parentId, String childId, int turn, String creatureName) { -// System.out.println("Undoing event "+type+ ": splitoff "+childId+ +// Log.debug("Undoing event "+type+ ": splitoff "+childId+ // ", parent "+parentId+" turn "+turn); - int found = 0; if (type == RevealEvent.eventSplit) { @@ -464,12 +545,13 @@ RevealEvent e = (RevealEvent)it.next(); if (e.getEventType() == type && e.getTurn() == turn && e.getMarkerId().equals(parentId) && - e.getMarkerId2().equals(childId) ) + e.getMarkerId2().equals(childId) && + ! e.wasUndone() ) { - // System.out.println("Split event to be undone found."); + // Log.debug("Split event to be undone found."); found++; - it.remove(); + e.setUndone(true); } } } @@ -490,12 +572,13 @@ RevealEvent e = (RevealEvent)it2.next(); if (e.getEventType() == type && e.getTurn()+1 == turn && e.getMarkerId().equals(parentId) && - e.getMarkerId2().equals(childId) - ) + e.getMarkerId2().equals(childId) && + ! e.wasUndone() ) { - // System.out.println("NOTE: Split event to be undone found only from previous turn!!"); + // Log.debug("NOTE: Split event to be undone found only " + + // "from previous turn!!"); found++; - it2.remove(); + e.setUndone(true); } } } @@ -510,30 +593,70 @@ { RevealEvent e = (RevealEvent)it.next(); if (e.getEventType() == type && e.getTurn() == turn && - e.getMarkerId().equals(parentId) ) + e.getMarkerId().equals(parentId) && + ! e.wasUndone()) { - // System.out.println("Recruit event to be undone found."); + // Log.debug("Recruit event to be undone found."); found++; - it.remove(); + e.setUndone(true); } } } } + else if (type == RevealEvent.eventSummon) + { + synchronized(syncdEventList) + { + Iterator it = syncdEventList.iterator(); + while (it.hasNext()) + { + RevealEvent e = (RevealEvent)it.next(); + if (e.getEventType() == type && e.getTurn() == turn && + e.getMarkerId().equals(parentId) && + ! e.wasUndone()) + { + Log.debug("Recruit event to be undone found."); + found++; + e.setUndone(true); + } + } + } + } + else if (type == RevealEvent.eventTeleport) + { + synchronized(syncdEventList) + { + Iterator it = syncdEventList.iterator(); + while (it.hasNext()) + { + RevealEvent e = (RevealEvent)it.next(); + if (e.getEventType() == type && e.getTurn() == turn && + e.getMarkerId().equals(parentId) && + ! e.wasUndone()) + { + // Log.debug("Teleport event to be undone found."); + found++; + e.setUndone(true); + } + } + } + } + else { - System.out.println("WARNING: undo event for unknown type "+type+" attempted."); + Log.warn("undo event for unknown type "+type+" attempted."); return; } if (found == 0) { - System.out.println("WARNING: '"+type+"' EVENT to undo ("+ + Log.error("Requested '"+type+"' EVENT to undo ("+ parentId+", "+childId+", turn "+turn+") not found"); System.exit(1); } if (found > 1) { - System.out.println("ERROR: '"+type+"' EVENT found " + found + " times!!"); + Log.error("Requested: '"+type+"' EVENT found " + found+" times!"); System.exit(1); } if (this.visible) @@ -547,8 +670,13 @@ */ public void purgeOldEvents() { -// System.out.println("Purging events, if necessary..."); + // Log.debug("Purging events, if necessary..."); + if (this.expireTurns == -1) + { + Log.warn("expireturns -1 - no purgign needed."); + return; + } int purged = 0; synchronized(syncdEventList) @@ -561,13 +689,8 @@ int oldEventTurn = e.getTurn(); int oldPlayerNr = e.getPlayerNr(); -// System.out.println("turn "+turnNr+ "oldTurn "+oldEventTurn+" plNum" + -// playerNr + " oldPlNum "+oldPlayerNr); if (turnNr-oldEventTurn > expireTurns-(playerNr>=oldPlayerNr?1:0)) { -// int oldEventPlayer = e.getPlayerNr(); -// System.out.println("Purging: newest event turn "+turnNr+", player" + playerNr + -// " - purging old event (turn="+oldEventTurn+", player " + oldEventPlayer + ")"); it.remove(); purged++; } @@ -575,7 +698,7 @@ } if (purged > 0) { - // System.out.println("Purged " + purged + " old events."); + // Log.debug("Purged " + purged + " old events."); getContentPane().validate(); } } @@ -627,10 +750,16 @@ { String value = (String) maxTurnsDisplayExpiringBox.getSelectedItem(); options.setOption(evMaxTurns, value); - maxTurns = Integer.parseInt(value); + if (value.equals("all") || value.equals(maxString)) + { + maxTurns = -1; + } + else + { + maxTurns = Integer.parseInt(value); + } updatePanels(); } - } public void itemStateChanged(ItemEvent e) @@ -645,8 +774,12 @@ { this.autoScroll = selected; } + else if (text.equals(evHideUndone)) + { + this.hideUndoneEvents = selected; + } - if (text.equals(evfRecruit)) + else if (text.equals(evfRecruit)) { this.showEventType[RevealEvent.eventRecruit] = selected; } @@ -662,13 +795,13 @@ { this.showEventType[RevealEvent.eventSummon] = selected; } - else if (text.equals(evfWinner)) + else if (text.equals(evfWon)) { - this.showEventType[RevealEvent.eventWinner] = selected; + this.showEventType[RevealEvent.eventWon] = selected; } - else if (text.equals(evfEliminated)) + else if (text.equals(evfLoser)) { - this.showEventType[RevealEvent.eventEliminated] = selected; + this.showEventType[RevealEvent.eventLost] = selected; } else if (text.equals(evfAcquire)) { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2007-04-30 19:11:30 UTC (rev 2669) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2007-04-30 19:23:46 UTC (rev 2670) @@ -38,14 +38,15 @@ public void setLegionStatus(String markerId, boolean moved, boolean teleported, int entrySide, String lastRecruit); - public void addCreature(String markerId, String name); + public void addCreature(String markerId, String name, String reason); - public void removeCreature(String markerId, String name); + public void removeCreature(String markerId, String name, String reason); - public void revealCreatures(String markerId, final List names); + public void revealCreatures(String markerId, final List names, + String reason); public void revealEngagedCreatures(String markerId, final List names, - boolean isAttacker); + boolean isAttacker, String reason); public void removeDeadBattleChits(); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java 2007-04-30 19:11:30 UTC (rev 2669) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java 2007-04-30 19:23:46 UTC (rev 2670) @@ -2,6 +2,7 @@ import java.awt.Component; import java.awt.Dimension; +import java.awt.Color; import java.util.ArrayList; import java.util.Iterator; @@ -9,6 +10,7 @@ import javax.swing.border.TitledBorder; import net.sf.colossus.server.Constants; +import net.sf.colossus.util.Log; public class RevealEvent @@ -21,59 +23,71 @@ private int height; private ArrayList knownCreatures; + // child legion or summoner (for split or summon events) + private String markerId2; + private int height2; + + // for mulligan: private int oldRoll; private int newRoll; - + private String mulliganTitanBaseName; // for titan in place of solid marker + + private boolean undone = false; private int scale; private JPanel p; + private String info; + // set for losing battle events, because if Titan killed the + // marker does already belong to slayer when we ask. + private String realPlayer; public final static int eventSplit = 0; public final static int eventRecruit = 1; public final static int eventSummon = 2; public final static int eventTeleport = 3; public final static int eventAcquire = 4; - public final static int eventWinner = 5; - public final static int eventEliminated = 6; + public final static int eventWon = 5; + public final static int eventLost = 6; public final static int eventTurnChange = 7; public final static int eventPlayerChange = 8; public final static int eventMulligan = 9; + // Battle is only a temporary state, before it becomes Won or Lost + // ( = no filter / checkbox setting for that needed, so far at least...) + public final static int eventBattle = 10; private final static String eventSplitText = "Split"; private final static String eventRecruitText = "Recruit"; private final static String eventSummonText = "Summon"; private final static String eventTeleportText = "Teleport"; private final static String eventAcquireText = "Acquire"; - private final static String eventWinnerText = "Winner"; - private final static String eventEliminatedText = "Eliminated"; + private final static String eventWonText = "Winner"; + private final static String eventLostText = "Lost"; private final static String eventTurnChangeText = "TurnChange"; private final static String eventPlayerChangeText = "PlayerChange"; private final static String eventMulliganText = "Mulligan"; + private final static String eventBattleText = "Battle"; private static String[] eventTypeToString = { eventSplitText, eventRecruitText, eventSummonText, eventTeleportText, - eventAcquireText, eventWinnerText, eventEliminatedText, - eventTurnChangeText, eventPlayerChangeText, eventMulliganText + eventAcquireText, eventWonText, eventLostText, eventTurnChangeText, + eventPlayerChangeText, eventMulliganText, eventBattleText }; - - - // child legion or summoner: - private String markerId2; - private int height2; - - - public RevealEvent(Client client, int turnNumber, int playerNr, int eventType, - String markerId, int height, ArrayList knownCreatures, - String markerId2, int height2) + + public RevealEvent(Client client, int turnNumber, int playerNr, + int eventType, String markerId, int height, ArrayList + knownCreatures, String markerId2, int height2) { - if (markerId == null && eventType != eventPlayerChange && eventType != eventTurnChange) + if (markerId == null && eventType != eventPlayerChange && + eventType != eventTurnChange) { - System.out.println("ERROR: null marker for event "+getEventTypeText(eventType)); + Log.error("ERROR: null marker for event " + + getEventTypeText(eventType)); return; } this.client = client; this.turnNumber = turnNumber; + // Number of the player in whose turn this event happens. this.playerNr = playerNr; this.eventType = eventType; // affected legion; split: parent; summon: donor @@ -84,7 +98,7 @@ this.markerId2 = markerId2; this.height2 = height2; - // System.out.println("NEW RevealEvent: "+this.toString()); + makeCreaturesTitanChangeSafe(knownCreatures); } // mulligan @@ -98,9 +112,197 @@ this.oldRoll = oldRoll; this.newRoll = newRoll; + + PlayerInfo info = client.getPlayerInfo(playerNr); + this.mulliganTitanBaseName = getTitanBasename(info); } + /* + * if there is a Titan in this legion, then nail down it's + * titanBaseName of the time when this happened. + * Called also after battle to update to new power after + * points were rewarded. + */ + private void makeCreaturesTitanChangeSafe(ArrayList list) + { + if (list == null || list.isEmpty()) + { + return; + } + + Iterator it = list.iterator(); + while (it.hasNext()) + { + RevealedCreature rc = (RevealedCreature) it.next(); + if (rc != null && rc.getPlainName() != null && + rc.getPlainName().equals(Constants.titan)) + { + String playerName = (realPlayer != null ? realPlayer : + client.getPlayerNameByMarkerId(markerId)); + + if (playerName == null) + { + Log.error("For making titan base name: " + + "playerName is null!"); + } + else + { + PlayerInfo info = client.getPlayerInfo(playerName); + String tbName = getTitanBasename(info); + rc.setTitanBaseName(tbName); + } + } + } + } + + // only for Engagement events, to set it afterwards to Winner or Loser + public void setEventType(int eventType) + { + this.eventType = eventType; + // if battle winner, re-trigger the setting titanbasename(s) + // because his power has changed. + if (eventType == RevealEvent.eventWon) + { + makeCreaturesTitanChangeSafe(knownCreatures); + } + } + public void setEventInfo(String info) + { + this.info = info; + } + + public void setRealPlayer(String realPlayer) + { + this.realPlayer = realPlayer; + if (this.realPlayer == null) + { + Log.error("RevealEvent: give realPlayer is null!"); + this.realPlayer = "dummy?"; + } + } + + public void setUndone(boolean undone) + { + this.undone = undone; + } + + public boolean wasUndone() + { + return this.undone; + } + + public void setAllDead() + { + Iterator it = this.knownCreatures.iterator(); + while (it.hasNext()) + { + RevealedCreature rc = (RevealedCreature) it.next(); + rc.setDead(true); + } + height = 0; + } + + public int getAliveCount() + { + int alive = 0; + Iterator it = this.knownCreatures.iterator(); + while (it.hasNext()) + { + RevealedCreature rc = (RevealedCreature) it.next(); + if (!rc.isDead()) + { + alive++; + } + } + return alive; + } + + public int getDeadCount() + { + int dead = 0; + Iterator it = this.knownCreatures.iterator(); + while (it.hasNext()) + { + RevealedCreature rc = (RevealedCreature) it.next(); + if (rc.isDead()) + { + dead++; + } + } + return dead; + } + + // so far I don't know any event in which Titan would be added, + // thus we don't need to make them TitanSafe here. + public void addCreature(RevealedCreature rc) + { + knownCreatures.add(rc); + height++; + } + + // creatures were revealed some while after event was created. + // E.g. engagements. + public void updateKnownCreatures(ArrayList revealedCreatures) + { + this.knownCreatures = revealedCreatures; + makeCreaturesTitanChangeSafe(knownCreatures); + this.height = knownCreatures.size(); + } + + public void setCreatureDied(String name, int newHeight) + { + Iterator it = this.knownCreatures.iterator(); + boolean done = false; + while (!done && it.hasNext()) + { + RevealedCreature rc = (RevealedCreature) it.next(); + if (rc.matches(name) && !rc.isDead()) + { + rc.setDead(true); + done = true; + } + } + if (!done) + { + if (name.startsWith("Titan-")) + { + // never mind. Whole legion is already gone. + } + else + { + Log.warn("got order to kill creature " + + name + " in legionEvent " + this.toString() + + " but no such alive creature found!!"); + } + } + // client tells us new accurate count how many are still alive. + height = newHeight; + } + + // undo the summoning of the angel to this battle event legion + // (when angel was left off board). + public boolean undoSummon(int turnNumber, String name) + { + if (turnNumber != this.turnNumber) + { + Log.warn("undoSummon for " + this.toString() + " -- wrong turn."); + return false; + } + Iterator it = this.knownCreatures.iterator(); + boolean done = false; + while (!done && it.hasNext()) + { + RevealedCreature rc = (RevealedCreature) it.next(); + if (rc.matches(name) && rc.wasSummoned()) + { + it.remove(); + done = true; + } + } + return done; + } + public int getEventType() { return eventType; @@ -126,6 +328,11 @@ return markerId2; } + public int getHeight() + { + return height; + } + public int getTurn() { return turnNumber; @@ -152,7 +359,8 @@ } else if (eventType == eventSummon) { - RevealedCreature rc = (RevealedCreature) this.knownCreatures.get(0); + RevealedCreature rc = + (RevealedCreature) this.knownCreatures.get(0); String summoned = rc.getName(); msg = "Revealing event: \"" + getEventTypeText() + "\":\n" + @@ -160,16 +368,21 @@ "(" + height + ") to " + markerId2 + "("+height2+")"; } - else if (eventType == eventWinner) + else if (eventType == eventWon) { - msg = "Revealing event: Winner = "+markerId; + msg = "Revealing event: " + markerId + " won"; } - else if (eventType == eventEliminated) + else if (eventType == eventLost) { - msg = "Revealing event: Eliminated = "+markerId; + msg = "Revealing event: " + markerId + " lost"; } + else if (eventType == eventBattle) + { + msg = "Revealing event: " + markerId + " battle starts"; + } + else if (eventType == eventTurnChange) { msg = "Revealing event: Turn change, now player "+getPlayerNr()+ @@ -191,7 +404,8 @@ { StringBuffer msgBuf = new StringBuffer(1000); - msgBuf.append("Revealing event: \"" + getEventTypeText() + "\" for marker " + markerId + "\n"); + msgBuf.append("Revealing event: \"" + getEventTypeText() + + "\" for marker " + markerId + "\n"); Iterator it = knownCreatures.iterator(); int i = 0; @@ -200,9 +414,9 @@ i++; RevealedCreature rc = (RevealedCreature)it.next(); msgBuf.append(i + ". " + rc.toString()+"\n"); - // System.out.println(i + ". " + rc.toDetails()); } - msgBuf.append(" => legion " + markerId + " now " + height + " creatures."); + msgBuf.append(" => legion " + markerId + " now " + height + + " creatures."); msg = msgBuf.toString(); } @@ -217,11 +431,12 @@ } // Todo: paint height on top of marker possible? - private void addMarker(String markerId) + private void addMarker(String markerId, int height) { if (markerId == null) { - System.out.println("ERROR: markerId null, event type "+getEventTypeText()+" turn" +getTurn()); + Log.error("ERROR: markerId null, event type " + + getEventTypeText()+" turn" +getTurn()); } try { @@ -231,38 +446,42 @@ } catch(Exception e) { - System.out.println("\n\nCATCH: ERROR: markerId null, event type "+ - getEventTypeText()+" turn" +getTurn()); + Log.error("new Chit for markerId " + markerId + ", event type "+ + getEventTypeText() + " turn" + getTurn() + " threw exception:" + + e.toString()); }; - + addLabel("("+height+")"); } // TODO duplicated from LegionInfo.java: /** Return the full basename for a titan in legion markerId, * first finding that legion's player, player color, and titan size. * Default to Constants.titan if the info is not there. */ - String getTitanBasename() + String getTitanBasename(PlayerInfo info) { try { - PlayerInfo info = client.getPlayerInfo(playerNr); String color = info.getColor(); int power = info.getTitanPower(); return "Titan-" + power + "-" + color; } catch (Exception ex) { + Log.error("RevealEvent.gettitanbasename, PlayerInfo threw " + + "exception " + ex.toString()); return Constants.titan; } } + // NOTE: this assumes that this event is for the player in whose + // turn this happens: private C... [truncated message content] |
From: <cl...@us...> - 2007-05-04 19:54:46
|
Revision: 2677 http://svn.sourceforge.net/colossus/?rev=2677&view=rev Author: cleka Date: 2007-05-04 12:54:45 -0700 (Fri, 04 May 2007) Log Message: ----------- Eliminate the can't get InputStream warnings for README and MarkersName files for remote clients. Partly temporary solution/hack: server now understands the ignoreFail flag (and just auto-sets ignore flag hardcoded for README and MarkersName); take this ignore feature for remote file into use in clients in next or overnext public build, when "noone" uses old server any more. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/FileServerThread.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java 2007-05-04 19:34:08 UTC (rev 2676) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java 2007-05-04 19:54:45 UTC (rev 2677) @@ -347,6 +347,7 @@ /** XXX If any of the args in the protocol contain this string, then * the protocol will break. */ public static final String protocolTermSeparator = " ~ "; + public static final String fileServerIgnoreFailSignal = "~/~Ignore-Fail~/~"; // From client to server public static final String signOn = "signOn"; Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/FileServerThread.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/FileServerThread.java 2007-05-04 19:34:08 UTC (rev 2676) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/FileServerThread.java 2007-05-04 19:54:45 UTC (rev 2677) @@ -82,15 +82,44 @@ Log.debug("Serving request " + request + " from " + fileClient); + + boolean ignoreFail = false; List li = Split.split(sep, request); String filename = (String)li.remove(0); + + // right now (05/2007) clients should not send this - + // take into use somewhat later. + if (filename.equals(Constants.fileServerIgnoreFailSignal)) + { + ignoreFail = true; + filename = (String)li.remove(0); + } + // Meanwhile, suppress the warnings at least for the README + // and the markersFile... + // we know that they usually print warnings for other + // than "Default" dir. + + // @TODO: e.g. when the overnext public build is out + // (the one right now (20.4.2007) does not contain this yet), + // make the client one day submit the ignorefail signal, + // and remove this markersFileName/README temporary hack. + if (filename.startsWith(Constants.markersNameFile) || + filename.startsWith("README") ) + { + ignoreFail = true; + } + byte[] data = ResourceLoader.getBytesFromFile(filename, li, - true); + true, ignoreFail); - os.write(data); + if (data != null) + { + os.write(data); + } + // else we just write nothing. } else { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2007-05-04 19:34:08 UTC (rev 2676) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2007-05-04 19:54:45 UTC (rev 2677) @@ -445,8 +445,11 @@ if ((cached == null) && cachedOnly) { - Log.warn("Requested file " + filename + - " is requested cached-only but is not is cache."); + if (!ignoreFail) + { + Log.warn("Requested file " + filename + + " is requested cached-only but is not is cache."); + } return null; } @@ -477,6 +480,16 @@ } if (stream == null) { + if (!remote && ignoreFail) + { + // If someone locally requests it as ignoreFail, + // let's assume a remote requester later sees it the + // same way. + // Right now, the remote-requesting is not able to + // submit the "ignore-fail" property... + // @TODO: submit that properly? + // fileCacheIgnoreFail.put(mapKey, new Boolean(true)); + } if (!ignoreFail) { Log.warn("getInputStream:: " + @@ -523,6 +536,15 @@ PrintWriter out = new PrintWriter(fileSocket.getOutputStream(), true); + + if (ignoreFail) + { + // Not in this version yet (05/2007). + // New clients could not talk with old server. + // Take this into full use somewhat later. + //out.print( + // Constants.fileServerIgnoreFailSignal + sep); + } out.print(filename); java.util.Iterator it = directories.iterator(); while (it.hasNext()) @@ -531,6 +553,13 @@ } out.println(); data = getBytesFromInputStream(is); + if ( data != null && data.length == 0 && + !ignoreFail) + { + Log.warn("Got empty contents for file " + + filename + " directories " + + directories.toString()); + } fileSocket.close(); fileCache.put(mapKey, data); } @@ -556,17 +585,20 @@ * or null if it fails. */ public static byte[] getBytesFromFile(String filename, - List directories, - boolean cachedOnly) + List directories, boolean cachedOnly, boolean ignoreFail) { InputStream is = getInputStream(filename, directories, - server != null, cachedOnly, false); + server != null, cachedOnly, ignoreFail); if (is == null) { - Log.warn("getBytesFromFile:: " + - " Couldn't get InputStream for file " + - filename + " in " + directories + - (cachedOnly ? " (cached only)" : "")); + // right now only FileServerThread is using this method at all. + if (!ignoreFail) + { + Log.warn("getBytesFromFile:: " + + " Couldn't get InputStream for file " + + filename + " in " + directories + + (cachedOnly ? " (cached only)" : "")); + } return null; } return getBytesFromInputStream(is); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-05-26 11:02:41
|
Revision: 2678 http://svn.sourceforge.net/colossus/?rev=2678&view=rev Author: cleka Date: 2007-05-26 04:02:38 -0700 (Sat, 26 May 2007) Log Message: ----------- Unlimited mulligans (as proposed by PeterBecker weeks ago). Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-05-04 19:54:45 UTC (rev 2677) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-05-26 11:02:38 UTC (rev 2678) @@ -160,6 +160,7 @@ addCheckbox(Options.cumulativeSlow, rulesOptionsPane); addCheckbox(Options.oneHexAllowed, rulesOptionsPane); addCheckbox(Options.nonRandomBattleDice, rulesOptionsPane); + addCheckbox(Options.unlimitedMulligans, rulesOptionsPane); JPanel aiTimePane = new JPanel(new FlowLayout()); aiTimePane.setBorder(new TitledBorder("AI Timing")); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java 2007-05-04 19:54:45 UTC (rev 2677) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Player.java 2007-05-26 11:02:38 UTC (rev 2678) @@ -5,6 +5,7 @@ import net.sf.colossus.util.Log; import net.sf.colossus.util.Glob; +import net.sf.colossus.util.Options; import net.sf.colossus.xmlparser.TerrainRecruitLoader; @@ -489,7 +490,10 @@ { undoAllMoves(); Log.event(getName() + " takes a mulligan"); - mulligansLeft--; + if(!game.getOption(Options.unlimitedMulligans)) + { + mulligansLeft--; + } movementRoll = 0; } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2007-05-04 19:54:45 UTC (rev 2677) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2007-05-26 11:02:38 UTC (rev 2678) @@ -1326,7 +1326,10 @@ player.commitMoves(); // Mulligans are only allowed on turn 1. - player.setMulligansLeft(0); + if(!game.getOption(Options.unlimitedMulligans)) + { + player.setMulligansLeft(0); + } game.advancePhase(Constants.Phase.MUSTER, getPlayerName()); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-05-04 19:54:45 UTC (rev 2677) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-05-26 11:02:38 UTC (rev 2678) @@ -82,6 +82,8 @@ "Tower-to-Tower Teleport only"; public static final String noTowerTeleport = "No Tower Teleport"; public static final String noTitanTeleport = "No Titan Teleport"; + + public static final String unlimitedMulligans = "Unlimited Mulligans"; // Display options (client only) public static final String useSVG = "Use SVG chits"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-05-26 13:59:00
|
Revision: 2686 http://svn.sourceforge.net/colossus/?rev=2686&view=rev Author: cleka Date: 2007-05-26 06:58:55 -0700 (Sat, 26 May 2007) Log Message: ----------- Make the -m actually work (set as selected item in GetPlayers and/or assign when direct start) Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/StartClient.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Start.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/StartClient.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/StartClient.java 2007-05-26 12:23:08 UTC (rev 2685) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/StartClient.java 2007-05-26 13:58:55 UTC (rev 2686) @@ -62,6 +62,7 @@ nameBox = new JComboBox(new Vector(nameChoices)); nameBox.setEditable(true); nameBox.addActionListener(this); + nameBox.setSelectedItem(playerName); getContentPane().add(nameBox); getContentPane().add(new JLabel("Server hostname")); Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-05-26 12:23:08 UTC (rev 2685) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GetPlayers.java 2007-05-26 13:58:55 UTC (rev 2686) @@ -324,16 +324,24 @@ playerType.setEnabled(false); playerTypes[i] = playerType; + String cmdlineName = options.getStringOption(Options.playerName); String name = options.getStringOption(Options.playerName + i); - if (name == null || name.length() == 0) + if (cmdlineName != null) { + name = cmdlineName; + } + else if (name == null || name.length() == 0) + { name = Constants.none; } - if (name.startsWith(Constants.byColor)) + else if (name.startsWith(Constants.byColor)) { name = Constants.byColor; } - + else if (name.startsWith(Constants.byType)) + { + name = Constants.byType; + } Vector nameChoices = new Vector(); nameChoices.add(name); if (!nameChoices.contains(Constants.byColor)) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Start.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Start.java 2007-05-26 12:23:08 UTC (rev 2685) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Start.java 2007-05-26 13:58:55 UTC (rev 2686) @@ -203,8 +203,12 @@ for (int i = 0; i < numHumans; i++) { String name = null; - if (i == 0) + if ( i == 0 && cl.optIsSet('m')) { + name = cl.getOptValue('m'); + } + else if (i == 0) + { name = Constants.username; } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-05-29 21:31:43
|
Revision: 2691 http://svn.sourceforge.net/colossus/?rev=2691&view=rev Author: cleka Date: 2007-05-29 14:31:34 -0700 (Tue, 29 May 2007) Log Message: ----------- Improvements related to EventViewer performance issues. Max expireTurns now 10 ("never" still allowed); EventViewer keeps a bookmark from where to search in the list, and does not redo updatePanels if not necessary at all. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-05-26 14:55:57 UTC (rev 2690) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-05-29 21:31:34 UTC (rev 2691) @@ -42,6 +42,9 @@ * games have same event view as in running game * "TODO: investigate, why does server gives us different turn numbers * in those Split/undoSplit events?" (=> see undoEvent) + * When fled, instead of "not revealed": at least if involved in battle + * (winner or defeated) should show the winner's content! + * * @Nice to have: * - Player dead events * - Legion eliminated (when player dead) events @@ -321,8 +324,11 @@ { alChoices.add(new Integer(i).toString()); } + /* right now: no big values due to performance issues... // 10, 50, 100, 500, 1000 if applicable. else if (i==10 || i==50 || i==100 || i==500 || i==1000) + */ + else if (i==10) { alChoices.add(new Integer(i).toString()); } @@ -398,25 +404,28 @@ this.pack(); } + private boolean isEventTooOld(RevealEvent e) + { + int oldEventTurn = e.getTurn(); + int oldPlayerNr = e.getPlayerNr(); + if ( maxTurns != -1 && + turnNr-oldEventTurn > maxTurns-(playerNr>=oldPlayerNr?1:0)) + { +// Log.debug("Not displaying event "+e.getEventTypeText()+" "+ +// e.getMarkerId() + " - older than max turns value!"); + return true; + } + return false; + } + private boolean isEventRelevant(RevealEvent e) { - Log.debug("Adding event panel for event " + e.getEventTypeText()); - - int oldEventTurn = e.getTurn(); - int oldPlayerNr = e.getPlayerNr(); int type = e.getEventType(); boolean display = true; - if ( maxTurns != -1 && - turnNr-oldEventTurn > maxTurns-(playerNr>=oldPlayerNr?1:0)) + if ( !showEventType[type] ) { -// Log.debug("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + -// " - older than max turns value!"); - display = false; - } - else if ( !showEventType[type] ) - { // Log.debug("Not displaying event "+e.getEventTypeText()+" "+e.getMarkerId() + // " - type " + type + " false."); display = false; @@ -475,8 +484,13 @@ /* * Remove all, and add those again which are still in the eventList + * @param forceAll: reset the bookmark, start from begin of list. + * => if not set, can start searching from last + * remembered position. */ - private void updatePanels() + private static int bookmark = 0; + + private void updatePanels(boolean forceAll) { Container pane = this.eventPane; @@ -484,26 +498,36 @@ synchronized(syncdEventList) { - // @TODO: one day, remove this i++ and relevant++ stuff, - // when the updatePanels code is ready / properly transformed - // into the invokeLater form etc. ... - // int i = 0; - // int relevant = 0; - Iterator it = syncdEventList.iterator(); + // if never expires, we never delete, so bookmark stays ok. + // But if expiring is happening (!= -1) or force is given + // (e.g. when maxTurns changed) then need to start searching + // from start. + if (this.expireTurns != -1 || forceAll) + { + bookmark = 0; + } + + if (bookmark > syncdEventList.size()) + { + // sanity check... + Log.error("bookmark " + bookmark + " out of range, size=" + + syncdEventList.size()); + bookmark = 0; + } + + ListIterator it = syncdEventList.listIterator(bookmark); while (it.hasNext()) { RevealEvent e = (RevealEvent) it.next(); - boolean display = isEventRelevant(e); - if (display) + if (isEventTooOld(e)) { + bookmark++; + } + else if (isEventRelevant(e)) + { addEventToEventPane(e); - // relevant++; } - // i++; } - - // System.out.println("updatePanels needed " + i + - // " iterations, " + relevant + " relevant"); } getContentPane().validate(); @@ -535,10 +559,21 @@ if (this.expireTurns != -1) { purgeOldEvents(); + if (this.visible) + { + updatePanels(true); + } } - if (this.visible) + else // expire turns -1 ==> no purging. { - updatePanels(); + if (this.maxTurns != -1) + { + // something will have got expired now + // but we can use the bookmark. + updatePanels(false); + } + // else: maxTurns -1 => stays displaying from begin on, + // so no update needed at all. } } @@ -683,7 +718,7 @@ if (this.visible) { - updatePanels(); + updatePanels(false); } } @@ -696,7 +731,7 @@ if (this.expireTurns == -1) { - Log.warn("expireturns -1 - no purgign needed."); + Log.warn("expireTurns -1 - no purging needed."); return; } int purged = 0; @@ -704,17 +739,8 @@ synchronized(syncdEventList) { Iterator it = syncdEventList.iterator(); - StringBuffer DebugBuf = new StringBuffer(200); - DebugBuf.append("purging: "); - String state = "init"; - - // @TODO: loop could stop after first not-to-purge one is found; - // For now, build a check that verifies that this really never - // breaks. - // @TODO-SOMEDAY: - // One day, either make this become permanent or remove this - // experimental/trial code. - while (it.hasNext()) + boolean done = false; + while (it.hasNext() && !done) { RevealEvent e = (RevealEvent)it.next(); int oldEventTurn = e.getTurn(); @@ -724,27 +750,13 @@ { it.remove(); purged++; - DebugBuf.append("P"); - if (state.equals("over")) - { - System.out.println("WARNING: found one event to purge, even after" + - " found one that is not to purge?"); - System.out.println(DebugBuf.toString()); - } - state = "found"; } else { - DebugBuf.append("-"); - state = "over"; + done = true; } } } - if (purged > 0) - { - // Log.debug("Purged " + purged + " old events."); - getContentPane().validate(); - } } public void cleanup() @@ -776,7 +788,7 @@ settingsPane.setMinimumSize(settingsPane.getSize()); // eventPane.setMinimumSize(eventPane.getSize()); this.visible = true; - updatePanels(); + updatePanels(true); } else { @@ -802,7 +814,7 @@ { maxTurns = Integer.parseInt(value); } - updatePanels(); + updatePanels(true); } } @@ -864,6 +876,6 @@ this.showEventType[RevealEvent.eventPlayerChange] = selected; } - updatePanels(); + updatePanels(false); } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-05-26 14:55:57 UTC (rev 2690) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-05-29 21:31:34 UTC (rev 2691) @@ -62,7 +62,7 @@ public static final String eventExpiringNever = "never"; public static final String[] eventExpiringChoices = { - "1", "2", "5", "10", "50", eventExpiringNever + "1", "2", "5", "10", eventExpiringNever }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-07-12 20:26:35
|
Revision: 2701 http://svn.sourceforge.net/colossus/?rev=2701&view=rev Author: cleka Date: 2007-07-12 13:26:33 -0700 (Thu, 12 Jul 2007) Log Message: ----------- Replaced boolean "Show all recruit chits" with the four different possibilities "None, Strongest, Recruit Hint, All". Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-07-11 21:10:33 UTC (rev 2700) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-07-12 20:26:33 UTC (rev 2701) @@ -169,6 +169,7 @@ private LogWindow logWindow; private int viewMode; + private int recruitChitMode; public Client(String host, int port, String playerName, boolean remote) { @@ -201,6 +202,26 @@ String viewModeName = options.getStringOption(Options.viewMode); viewMode = options.getNumberForViewMode(viewModeName); + + String rcMode = options.getStringOption(Options.showRecruitChitsSubmenu); + if(rcMode == null || rcMode.equals("")) + { + // not set: convert from old "showAllRecruitChits" option + boolean showAll = options.getOption(Options.showAllRecruitChits); + if (showAll) + { + rcMode = Options.showRecruitChitsAll; + } + else + { + rcMode = Options.showRecruitChitsStrongest; + } + // initialize new option + options.setOption(Options.showRecruitChitsSubmenu, rcMode); + // clean up obsolete option from cfg file + options.removeOption(Options.showAllRecruitChits); + } + recruitChitMode = options.getNumberForRecruitChitSelection(rcMode); } boolean isRemote() @@ -761,6 +782,11 @@ return this.viewMode; } + public int getRecruitChitMode() + { + return this.recruitChitMode; + } + /** Fully sync the board state by running all option triggers. */ private void runAllOptionTriggers() { @@ -797,6 +823,10 @@ { showAllRecruitChits = bval; } + else if (optname.equals(Options.showRecruitChitsSubmenu)) + { + recruitChitMode = options.getNumberForRecruitChitSelection(value); + } else if (optname.equals(Options.noBaseColor)) { Creature.setNoBaseColor(bval); @@ -992,7 +1022,6 @@ { PlayerInfo info = new PlayerInfo(this); playerInfo[i] = info; - String name = info.getName(); } } for (int i = 0; i < numPlayers; i++) @@ -1962,23 +1991,42 @@ { clearPossibleRecruitChits(); + if (recruitChitMode == Options.showRecruitChitsNumNone) + { + return; + } + // set is a set of possible target hexes + List oneElemList = new ArrayList(); + Iterator it = set.iterator(); while (it.hasNext()) { String hexLabel = (String)it.next(); List recruits = findEligibleRecruits(markerId, hexLabel); + if (recruits != null && recruits.size() > 0) { - if (!showAllRecruitChits) - { - List oneElemList = new ArrayList(); - Creature recruit = chooseBestPotentialRecruit(markerId, + switch(recruitChitMode) + { + case Options.showRecruitChitsNumAll: + break; + case Options.showRecruitChitsNumRecruitHint: + oneElemList.clear(); + Creature hint = chooseBestPotentialRecruit(markerId, hexLabel, recruits); - oneElemList.add(recruit); + oneElemList.add(hint); recruits = oneElemList; - } - addPossibleRecruitChits(recruits, hexLabel); + break; + case Options.showRecruitChitsNumStrongest: + oneElemList.clear(); + Creature strongest = + (Creature) recruits.get(recruits.size() - 1); + oneElemList.add(strongest); + recruits = oneElemList; + break; + } + addPossibleRecruitChits(recruits, hexLabel); } } } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-07-11 21:10:33 UTC (rev 2700) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-07-12 20:26:33 UTC (rev 2701) @@ -37,6 +37,8 @@ import javax.swing.AbstractAction; import javax.swing.JButton; +import javax.swing.ButtonGroup; +import javax.swing.JRadioButtonMenuItem; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFileChooser; import javax.swing.JFrame; @@ -712,6 +714,23 @@ checkboxes.put(name, cbmi); } + private ItemListener rcmHandler = new MasterBoardRecruitChitMenuHandler(); + + private void addRadioButton(JMenu menu, ButtonGroup group, String name) + { + JRadioButtonMenuItem rbmi = new JRadioButtonMenuItem(name); + rbmi.addItemListener(rcmHandler); + group.add(rbmi); + menu.add(rbmi); + boolean selected = false; + if (name.equals( + client.getStringOption(Options.showRecruitChitsSubmenu))) + { + selected = true; + } + rbmi.setSelected(selected); + } + private void setupTopMenu() { JMenuBar menuBar = new JMenuBar(); @@ -784,7 +803,16 @@ addCheckBox(graphicsMenu, Options.noBaseColor, KeyEvent.VK_W); addCheckBox(graphicsMenu, Options.useColoredBorders, 0); addCheckBox(graphicsMenu, Options.doNotInvertDefender, 0); - addCheckBox(graphicsMenu, Options.showAllRecruitChits, 0); + + // addCheckBox(graphicsMenu, Options.showAllRecruitChits, 0); + JMenu srcSubmenu = new JMenu(Options.showRecruitChitsSubmenu); + ButtonGroup group = new ButtonGroup(); + addRadioButton(srcSubmenu, group, Options.showRecruitChitsNone); + addRadioButton(srcSubmenu, group, Options.showRecruitChitsStrongest); + addRadioButton(srcSubmenu, group, Options.showRecruitChitsRecruitHint); + addRadioButton(srcSubmenu, group, Options.showRecruitChitsAll); + graphicsMenu.add(srcSubmenu); + // change scale mi = graphicsMenu.add(changeScaleAction); mi.setMnemonic(KeyEvent.VK_S); @@ -2133,6 +2161,19 @@ } } + class MasterBoardRecruitChitMenuHandler implements ItemListener + { + public void itemStateChanged(ItemEvent e) + { + JMenuItem source = (JMenuItem)e.getSource(); + String text = source.getText(); + boolean selected = (e.getStateChange() == ItemEvent.SELECTED); + if (selected && text != null) + { + client.setOption(Options.showRecruitChitsSubmenu, text); + } + } + } class MasterBoardWindowHandler extends WindowAdapter { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-07-11 21:10:33 UTC (rev 2700) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/Options.java 2007-07-12 20:26:33 UTC (rev 2701) @@ -102,6 +102,17 @@ public static final String doNotInvertDefender = "Do not invert defender's Battle Chits"; public static final String showAllRecruitChits = "Show all recruit Chits"; + public static final String showRecruitChitsSubmenu = "Show recruit preview chits..."; + public static final String showRecruitChitsNone = "None"; + public static final String showRecruitChitsStrongest = "Strongest"; + public static final String showRecruitChitsRecruitHint = "Recruit Hint"; + public static final String showRecruitChitsAll = "All"; + + public static final int showRecruitChitsNumNone = 0; + public static final int showRecruitChitsNumStrongest = 1; + public static final int showRecruitChitsNumRecruitHint = 2; + public static final int showRecruitChitsNumAll = 3; + public static final String antialias = "Antialias"; public static final String scale = "Scale"; @@ -311,4 +322,25 @@ return val; } + // client compares then only numeric modes (easier and faster in runtime) + // ((can use switch case statement)) + public int getNumberForRecruitChitSelection(String s) + { + if (s == null || s.equals("")) + { + return Options.showRecruitChitsNumNone; + } + + int val = Options.showRecruitChitsNumAll; + if (s.equals(Options.showRecruitChitsNone)) + val = Options.showRecruitChitsNumNone; + if (s.equals(Options.showRecruitChitsStrongest)) + val = Options.showRecruitChitsNumStrongest; + if (s.equals(Options.showRecruitChitsRecruitHint)) + val = Options.showRecruitChitsNumRecruitHint; + if (s.equals(Options.showRecruitChitsAll)) + val = Options.showRecruitChitsNumAll; + return val; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-10-04 20:01:40
|
Revision: 2718 http://colossus.svn.sourceforge.net/colossus/?rev=2718&view=rev Author: cleka Date: 2007-10-04 13:01:39 -0700 (Thu, 04 Oct 2007) Log Message: ----------- When a battle was lost by time loss, Engagement results and EventViewer did tell so. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/EngagementResults.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-10-04 19:32:35 UTC (rev 2717) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2007-10-04 20:01:39 UTC (rev 2718) @@ -376,7 +376,7 @@ RevealEvent loserLegion; public void tellEngagementResultsEventHandling( - String winnerId, String method) + String winnerId, String method, int turns) { // if those are not set, we are new version client with old // version server, who does not provide the reason argument @@ -440,6 +440,10 @@ // thus make sure they are really shown dead. loserLegion.setAllDead(); loserLegion.setEventType(RevealEvent.eventLost); + if (turns > 7) + { + method = Constants.erMethodTimeLoss; + } loserLegion.setEventInfo(method); eventViewer.addEvent(loserLegion); @@ -480,7 +484,7 @@ return; } - tellEngagementResultsEventHandling(winnerId, method); + tellEngagementResultsEventHandling(winnerId, method, turns); if (getOption(Options.showEngagementResults)) { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EngagementResults.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EngagementResults.java 2007-10-04 19:32:35 UTC (rev 2717) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/EngagementResults.java 2007-10-04 20:01:39 UTC (rev 2718) @@ -548,8 +548,16 @@ { if (winnerId != null) { - result = winnerId + " won the battle in " + this.turns + - " turns and earned " + this.points + " points"; + if (turns > 7) + { + result = winnerId + " won the battle by time loss" + + " and earned " + this.points + " points"; + } + else + { + result = winnerId + " won the battle in " + this.turns + + " turns and earned " + this.points + " points"; + } } else { Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java 2007-10-04 19:32:35 UTC (rev 2717) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java 2007-10-04 20:01:39 UTC (rev 2718) @@ -645,6 +645,10 @@ { eventTypeText = "Conceded: "; } + else if (info.equals(Constants.erMethodTimeLoss)) + { + eventTypeText = "Time loss: "; + } else if (info.equals(Constants.erMethodNegotiate)) { eventTypeText = "Negotiated: "; Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java 2007-10-04 19:32:35 UTC (rev 2717) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Constants.java 2007-10-04 20:01:39 UTC (rev 2718) @@ -468,6 +468,7 @@ public static final String erMethodFlee = "flee"; public static final String erMethodConcede = "concede"; public static final String erMethodFight = "fight"; + public static final String erMethodTimeLoss = "timeloss"; public static final String erMethodNegotiate = "negotiate"; static This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-10-30 19:16:36
|
Revision: 2728 http://colossus.svn.sourceforge.net/colossus/?rev=2728&view=rev Author: cleka Date: 2007-10-30 12:16:35 -0700 (Tue, 30 Oct 2007) Log Message: ----------- EventViewer and Autoinspector get now during initialization (i.e. never used before, e.g. a new user), reasonable sizes and positions. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java 2007-10-30 19:14:22 UTC (rev 2727) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/AutoInspector.java 2007-10-30 19:16:35 UTC (rev 2728) @@ -55,7 +55,8 @@ }); saveWindow = new SaveWindow(options, "AutoInspector"); - saveWindow.restore(this, new Point(0,0)); + Point location = getUpperRightCorner(550); + saveWindow.restore(this, location); scrollPane = new JScrollPane(); @@ -77,7 +78,7 @@ { // this is just a first go to have some size at all // TODO do a decent estimate of a legion's size - return new Dimension(200,50); + return new Dimension(550, 110); } public void showLegion(Marker marker, LegionInfo legion) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-10-30 19:14:22 UTC (rev 2727) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-10-30 19:16:35 UTC (rev 2728) @@ -244,13 +244,13 @@ { // A tabbed pane, one tab the events, one tab the settings JTabbedPane tabbedPane = new JTabbedPane(); - tabbedPane.setPreferredSize(new Dimension(220, 250)); + tabbedPane.setPreferredSize(new Dimension(270, 520)); // Events: Box eventTabPane = new Box(BoxLayout.Y_AXIS); tabbedPane.addTab("Events", eventTabPane); eventTabPane.setAlignmentX(Component.LEFT_ALIGNMENT); - eventTabPane.setPreferredSize(new Dimension(200, 400)); + eventTabPane.setPreferredSize(new Dimension(250, 500)); eventPane = new Box(BoxLayout.Y_AXIS); eventTabPane.setAlignmentX(Component.LEFT_ALIGNMENT); @@ -786,7 +786,9 @@ { if (visible) { - saveWindow.restore(this, new Point(0,0)); + Point defaultLoc = getUpperRightCorner(getWidth()); + defaultLoc.setLocation(defaultLoc.x, 120); + saveWindow.restore(this, defaultLoc); settingsPane.setMinimumSize(settingsPane.getSize()); // eventPane.setMinimumSize(eventPane.getSize()); this.visible = true; @@ -794,8 +796,16 @@ } else { - saveWindow.save(this); - this.visible = false; + if (this.isVisible()) + { + // do not save when not visible - in particular this + // would be run when a new user first time creates a + // board - Inspector option not selected, but EventViewer + // gets created anyway and "setVisibleMaybe()" - that + // would save (0, 0) as initial location... + saveWindow.save(this); + this.visible = false; + } } super.setVisible(visible); } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java 2007-10-30 19:14:22 UTC (rev 2727) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/KDialog.java 2007-10-30 19:16:35 UTC (rev 2728) @@ -57,6 +57,13 @@ (d.height / 2 - getSize().height / 2) + yoffset)); } + public Point getUpperRightCorner(int width) + { + Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); + Point location = new Point(d.width - width, 0); + return location; + } + public void upperRightCorner() { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-11-17 18:35:29
|
Revision: 2756 http://colossus.svn.sourceforge.net/colossus/?rev=2756&view=rev Author: cleka Date: 2007-11-17 10:35:26 -0800 (Sat, 17 Nov 2007) Log Message: ----------- The improved "what if saves/ does not exist or cannot even be created" handling as proposed recently. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-11-16 22:49:09 UTC (rev 2755) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/MasterBoard.java 2007-11-17 18:35:26 UTC (rev 2756) @@ -22,6 +22,7 @@ import java.awt.event.MouseMotionAdapter; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.io.File; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.ArrayList; @@ -600,7 +601,35 @@ // TODO: Need a confirmation dialog on overwrite? public void actionPerformed(ActionEvent e) { - JFileChooser chooser = new JFileChooser(Constants.saveDirname); + File savesDir = new File(Constants.saveDirname); + if (!savesDir.exists()) + { + Log.event("Trying to make directory " + savesDir.toString()); + if (!savesDir.mkdirs()) + { + Log.error("Could not create saves directory"); + JOptionPane.showMessageDialog(masterFrame, + "Could not create directory " + savesDir + + "\n- FileChooser dialog box will default " + + "to some other (system dependent) directory!", + "Creating directory " + savesDir + " failed!", + JOptionPane.ERROR_MESSAGE); + } + } + else if (!savesDir.isDirectory()) + { + Log.error("Can't create directory " + savesDir.toString() + + " - name exists but is not a file"); + JOptionPane.showMessageDialog(masterFrame, + "Can't create directory " + savesDir + + " (name exists, but is not a file)\n" + + "- FileChooser dialog box will default to " + + "some other (system dependent) directory!", + "Creating directory " + savesDir + " failed!", + JOptionPane.ERROR_MESSAGE); + } + + JFileChooser chooser = new JFileChooser(savesDir); chooser.setFileFilter(new XMLSnapshotFilter()); int returnVal = chooser.showSaveDialog(masterFrame); if (returnVal == JFileChooser.APPROVE_OPTION) Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java 2007-11-16 22:49:09 UTC (rev 2755) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Game.java 2007-11-17 18:35:26 UTC (rev 2756) @@ -4,6 +4,8 @@ import java.io.*; import java.util.*; +import javax.swing.JOptionPane; + import org.jdom.*; import org.jdom.output.*; import org.jdom.input.*; @@ -950,6 +952,14 @@ if (!savesDir.mkdirs()) { Log.error("Could not create saves directory"); + JOptionPane.showMessageDialog(null, + "Could not create directory " + savesDir + + "\n- saving game failed! Unless the directory " + + "can be created, you can't use File=>Save, and " + + "make sure Autosave (in Game Setup) is disabled.", + "Can't save game!", + JOptionPane.ERROR_MESSAGE); + return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pet...@us...> - 2007-12-02 00:24:52
|
Revision: 2788 http://colossus.svn.sourceforge.net/colossus/?rev=2788&view=rev Author: peterbecker Date: 2007-12-01 16:24:47 -0800 (Sat, 01 Dec 2007) Log Message: ----------- Changed handling of missing readme files. Previously a missing readme file completely stopped a variant from loading. In the new version a warning will be logged and a text document will be created containing a message about the missing files. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java 2007-12-01 21:21:32 UTC (rev 2787) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/VariantSupport.java 2007-12-02 00:24:47 UTC (rev 2788) @@ -9,7 +9,10 @@ import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.text.BadLocationException; +import javax.swing.text.DefaultStyledDocument; import javax.swing.text.Document; +import javax.swing.text.StyledDocument; import net.sf.colossus.client.HexMap; import net.sf.colossus.util.ResourceLoader; @@ -199,6 +202,14 @@ directories = new java.util.ArrayList(); directories.add(tempVarDirectory); varREADME = ResourceLoader.getDocument("README", directories); + + // varREADME seems to be used as flag for a successfully loaded + // variant, but breaking the whole variant loading just because + // there is no readme file seems a bit overkill, thus we set + // a default in this case + if(varREADME == null) { + varREADME = getMissingReadmeNotification(); + } } catch (Exception e) { @@ -239,7 +250,23 @@ return varREADME; } - public static String getVarDirectory() + private static Document getMissingReadmeNotification() { + StyledDocument txtdoc = new DefaultStyledDocument(); + try { + txtdoc.insertString(0, + "No README found -- variant is lacking a README.txt or README.html.", + null); + } catch (BadLocationException e) { + // really shouldn't happen with the constant offset + LOGGER.log(Level.WARNING, + "Failed to insert warning about missing readme into Document object", + e); + } + txtdoc.putProperty(ResourceLoader.keyContentType, "text/plain"); + return txtdoc; + } + + public static String getVarDirectory() { return varDirectory; } Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2007-12-01 21:21:32 UTC (rev 2787) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/ResourceLoader.java 2007-12-02 00:24:47 UTC (rev 2788) @@ -784,12 +784,12 @@ catch (Exception e) { LOGGER.log(Level.SEVERE, "text document exists, but cannot be loaded (" + - filename + "): " + e, (Throwable)null); + filename + "): " + e, e); } return null; } - LOGGER.log(Level.SEVERE, "No document for basename " + filename + " found " + - "(neither .html, .txt nor without extention)!", (Throwable)null); + LOGGER.log(Level.WARNING, "No document for basename " + filename + " found " + + "(neither .html, .txt nor without extention)!"); return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-12-04 20:58:44
|
Revision: 2797 http://colossus.svn.sourceforge.net/colossus/?rev=2797&view=rev Author: cleka Date: 2007-12-04 12:58:36 -0800 (Tue, 04 Dec 2007) Log Message: ----------- Added the eol-style and keywrods properties on those java files where it was missing. Eclipse also fixed the $Id$ fields automatically. Modified Paths: -------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowHelpDoc.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/StartupProgress.java Property Changed: ---------------- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/HexRecruitTreePanel.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealedCreature.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowHelpDoc.java trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java trunk/Colossus/core/src/main/java/net/sf/colossus/server/StartupProgress.java Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-12-03 22:33:05 UTC (rev 2796) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java 2007-12-04 20:58:36 UTC (rev 2797) @@ -70,7 +70,7 @@ * depending on what the viewMode says * - "SolidMarker" instead of Titan for mulligan * - * @version $Id: EventViewer.java 2591 2006-01-01 23:41:26Z cleka $ + * @version $Id$ * @author Clemens Katzer */ Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/client/EventViewer.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/client/HexRecruitTreePanel.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/client/PickStrikePenalty.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealEvent.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/client/RevealedCreature.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowHelpDoc.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowHelpDoc.java 2007-12-03 22:33:05 UTC (rev 2796) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowHelpDoc.java 2007-12-04 20:58:36 UTC (rev 2797) @@ -11,7 +11,7 @@ * Eventually one day this should show the option documents * itself as an own JEditorPane, let user browse them etc... * - * @version $Id: ShowHelpDoc.java 0000 2007-07-13 00:00:00Z cleka $ + * @version $Id$ * @author Clemens Katzer */ Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowHelpDoc.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java 2007-12-03 22:33:05 UTC (rev 2796) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java 2007-12-04 20:58:36 UTC (rev 2797) @@ -20,7 +20,7 @@ * Provides a JScrollPane to display the Variant README, * either within GetPlayer selection tab, * or from main boards help (then in own JFrame). - * @version $Id: ShowReadme.java 0000 2007-02-16 00:00:00Z cleka $ + * @version $Id$ * @author Clemens Katzer */ Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ShowReadme.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/StartupProgress.java =================================================================== --- trunk/Colossus/core/src/main/java/net/sf/colossus/server/StartupProgress.java 2007-12-03 22:33:05 UTC (rev 2796) +++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/StartupProgress.java 2007-12-04 20:58:36 UTC (rev 2797) @@ -14,7 +14,7 @@ /** * Simple log window for Startup progress (waiting for clients) - * @version $Id: StartupProgress.java 0000 2007-02-14 00:00:00Z cleka $ + * @version $Id$ * @author Clemens Katzer */ public final class StartupProgress implements ActionListener Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/server/StartupProgress.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |