Revision: 5700
http://vassalengine.svn.sourceforge.net/vassalengine/?rev=5700&view=rev
Author: morvael
Date: 2009-06-02 15:17:50 +0000 (Tue, 02 Jun 2009)
Log Message:
-----------
Own KeyCommand for better integration, some refactoring done on command method names.
Modified Paths:
--------------
VSQL-src/branches/morvael/rsr/PieceCache.java
VSQL-src/branches/morvael/rsr/RsrAdvance.java
VSQL-src/branches/morvael/rsr/RsrAdvanceBase.java
VSQL-src/branches/morvael/rsr/RsrGlobal.java
VSQL-src/branches/morvael/rsr/RsrImmobilized.java
VSQL-src/branches/morvael/rsr/RsrPieceMover.java
VSQL-src/branches/morvael/rsr/RsrTrait.java
Added Paths:
-----------
VSQL-src/branches/morvael/rsr/RsrKeyCommand.java
Modified: VSQL-src/branches/morvael/rsr/PieceCache.java
===================================================================
--- VSQL-src/branches/morvael/rsr/PieceCache.java 2009-06-02 13:21:35 UTC (rev 5699)
+++ VSQL-src/branches/morvael/rsr/PieceCache.java 2009-06-02 15:17:50 UTC (rev 5700)
@@ -217,7 +217,7 @@
hr = mainGrid.getHexPos(gp.getPosition());
if ((RsrTrait.getFired(gp) == 0) && (mainGrid.getHexesInRange(hr, RsrTrait.getRange(gp)).containsAll(dH))) {
if ((getHexesInZOCEnemy(SIDE_AXIS).contains(hr) == false) || (filter.filterPieces(axisPieceGroups.get(hr), T_ATTACKER + ">0").size() > 0)) {
- core.commandSetProperty(gp, T_HL_ACTION, 0, T_FIRED, 1);
+ core.commandBaseSetProperty(gp, T_HL_ACTION, 0, T_FIRED, 1);
return 4;
}
}
Modified: VSQL-src/branches/morvael/rsr/RsrAdvance.java
===================================================================
--- VSQL-src/branches/morvael/rsr/RsrAdvance.java 2009-06-02 13:21:35 UTC (rev 5699)
+++ VSQL-src/branches/morvael/rsr/RsrAdvance.java 2009-06-02 15:17:50 UTC (rev 5700)
@@ -4,7 +4,6 @@
import VASSAL.command.Command;
import java.awt.Point;
import VASSAL.counters.GamePiece;
-import VASSAL.counters.KeyCommand;
import filter.Filter;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
@@ -34,8 +33,8 @@
return instance;
}
//
- private KeyCommand[] commandsArray = new KeyCommand[0];
- private ArrayList<KeyCommand> commands = new ArrayList<KeyCommand>();
+ private RsrKeyCommand[] commandsArray = new RsrKeyCommand[0];
+ private ArrayList<RsrKeyCommand> commands = new ArrayList<RsrKeyCommand>();
public RsrAdvance() {
super();
@@ -54,28 +53,28 @@
}
protected void executeSetPhaseParts() {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PART, 1);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PART, 1);
String phaseName = getPhaseName();
if (phaseName.equals(PHASE_SUPPLY)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
} else if (phaseName.equals(PHASE_AXIS_REINFORCEMENT)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
} else if (phaseName.equals(PHASE_AXIS_MOVEMENT)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 4);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 4);
} else if (phaseName.equals(PHASE_AXIS_COMBAT)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
} else if (phaseName.equals(PHASE_SOVIET_COMBAT)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
} else if (phaseName.equals(PHASE_SOVIET_REINFORCEMENT)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
} else if (phaseName.equals(PHASE_SOVIET_MOVEMENT)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 5);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 5);
} else if (phaseName.equals(PHASE_GERMAN_TANK_MOVEMENT)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 3);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 3);
} else if (phaseName.equals(PHASE_ADMINISTRATIVE)) {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 6);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 6);
} else {
- commandSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PARTS, 1);
}
}
@@ -84,7 +83,8 @@
//1..x - parts
//x+1 - leave
- commandClearHighlight();
+ //commandBaseClearHighlight();
+ commandDisallowActionAll();
commandDisallowMovementAll();
String phaseName = getPhaseName();
@@ -157,7 +157,7 @@
* Ask Axis player to voluntarily remove supply depots and/or convert supply depots into emergency supply sources. (MANUAL)
*/
private void executeSupply1() {
- commandLog("Game: Checking supply of airbases.");
+ commandBaseLog("Game: Checking supply of airbases.");
HashMap<HexRef, TerrainMapShaderCost> inSupply = supplyCache.getSupply(NATIONALITY_GERMAN, false);
HexRef hr;
for (GamePiece gp : filter.filterPieces(mainMap, "Type=='Airbase'")) {
@@ -179,7 +179,7 @@
}
}
if (count > 0) {
- commandLog("Axis Player: Move air fleets to desired location in range.");
+ commandBaseLog("Axis Player: Move air fleets to desired location in range.");
}
}
count = 0;
@@ -188,7 +188,7 @@
count++;
}
if (count > 0) {
- commandLog("Axis Player: Voluntarily remove supply depots and/or convert supply depots into emergency supply sources.");
+ commandBaseLog("Axis Player: Voluntarily remove supply depots and/or convert supply depots into emergency supply sources.");
}
}
@@ -200,7 +200,7 @@
*/
private void executeSupply2() {
//Check supply of all units (except airbases).
- commandLog("Game: Checking supply of all units (except airbases).");
+ commandBaseLog("Game: Checking supply of all units (except airbases).");
//clear and recalculate AirFleet support zone for this turn (it will not change during the turn)
airFleetCache.clear();
HashSet<HexRef> inAirRange = airFleetCache.getAirFleetSupportZone();
@@ -258,12 +258,12 @@
if ((supplyLevel == 3) && (Filter.isAny(type, "Headquarters", "Leader"))) {
commandEliminate(gp);
} else {
- commandSetProperty(gp, T_SUPPLY_LEVEL, supplyLevel, T_SUPPLY_ISOLATED, isolated);
+ commandBaseSetProperty(gp, T_SUPPLY_LEVEL, supplyLevel, T_SUPPLY_ISOLATED, isolated);
}
}
//Check attrition of all isolated units.
if (isolatedUnits.size() > 0) {
- commandLog("Game: Checking attrition of isolated units.");
+ commandBaseLog("Game: Checking attrition of isolated units.");
int d6;
String tt;
int stepsLost = 0;
@@ -320,7 +320,7 @@
//Remove supply depots converted into emergency supply sources.
ArrayList<GamePiece> emergencyDepots = filter.filterPieces(mainMap, "Type=='Depot'&&SupplyMode==2");
if (emergencyDepots.size() > 0) {
- commandLog("Game: Removing " + emergencyDepots.size() + " supply depot(s) converted into emergency supply source(s).");
+ commandBaseLog("Game: Removing " + emergencyDepots.size() + " supply depot(s) converted into emergency supply source(s).");
for (GamePiece gp : emergencyDepots) {
commandSendToReinforcementZone(gp, 4, "Axis Permanently Eliminated Units Box");
}
@@ -328,7 +328,7 @@
//
ArrayList<GamePiece> receivedCombatStrengthMarkers = filter.filterPieces(turnMap, "Type=='Strength'&&LocationName=='S" + getTurnName() + "'");
if (receivedCombatStrengthMarkers.size() > 0) {
- commandLog("Game: Moving " + receivedCombatStrengthMarkers.size() + " Soviet Combat Strength Marker(s) received as reinforcement(s) into the proper draw cups.");
+ commandBaseLog("Game: Moving " + receivedCombatStrengthMarkers.size() + " Soviet Combat Strength Marker(s) received as reinforcement(s) into the proper draw cups.");
for (GamePiece gp : receivedCombatStrengthMarkers) {
commandSendToOffboardZone(gp, RsrTrait.getStrengthClass(gp) + "-strength pool");
}
@@ -344,7 +344,7 @@
for (GamePiece gp : reinforcements) {
commandAllowMovement(gp, 0.0d, true);
}
- commandLog("Axis Player: Put reinforcements on map.");
+ commandBaseLog("Axis Player: Put reinforcements on map.");
} else {
autoAdvance = true;
}
@@ -355,13 +355,13 @@
*/
private void executeAxisReinforcement2() {
for (GamePiece gp : filter.filterPieces(mainMap, T_PLACED + ">0")) {
- commandSetProperty(gp, T_PLACED, 0);
+ commandBaseSetProperty(gp, T_PLACED, 0);
}
}
//sea movement - MANUAL
private void executeAxisMovement1() {
- //commandLog("Axis Player: Sea movement.");
+ //commandBaseLog("Axis Player: Sea movement.");
//TODO: finish this
autoAdvance = true;
}
@@ -381,7 +381,7 @@
}
if (count > 0) {
commandResetMovementIndex();
- commandLog("Axis Player: Move units (strategic movement).");
+ commandBaseLog("Axis Player: Move units (strategic movement).");
} else {
autoAdvance = true;
}
@@ -403,7 +403,7 @@
}
if (count > 0) {
commandResetMovementIndex();
- commandLog("Axis Player: Move units (except airbases).");
+ commandBaseLog("Axis Player: Move units (except airbases).");
} else {
autoAdvance = true;
}
@@ -425,7 +425,7 @@
}
if (count > 0) {
commandResetMovementIndex();
- commandLog("Axis Player: Move airbases.");
+ commandBaseLog("Axis Player: Move airbases.");
} else {
autoAdvance = true;
}
@@ -454,7 +454,7 @@
for (GamePiece gp : filter.filterPieces(mainMap, "Type=='SiegeArtillery'")) {
commandAllowAction(gp);
}
- commandLog("Axis Player: Attack with your units.");
+ commandBaseLog("Axis Player: Attack with your units.");
} else {
autoAdvance = true;
}
@@ -465,7 +465,7 @@
*/
private void executeAxisCombat2() {
for (GamePiece gp : filter.filterPieces(mainMap, T_ATTACKED + ">0||" + T_FIRED + ">0")) {
- commandSetProperty(gp, T_ATTACKED, 0, T_FIRED, 0);
+ commandBaseSetProperty(gp, T_ATTACKED, 0, T_FIRED, 0);
}
}
@@ -482,7 +482,7 @@
}
}
if (count > 0) {
- commandLog("Soviet Player: Attack with your units.");
+ commandBaseLog("Soviet Player: Attack with your units.");
} else {
autoAdvance = true;
}
@@ -493,7 +493,7 @@
*/
private void executeSovietCombat2() {
for (GamePiece gp : filter.filterPieces(mainMap, T_ATTACKED + ">0")) {
- commandSetProperty(gp, T_ATTACKED, 0);
+ commandBaseSetProperty(gp, T_ATTACKED, 0);
}
}
@@ -536,7 +536,7 @@
}
}
if (count > 0) {
- commandLog("Soviet Player: Put reinforcements on map.");
+ commandBaseLog("Soviet Player: Put reinforcements on map.");
} else {
autoAdvance = true;
}
@@ -550,7 +550,7 @@
*/
private void executeSovietReinforcement2() {
for (GamePiece gp : filter.filterPieces(mainMap, T_PLACED + ">0")) {
- commandSetProperty(gp, T_PLACED, 0);
+ commandBaseSetProperty(gp, T_PLACED, 0);
}
}
@@ -564,7 +564,7 @@
count++;
}
if (count > 0) {
- commandLog("Soviet Player: Put airborne corps on map.");
+ commandBaseLog("Soviet Player: Put airborne corps on map.");
} else {
autoAdvance = true;
}
@@ -574,7 +574,7 @@
* Sea movement. (MANUAL)
*/
private void executeSovietMovement2() {
- //commandLog("Soviet Player: Sea movement.");
+ //commandBaseLog("Soviet Player: Sea movement.");
//TODO: finish this
autoAdvance = true;
}
@@ -594,7 +594,7 @@
}
if (count > 0) {
commandResetMovementIndex();
- commandLog("Soviet Player: Move units (strategic movement).");
+ commandBaseLog("Soviet Player: Move units (strategic movement).");
} else {
autoAdvance = true;
}
@@ -616,7 +616,7 @@
}
if (count > 0) {
commandResetMovementIndex();
- commandLog("Soviet Player: Move units (except leaders).");
+ commandBaseLog("Soviet Player: Move units (except leaders).");
} else {
autoAdvance = true;
}
@@ -638,7 +638,7 @@
}
if (count > 0) {
commandResetMovementIndex();
- commandLog("Soviet Player: Move leaders.");
+ commandBaseLog("Soviet Player: Move leaders.");
} else {
autoAdvance = true;
}
@@ -667,7 +667,7 @@
}
if (count > 0) {
commandResetMovementIndex();
- commandLog("Axis Player: Move German tank units.");
+ commandBaseLog("Axis Player: Move German tank units.");
} else {
autoAdvance = true;
}
@@ -688,7 +688,7 @@
}
if (count > 0) {
commandResetMovementIndex();
- commandLog("Axis Player: Move German tank units (strategic movement).");
+ commandBaseLog("Axis Player: Move German tank units (strategic movement).");
} else {
autoAdvance = true;
}
@@ -705,7 +705,7 @@
//
ArrayList<GamePiece> airfleets = filter.filterPieces(mainMap, "Type=='AirFleet'");
if (airfleets.size() > 0) {
- commandLog("Game: Removing air fleets from the map.");
+ commandBaseLog("Game: Removing air fleets from the map.");
for (GamePiece gp : airfleets) {
commandSendToOffboardZone(gp, "Airfleet pool");
}
@@ -717,7 +717,7 @@
airbases.addAll(filter.filterPieces(turnMap, "Type=='Airbase'"));
int desiredCount = turnNumber == 11 ? 2 : 1;
if (airbases.size() > desiredCount) {
- commandLog("Axis Player: Remove any one airbase.");
+ commandBaseLog("Axis Player: Remove any one airbase.");
for (GamePiece gp : airbases) {
commandAllowCombatAction(gp);
}
@@ -742,7 +742,7 @@
commandEliminate(gp);
}
}
- commandLog("Axis Player: Perform breakdowns and buildups.");
+ commandBaseLog("Axis Player: Perform breakdowns and buildups.");
}
/**
@@ -766,7 +766,7 @@
for (GamePiece gp : convertible) {
commandAllowAction(gp);
}
- commandLog("Soviet Player: Promote infantry armies into Guards and Shock armies.");
+ commandBaseLog("Soviet Player: Promote infantry armies into Guards and Shock armies.");
return;
}
}
@@ -780,9 +780,9 @@
*/
private void executeAdministrative3() {
if (isProductionTurn()) {
- commandLog("Soviet Player: Perform breakdowns, buildups and incorporations.");
+ commandBaseLog("Soviet Player: Perform breakdowns, buildups and incorporations.");
} else {
- commandLog("Soviet Player: Perform incorporations.");
+ commandBaseLog("Soviet Player: Perform incorporations.");
}
}
@@ -799,7 +799,7 @@
if (isProductionTurn()) {
ArrayList<GamePiece> ports = filter.filterPieces(mainMap, "AssetType=='Strategic Port'");
if (ports.size() > 0) {
- commandLog("Game: Checking railroad line of communication of strategic port assets.");
+ commandBaseLog("Game: Checking railroad line of communication of strategic port assets.");
HashSet<HexRef> withLOC = supplyCache.getSovietLine();
for (GamePiece gp : ports) {
if (withLOC.contains(getHexRef(gp.getPosition())) == false) {
@@ -815,7 +815,7 @@
GamePiece gp = leadersInPool.get(ran.nextInt(leadersInPool.size()));
commandSendToReinforcementZone(gp, 0, "Leader pool");
commandAllowMovement(gp, 0.0d, true);
- commandLog("Soviet Player: Put leader on map.");
+ commandBaseLog("Soviet Player: Put leader on map.");
return;
}
}
@@ -841,7 +841,7 @@
}
}
if (count > 0) {
- commandLog("Soviet Player: Evacuate factory economic assets.");
+ commandBaseLog("Soviet Player: Evacuate factory economic assets.");
return;
}
}
@@ -853,7 +853,7 @@
*/
private void executeAdministrative6() {
//
- commandSetProperty(dataPiece, G_EVACUATED, 0);
+ commandBaseSetProperty(dataPiece, G_EVACUATED, 0);
//
int count = 0;
for (GamePiece gp : filter.filterPieces(turnMap, "LocationName=='S" + getTurnName() + "'&&Type=='Partisan'")) {
@@ -861,7 +861,7 @@
count++;
}
if (count > 0) {
- commandLog("Soviet Player: Put partisan on map.");
+ commandBaseLog("Soviet Player: Put partisan on map.");
} else {
autoAdvance = true;
}
@@ -1069,14 +1069,14 @@
allowedMovement.get(gp).movementDone(hr);
if (moveMode == MOVE_ONCE) {
if (RsrTrait.getRepositioning(gp) > 0) {
- commandSetProperty(gp, T_REPOSITIONING, 0);
- commandSetProperty(dataPiece, G_REPOSITIONING_REQUIRED, RsrGlobal.getRepositioningRequired()-1);
+ commandBaseSetProperty(gp, T_REPOSITIONING, 0);
+ commandBaseSetProperty(dataPiece, G_REPOSITIONING_REQUIRED, RsrGlobal.getRepositioningRequired()-1);
} else
if (combatStage == 4) {
lossVal = Math.max(lossVal, allowedMovement.get(gp).getCost(hr).getValue());
- commandSetProperty(gp, T_RETREATING, -1);
+ commandBaseSetProperty(gp, T_RETREATING, -1);
} else if (combatStage == 6) {
- commandSetProperty(gp, T_ADVANCING, 0);
+ commandBaseSetProperty(gp, T_ADVANCING, 0);
if (combatMode == 0) {
commandDisallowMovement(gp);
}
@@ -1090,7 +1090,7 @@
int motLossVal = lossVal % 10;
if (motLossVal > 0) {
int availableStepsMot = 0;
- commandLog("Due to retreat(s) across major river(s), the stack must lose " + motLossVal + " motorized step(s).");
+ commandBaseLog("Due to retreat(s) across major river(s), the stack must lose " + motLossVal + " motorized step(s).");
for (GamePiece gp : pieces) {
if (RsrTrait.getMovementTypeAsInt(gp) == MOVEMENT_MOTORIZED) {
availableStepsMot += RsrTrait.getCurrentNominalSteps(gp);
@@ -1108,7 +1108,7 @@
}
lossVal -= motLossVal;
} else {
- commandSetProperty(dataPiece, MOTORIZED_LOSS_REQUIRED, motLossVal);
+ commandBaseSetProperty(dataPiece, MOTORIZED_LOSS_REQUIRED, motLossVal);
for (GamePiece gp : pieces) {
if (RsrTrait.getMovementTypeAsInt(gp) == MOVEMENT_MOTORIZED) {
commandAllowCombatAction(gp);
@@ -1119,7 +1119,7 @@
int conLossVal = lossVal / 10;
if (conLossVal > 0) {
int availableStepsCon = 0;
- commandLog("Due to retreat through enemy contested, unoccupied space(s) the stack must lose " + conLossVal + " step(s).");
+ commandBaseLog("Due to retreat through enemy contested, unoccupied space(s) the stack must lose " + conLossVal + " step(s).");
for (GamePiece gp : pieces) {
availableStepsCon += RsrTrait.getCurrentNominalSteps(gp);
}
@@ -1131,7 +1131,7 @@
}
lossVal -= conLossVal * 10;
} else {
- commandSetProperty(dataPiece, CONTESTED_LOSS_REQUIRED, conLossVal);
+ commandBaseSetProperty(dataPiece, CONTESTED_LOSS_REQUIRED, conLossVal);
for (GamePiece gp : pieces) {
commandAllowCombatAction(gp);
}
@@ -1174,7 +1174,7 @@
}
pieces.clear();
}
- commandAdvance(false);
+ commandAdvance();
}
}
@@ -1232,7 +1232,7 @@
//supply will have to be recalculated after a unit is placed
supplyCache.clear();
for (GamePiece gp : pieces) {
- commandSetProperty(gp, T_PLACED, 1);
+ commandBaseSetProperty(gp, T_PLACED, 1);
}
}
return true;
@@ -1245,53 +1245,53 @@
}
}
- public KeyCommand[] getCommands(RsrTrait trait, GamePiece gp) {
+ public RsrKeyCommand[] getCommands(RsrTrait trait, GamePiece gp) {
commands.clear();
if (RsrGlobal.getDebug() == 1) {
- commands.add(new KeyCommand("Delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), gp, trait));
+ commands.add(new RsrKeyCommand("Delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), gp, trait));
}
String phaseName = getPhaseName();
int phasePart = RsrGlobal.getPhasePart() - 1;
if (phaseName.equals(PHASE_SUPPLY)) {
if ((phasePart == 1) && (RsrTrait.getHlAction(gp) > 0)) {
- commands.add(new KeyCommand("Remove Depot", KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK), gp, trait));
- commands.add(new KeyCommand("Convert Depot", KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK), gp, trait));
+ commands.add(new RsrKeyCommand("Remove Depot", KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK), gp, trait));
+ commands.add(new RsrKeyCommand("Convert Depot", KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK), gp, trait));
}
} else if (phaseName.equals(PHASE_GERMAN_TANK_MOVEMENT)) {
if ((phasePart == 3) && (RsrTrait.getHlLoss(gp) > 0)) {
- commands.add(new KeyCommand("Eliminate", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), gp, trait));
+ commands.add(new RsrKeyCommand("Eliminate", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), gp, trait));
}
} else if (phaseName.equals(PHASE_ADMINISTRATIVE)) {
if (RsrTrait.getHlAction(gp) > 0) {
switch (phasePart) {
case 2 :
- commands.add(new KeyCommand("Promote", KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK), gp, trait));
+ commands.add(new RsrKeyCommand("Promote", KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK), gp, trait));
break;
case 5 :
- commands.add(new KeyCommand("Evacuate", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), gp, trait));
+ commands.add(new RsrKeyCommand("Evacuate", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), gp, trait));
break;
}
}
} else if (phaseName.equals(PHASE_AXIS_COMBAT)) {
if ((RsrTrait.getType(gp).equals("SiegeArtillery")) && (RsrTrait.getHlAction(gp) > 0)) {
if (RsrTrait.getFired(gp) > 0) {
- commands.add(new KeyCommand("Enable support", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), gp, trait));
+ commands.add(new RsrKeyCommand("Enable support", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), gp, trait));
} else {
- commands.add(new KeyCommand("Disable support", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), gp, trait));
+ commands.add(new RsrKeyCommand("Disable support", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), gp, trait));
}
}
}
int combatStage = RsrGlobal.getCombatStage();
if (((combatStage == 2) || (combatStage == 3) || (combatStage == 4)) && (RsrTrait.getHlLoss(gp) > 0)) {
- commands.add(new KeyCommand("Step loss", KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK), gp, trait));
+ commands.add(new RsrKeyCommand("Step loss", KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK), gp, trait));
}
return commands.toArray(commandsArray);
}
- public Command getCommand(RsrTrait trait, GamePiece gp, KeyCommand kc) {
+ public Command getCommand(RsrTrait trait, GamePiece gp, RsrKeyCommand kc) {
String name = kc.getName();
if (name.equals("Delete")) {
- commandDelete(gp);
+ commandBaseDelete(gp);
} else if (name.equals("Step loss")) {
int combatStage = RsrGlobal.getCombatStage();
if ((combatStage == 2) || (combatStage == 3)) {
@@ -1304,11 +1304,11 @@
if (RsrGlobal.getMotorizedLossRequired() > 0) {
if (RsrTrait.getMovementTypeAsInt(gp) == MOVEMENT_MOTORIZED) {
commandStepLoss(gp);
- commandSetProperty(dataPiece, MOTORIZED_LOSS_REQUIRED, RsrGlobal.getMotorizedLossRequired() - 1);
+ commandBaseSetProperty(dataPiece, MOTORIZED_LOSS_REQUIRED, RsrGlobal.getMotorizedLossRequired() - 1);
}
} else if (RsrGlobal.getContestedLossRequired() > 0) {
commandStepLoss(gp);
- commandSetProperty(dataPiece, CONTESTED_LOSS_REQUIRED, RsrGlobal.getContestedLossRequired() - 1);
+ commandBaseSetProperty(dataPiece, CONTESTED_LOSS_REQUIRED, RsrGlobal.getContestedLossRequired() - 1);
}
if ((RsrGlobal.getMotorizedLossRequired() == 0) && (RsrGlobal.getContestedLossRequired() == 0)) {
commandResolveCombat();
@@ -1318,30 +1318,28 @@
}
} else if (name.equals("Eliminate")) { //airbase elimination
commandSendToOffboardZone(gp, "Axis Permanently Eliminated Units Box");
- commandAdvance(false);
+ commandAdvance();
} else if (name.equals("Promote")) {
commandPromote(gp);
} else if (name.equals("Evacuate")) {
commandEvacuate(gp);
} else if (name.equals("Enable support")) {
- commandSetProperty(gp, T_FIRED, 0);
+ commandBaseSetProperty(gp, T_FIRED, 0);
} else if (name.equals("Disable support")) {
- commandSetProperty(gp, T_FIRED, 1);
+ commandBaseSetProperty(gp, T_FIRED, 1);
} else if (name.equals("Remove Depot")) {
commandLogMy("Voluntarily removed supply depot in " + mainGrid.locationName(gp.getPosition()) + ".");
commandSendToReinforcementZone(gp, 4, "Axis Permanently Eliminated Units Box");
} else if (name.equals("Convert Depot")) {
if (RsrTrait.getSupplyMode(gp) == 1) {
- commandSetProperty(gp, PROPERTY_SUPPLY_MODE, 2);
+ commandBaseSetProperty(gp, PROPERTY_SUPPLY_MODE, 2);
commandLogMy("Converted supply depot in " + mainGrid.locationName(gp.getPosition()) + " into emergency supply source.");
} else {
- commandSetProperty(gp, PROPERTY_SUPPLY_MODE, 1);
+ commandBaseSetProperty(gp, PROPERTY_SUPPLY_MODE, 1);
commandLogMy("Converted emergency supply source in " + mainGrid.locationName(gp.getPosition()) + " back into supply depot.");
}
}
- Command result = c;
- c = null;
- return result;
+ return c;
}
Modified: VSQL-src/branches/morvael/rsr/RsrAdvanceBase.java
===================================================================
--- VSQL-src/branches/morvael/rsr/RsrAdvanceBase.java 2009-06-02 13:21:35 UTC (rev 5699)
+++ VSQL-src/branches/morvael/rsr/RsrAdvanceBase.java 2009-06-02 15:17:50 UTC (rev 5700)
@@ -158,7 +158,8 @@
}
public final void execute(String param) {
- commandAdvance(true);
+ commandAdvance();
+ sendAndLog();
}
protected abstract void onInitialize(String param);
@@ -191,24 +192,24 @@
c = null;
}
- public void commandLog(String message) {
+ public void commandBaseLog(String message) {
Command cmd = new Chatter.DisplayText(GameModule.getGameModule().getChatter(), message);
cmd.execute();
appendCommand(cmd);
}
public void commandLogMy(String message) {
- commandLog("* " + GlobalOptions.getInstance().getPlayerId() + ": " + message);
+ commandBaseLog("* " + GlobalOptions.getInstance().getPlayerId() + ": " + message);
}
- public void commandSetProperty(GamePiece gp, Object key, Object val) {
+ public void commandBaseSetProperty(GamePiece gp, Object key, Object val) {
pieceCache.clear(); //step down may cause loss of zoc
ChangeTracker tracker = new ChangeTracker(gp);
gp.setProperty(key.toString(), String.valueOf(val));
appendCommand(tracker.getChangeCommand());
}
- public void commandSetProperty(GamePiece gp, Object... key_val) {
+ public void commandBaseSetProperty(GamePiece gp, Object... key_val) {
pieceCache.clear(); //step down may cause loss of zoc
ChangeTracker tracker = new ChangeTracker(gp);
for (int i = 0; i < key_val.length; i += 2) {
@@ -217,7 +218,7 @@
appendCommand(tracker.getChangeCommand());
}
- public void commandMove(Map map, GamePiece gp, Point p) {
+ public void commandBaseMove(Map map, GamePiece gp, Point p) {
pieceCache.clear(); //moving units may cause change of zoc
appendCommand(map.placeOrMerge(gp, p));
}
@@ -310,16 +311,16 @@
if (gpc != null) {
int desiredControl = side.equals(SIDE_SOVIET) ? 1 : 2;
if (RsrCounter.getIntProperty(gpc, "Control", 1, false) != desiredControl) {
- commandSetProperty(gpc, "Control", String.valueOf(desiredControl));
- commandLog("Game: Space " + mainGrid.locationName(mainGrid.getHexCenter(hr.getColumn(), hr.getRow())) + " is now under " + side + " control.");
+ commandBaseSetProperty(gpc, "Control", String.valueOf(desiredControl));
+ commandBaseLog("Game: Space " + mainGrid.locationName(mainGrid.getHexCenter(hr.getColumn(), hr.getRow())) + " is now under " + side + " control.");
//TODO: apply Moscow/Baku surrender rule on first axis enter
}
if (desiredControl == 2) {
GamePiece gpd = destroyedMarkers.get(hr);
if (gpd != null) {
if (RsrCounter.getIntProperty(gpc, "Destruction", 1, false) != desiredControl) {
- commandSetProperty(gpc, "Destruction", String.valueOf(desiredControl));
- commandLog("Game: Space " + mainGrid.locationName(mainGrid.getHexCenter(hr.getColumn(), hr.getRow())) + " is now destroyed.");
+ commandBaseSetProperty(gpc, "Destruction", String.valueOf(desiredControl));
+ commandBaseLog("Game: Space " + mainGrid.locationName(mainGrid.getHexCenter(hr.getColumn(), hr.getRow())) + " is now destroyed.");
}
}
}
@@ -343,7 +344,7 @@
if (getPartisanRepositionHexes(gp).size() == 0) {
commandEliminate(gp);
} else {
- commandSetProperty(gp, T_REPOSITIONING, 1);
+ commandBaseSetProperty(gp, T_REPOSITIONING, 1);
count++;
}
}
@@ -351,13 +352,13 @@
}
}
if (count > 0) {
- commandSetProperty(dataPiece, G_REPOSITIONING_REQUIRED, count);
- commandLog("Game: There are " + count + " partisan unit(s) to reposition.");
+ commandBaseSetProperty(dataPiece, G_REPOSITIONING_REQUIRED, count);
+ commandBaseLog("Game: There are " + count + " partisan unit(s) to reposition.");
}
}
}
- public void commandClearHighlight() {
+ public void commandBaseClearHighlight() {
supplyCache.clear();
pieceCache.clear();
ClearHighlightCommand cmd = new ClearHighlightCommand(mainMap, filter);
@@ -365,16 +366,16 @@
appendCommand(cmd);
}
- public void commandReportMoves() {
+ public void commandBaseReportMoves() {
MovementReporter r = new MovementReporter(c);
- Command reportCommand = r.getReportCommand();
- if (reportCommand != null) {
- reportCommand.execute();
- appendCommand(reportCommand);
+ Command cmd = r.getReportCommand();
+ if (cmd != null) {
+ cmd.execute();
}
+ appendCommand(cmd);
}
- public void commandDelete(GamePiece gp) {
+ public void commandBaseDelete(GamePiece gp) {
pieceCache.clear(); //deleting units may cause change of zoc
Command cmd = new RemovePiece(gp);
cmd.execute();
@@ -428,9 +429,9 @@
private void commandUpdateStrength(GamePiece gp, GamePiece sgp) {
if (sgp == null) {
- commandSetProperty(gp, T_STRENGTH_ID, "");
+ commandBaseSetProperty(gp, T_STRENGTH_ID, "");
} else {
- commandSetProperty(gp, T_STRENGTH_ID, sgp.getProperty("BasicName"));
+ commandBaseSetProperty(gp, T_STRENGTH_ID, sgp.getProperty("BasicName"));
}
}
@@ -439,20 +440,20 @@
if (sgp != null) {
commandSendToOffboardZone(sgp, RsrTrait.getCombatClass(gp) + "-used strength pool");
commandUpdateStrength(gp, sgp);
- commandLog("Game: " + gp.getName() + " fetched a Combat Strength Marker.");
+ commandBaseLog("Game: " + gp.getName() + " fetched a Combat Strength Marker.");
}
}
public void commandReleaseCounter(GamePiece gp) {
GamePiece sgp = findStrength(RsrTrait.getCombatClass(gp), RsrTrait.getStrengthID(gp));
if (sgp != null) {
- commandSetProperty(gp, T_CURRENT_STEP, 2, T_STRENGTH_ID, "");
+ commandBaseSetProperty(gp, T_CURRENT_STEP, 2, T_STRENGTH_ID, "");
if (RsrTrait.getStrengthType(sgp).equals("Normal")) {
commandSendToOffboardZone(sgp, RsrTrait.getCombatClass(gp) + "-strength pool");
} else {
commandSendToOffboardZone(sgp, "At-Start Strength Marker Box");
}
- commandLog("Game: " + gp.getName() + " released a Combat Strength Marker.");
+ commandBaseLog("Game: " + gp.getName() + " released a Combat Strength Marker.");
}
}
@@ -471,9 +472,9 @@
Rectangle r2 = z.getBoard().bounds();
Point dest = offboardMap.snapTo(new Point(r2.x + r1.x + r1.width / 2, r2.y + r1.y + r1.height / 2));
//
- commandMove(offboardMap, gp, dest);
+ commandBaseMove(offboardMap, gp, dest);
RsrTrait.commandClearAttributes(gp);
- commandLog("Game: " + gp.getName() + " was sent to " + offboardZone + ".");
+ commandBaseLog("Game: " + gp.getName() + " was sent to " + offboardZone + ".");
}
public void commandSendToReinforcementZone(GamePiece gp, int turnNumberMod, String offboardZone) {
@@ -503,17 +504,17 @@
commandReleaseCounter(gp);
}
//
- commandMove(turnMap, gp, dest);
+ commandBaseMove(turnMap, gp, dest);
RsrTrait.commandClearAttributes(gp);
- commandLog("Game: " + gp.getName() + " will return as reinforcement on turn " + regionName.substring(1) + ".");
+ commandBaseLog("Game: " + gp.getName() + " will return as reinforcement on turn " + regionName.substring(1) + ".");
}
public void commandSendToPiece(GamePiece gp, GamePiece rgp, boolean copyProperties) {
- commandMove(gp.getMap(), rgp, gp.getPosition());
+ commandBaseMove(gp.getMap(), rgp, gp.getPosition());
if (copyProperties) {
RsrTrait.commandCopyAttributes(gp, rgp);
}
- commandLog("Game: " + rgp.getName() + " was sent to " + gp.getName() + "'s location.");
+ commandBaseLog("Game: " + rgp.getName() + " was sent to " + gp.getName() + "'s location.");
}
public void commandPromote(GamePiece gp) {
@@ -612,9 +613,9 @@
commandEliminate(gp);
} else {
if (currentStep == 2) {
- commandSetProperty(gp, T_CURRENT_STEP, 1);
+ commandBaseSetProperty(gp, T_CURRENT_STEP, 1);
commandUpdateStrength(gp, findStrength(RsrTrait.getCombatClass(gp), RsrTrait.getStrengthID(gp)));
- commandLog("Game: " + gp.getName() + " lost a step.");
+ commandBaseLog("Game: " + gp.getName() + " lost a step.");
} else if ((currentStep == 1) && (isAxisGermanCorps)) {
if (unitType.equals("AxisGermanTankCorps")) {
for (GamePiece fgp : findInOffboardZone("German Breakdown & Buildup Box", "Unit", "AxisGermanTankBattlegroup", 1)) {
@@ -627,7 +628,7 @@
} else {
for (GamePiece fgp : findInOffboardZone("German Breakdown & Buildup Box", "Unit", "AxisGermanMountainBattlegroup", 1)) {
commandSendToPiece(gp, fgp, true);
- commandSetProperty(fgp, T_CURRENT_STEP, 1);
+ commandBaseSetProperty(fgp, T_CURRENT_STEP, 1);
}
}
commandSendToOffboardZone(gp, "German Breakdown & Buildup Box");
@@ -638,26 +639,20 @@
public void commandEvacuate(GamePiece gp) {
commandSendToOffboardZone(gp, "Evacuated Factories Box");
int newValue = RsrGlobal.getEvacuated()+1;
- commandSetProperty(dataPiece, G_EVACUATED, newValue);
+ commandBaseSetProperty(dataPiece, G_EVACUATED, newValue);
if (newValue >= 3) {
- commandAdvance(false);
+ commandAdvance();
}
}
- public void commandAdvance(boolean fromButton) {
+ public void commandAdvance() {
//TODO: block advance if there are things to do, also block advance for player that is not the owner of current phase part
if (RsrGlobal.getRepositioningRequired() > 0) {
- commandLog("Game: Reposition partisan unit(s) before advancing.");
- if (fromButton) {
- sendAndLog();
- }
+ commandBaseLog("Game: Reposition partisan unit(s) before advancing.");
return;
}
if (RsrGlobal.getCombatStage() > 0) {
- commandLog("Game: Resolve or cancel combat before advancing.");
- if (fromButton) {
- sendAndLog();
- }
+ commandBaseLog("Game: Resolve or cancel combat before advancing.");
return;
}
autoAdvance = true;
@@ -673,15 +668,15 @@
Point p2 = turnPiece.getPosition();
if (p2.y < 3599) {
p2.translate(0, 91);
- commandMove(turnMap, turnPiece, p2);
- commandLog("Game: Turn changes to " + turnGrid.locationName(p2) + ".");
+ commandBaseMove(turnMap, turnPiece, p2);
+ commandBaseLog("Game: Turn changes to " + turnGrid.locationName(p2) + ".");
}
p.y = 45;
} else {
p.translate(0, 82);
}
- commandMove(turnMap, phasePiece, p);
- commandLog("Game: Phase changes to " + turnGrid.locationName(p) + ".");
+ commandBaseMove(turnMap, phasePiece, p);
+ commandBaseLog("Game: Phase changes to " + turnGrid.locationName(p) + ".");
executeEnterPhase();
} else {
executePart(phasePart);
@@ -690,9 +685,6 @@
executeFirst();
}
}
- if (fromButton) {
- sendAndLog();
- }
}
private void executeFirst() {
@@ -711,22 +703,22 @@
private void executePart(int part) {
executePartPhase(part);
- commandSetProperty(dataPiece, PROPERTY_PHASE_PART, part + 1);
+ commandBaseSetProperty(dataPiece, PROPERTY_PHASE_PART, part + 1);
}
protected abstract void executeSetPhaseParts();
protected abstract void executePartPhase(int part);
public void commandAllowCombatAction(GamePiece gp) {
- commandSetProperty(gp, T_HL_LOSS, 1);
+ commandBaseSetProperty(gp, T_HL_LOSS, 1);
}
public void commandDisallowCombatAction(GamePiece gp) {
- commandSetProperty(gp, T_HL_LOSS, 0);
+ commandBaseSetProperty(gp, T_HL_LOSS, 0);
}
public void commandAllowAction(GamePiece gp) {
- commandSetProperty(gp, T_HL_ACTION, 1);
+ commandBaseSetProperty(gp, T_HL_ACTION, 1);
}
public void commandDisallowActionAll() {
@@ -736,25 +728,25 @@
}
public void commandDisallowAction(GamePiece gp) {
- commandSetProperty(gp, T_HL_ACTION, 0);
+ commandBaseSetProperty(gp, T_HL_ACTION, 0);
}
public void commandAllowMovement(GamePiece gp, double mp, boolean newMove) {
if (newMove) {
if (gp.getMap() == mainMap) {
- commandSetProperty(gp, T_MOVEMENT_LEFT, mp, T_HL_MOVEMENT, 1, T_START_HEX, mainGrid.locationName(gp.getPosition()), T_MOVE_INDEX, 0);
+ commandBaseSetProperty(gp, T_MOVEMENT_LEFT, mp, T_HL_MOVEMENT, 1, T_START_HEX, mainGrid.locationName(gp.getPosition()), T_MOVE_INDEX, 0);
} else {
- commandSetProperty(gp, T_MOVEMENT_LEFT, mp, T_HL_MOVEMENT, 1, T_START_HEX, "", T_MOVE_INDEX, 0);
+ commandBaseSetProperty(gp, T_MOVEMENT_LEFT, mp, T_HL_MOVEMENT, 1, T_START_HEX, "", T_MOVE_INDEX, 0);
}
} else {
- commandSetProperty(gp, T_MOVEMENT_LEFT, mp, T_HL_MOVEMENT, 1);
+ commandBaseSetProperty(gp, T_MOVEMENT_LEFT, mp, T_HL_MOVEMENT, 1);
}
}
public void commandDisallowMovementAll() {
int moveIndex = RsrGlobal.getLastMovedIndex() + 1;
if (moveIndex > 1) {
- commandSetProperty(dataPiece, PROPERTY_LAST_MOVED_INDEX, moveIndex);
+ commandBaseSetProperty(dataPiece, PROPERTY_LAST_MOVED_INDEX, moveIndex);
for (GamePiece gp : filter.filterPieces(mainMap, T_MOVE_INDEX + ">0&&" + T_MOVE_INDEX + "<" + moveIndex)) {
commandDisallowMovement(gp);
commandMarkAsMoved(gp);
@@ -766,35 +758,35 @@
}
public void commandDisallowMovement(GamePiece gp) {
- commandSetProperty(gp, T_MOVEMENT_LEFT, 0.0d, T_HL_MOVEMENT, 0, T_START_HEX, "", T_MOVE_INDEX, 0);
+ commandBaseSetProperty(gp, T_MOVEMENT_LEFT, 0.0d, T_HL_MOVEMENT, 0, T_START_HEX, "", T_MOVE_INDEX, 0);
}
public void commandMarkAsMoved(GamePiece gp) {
- commandSetProperty(gp, T_MOVED, 1);
+ commandBaseSetProperty(gp, T_MOVED, 1);
}
public void commandMarkAsUnmovedAll() {
for (GamePiece gp : filter.filterPieces(mainMap, T_MOVED + ">0")) {
- commandSetProperty(gp, T_MOVED, 0);
+ commandBaseSetProperty(gp, T_MOVED, 0);
}
}
public void commandMarkAsReorganized(GamePiece gp) {
- commandSetProperty(gp, T_REORGANIZED, 1);
+ commandBaseSetProperty(gp, T_REORGANIZED, 1);
}
public void commandMarkAsUnreorganizedAll() {
for (GamePiece gp : filter.filterPieces(mainMap, T_REORGANIZED + ">0")) {
- commandSetProperty(gp, T_REORGANIZED, 0);
+ commandBaseSetProperty(gp, T_REORGANIZED, 0);
}
}
public void commandSetMovementIndex(ArrayList<GamePiece> pieces) {
int moveIndex = RsrGlobal.getLastMovedIndex() + 1;
for (GamePiece gp : pieces) {
- commandSetProperty(gp, T_MOVE_INDEX, moveIndex);
+ commandBaseSetProperty(gp, T_MOVE_INDEX, moveIndex);
}
- commandSetProperty(dataPiece, PROPERTY_LAST_MOVED_INDEX, moveIndex);
+ commandBaseSetProperty(dataPiece, PROPERTY_LAST_MOVED_INDEX, moveIndex);
for (GamePiece gp : filter.filterPieces(mainMap, T_MOVE_INDEX + ">0&&" + T_MOVE_INDEX + "<" + moveIndex)) {
commandDisallowMovement(gp);
commandMarkAsMoved(gp);
@@ -802,7 +794,7 @@
}
public void commandResetMovementIndex() {
- commandSetProperty(dataPiece, PROPERTY_LAST_MOVED_INDEX, 0);
+ commandBaseSetProperty(dataPiece, PROPERTY_LAST_MOVED_INDEX, 0);
}
public HexRef getStartHex(GamePiece gp) {
@@ -845,7 +837,7 @@
RsrTrait.commandClearCombatAttributes(gp, (RsrTrait.getDefender(gp) > 0) && (combatStage == 6) && (overrun == false));
}
//set combat parameters
- commandSetProperty(dataPiece, COMBAT_STAGE, 0,
+ commandBaseSetProperty(dataPiece, COMBAT_STAGE, 0,
COMBAT_MODE, 0,
ATTACKER_HEXES, "",
DEFENDER_HEXES, "",
@@ -925,7 +917,7 @@
commandLogMy((overrun ? "Overrun combat" : "Combat") + " initiated in space " + defenderHex + ".");
}
for (GamePiece gp : strengthA.keySet()) {
- commandSetProperty(gp, T_ATTACKER, 1, T_COMBAT_HEX, attackerHex);
+ commandBaseSetProperty(gp, T_ATTACKER, 1, T_COMBAT_HEX, attackerHex);
strength = strengthA.get(gp).intValue();
if (strength > 0) {
commandLogMy(gp.getName() + " will attack with strength " + strength + ".");
@@ -934,7 +926,7 @@
}
}
for (GamePiece gp : strengthD.keySet()) {
- commandSetProperty(gp, T_DEFENDER, 1, T_COMBAT_HEX, defenderHex);
+ commandBaseSetProperty(gp, T_DEFENDER, 1, T_COMBAT_HEX, defenderHex);
strength = strengthD.get(gp).intValue();
if (strength > 0) {
commandLogMy(gp.getName() + " will defend with strength " + strength + ".");
@@ -942,7 +934,7 @@
commandLogMy(gp.getName() + " will defend with unknown strength.");
}
}
- commandSetProperty(dataPiece, COMBAT_STAGE, 1,
+ commandBaseSetProperty(dataPiece, COMBAT_STAGE, 1,
COMBAT_MODE, overrun ? 1 : 0,
ATTACKER_HEXES, attackerHexes.toString(),
DEFENDER_HEXES, defenderHexes.toString());
@@ -980,8 +972,8 @@
}
urbanLoss = 2*motorizedSteps > totalSteps;
if (urbanLoss) {
- commandLog("Game: Additional losses will apply to motorized forces attacking urban area (" + motorizedSteps + " step(s) out of " + totalSteps + " step(s) are motorized).");
- commandSetProperty(dataPiece, URBAN_LOSS_REQUIRED, 1);
+ commandBaseLog("Game: Additional losses will apply to motorized forces attacking urban area (" + motorizedSteps + " step(s) out of " + totalSteps + " step(s) are motorized).");
+ commandBaseSetProperty(dataPiece, URBAN_LOSS_REQUIRED, 1);
}
}
}
@@ -1049,7 +1041,7 @@
}
}
}
- commandSetProperty(dataPiece, COMBAT_STAGE, ++combatStage,
+ commandBaseSetProperty(dataPiece, COMBAT_STAGE, ++combatStage,
ATTACKER_LOSS, al,
ATTACKER_RETREAT, ar,
DEFENDER_LOSS, dl,
@@ -1059,20 +1051,20 @@
if (combatStage == 2) {
//defender step loss
if (commandRefreshCombatLossList(ignoreOptional)) {
- commandSetProperty(dataPiece, COMBAT_STAGE, ++combatStage);
+ commandBaseSetProperty(dataPiece, COMBAT_STAGE, ++combatStage);
ignoreOptional = false;
} else {
- commandLog("Game: Defender is required to lose " + RsrGlobal.getDefenderLoss() + " step(s) and optionally " + RsrGlobal.getDefenderRetreat() + " more.");
+ commandBaseLog("Game: Defender is required to lose " + RsrGlobal.getDefenderLoss() + " step(s) and optionally " + RsrGlobal.getDefenderRetreat() + " more.");
return;
}
}
if (combatStage == 3) {
//attacker step loss
if (commandRefreshCombatLossList(ignoreOptional)) {
- commandSetProperty(dataPiece, COMBAT_STAGE, ++combatStage);
+ commandBaseSetProperty(dataPiece, COMBAT_STAGE, ++combatStage);
ignoreOptional = false;
} else {
- commandLog("Game: Attacker is required to lose " + RsrGlobal.getAttackerLoss() + " step(s) and optionally " + RsrGlobal.getAttackerRetreat() + " more.");
+ commandBaseLog("Game: Attacker is required to lose " + RsrGlobal.getAttackerLoss() + " step(s) and optionally " + RsrGlobal.getAttackerRetreat() + " more.");
return;
}
}
@@ -1086,48 +1078,48 @@
defenders = filter.filterPieces(mainMap, T_DEFENDER + ">0");
//
for (GamePiece gp : defenders) {
- commandSetProperty(gp, T_RETREATING, dr);
+ commandBaseSetProperty(gp, T_RETREATING, dr);
if (TerrainMapShaderRule.hasNonTraceHexes(getRetreatHexes(gp))) {
- commandLog("Game: " + gp.getName() + " must retreat " + dr + " space(s).");
+ commandBaseLog("Game: " + gp.getName() + " must retreat " + dr + " space(s).");
} else {
commandEliminate(gp);
}
}
- commandSetProperty(dataPiece, DEFENDER_RETREAT, 0);
+ commandBaseSetProperty(dataPiece, DEFENDER_RETREAT, 0);
}
if (ar > 0) {
//refresh in case any units were removed
attackers = filter.filterPieces(mainMap, T_ATTACKER + ">0");
//
for (GamePiece gp : attackers) {
- commandSetProperty(gp, T_RETREATING, ar);
+ commandBaseSetProperty(gp, T_RETREATING, ar);
if (TerrainMapShaderRule.hasNonTraceHexes(getRetreatHexes(gp))) {
- commandLog("Game: " + gp.getName() + " must retreat " + ar + " space(s).");
+ commandBaseLog("Game: " + gp.getName() + " must retreat " + ar + " space(s).");
} else {
commandEliminate(gp);
}
}
- commandSetProperty(dataPiece, ATTACKER_RETREAT, 0);
+ commandBaseSetProperty(dataPiece, ATTACKER_RETREAT, 0);
}
if ((RsrGlobal.getMotorizedLossRequired() > 0) || (RsrGlobal.getContestedLossRequired() > 0)) {
- commandLog("Game: There are units that have to take mandatory step loss(es).");
+ commandBaseLog("Game: There are units that have to take mandatory step loss(es).");
return;
} else
if (filter.filterPieces(mainMap, T_RETREATING + ">0").size() == 0) {
//clear just reatreated units
for (GamePiece gp : filter.filterPieces(mainMap, T_RETREATING + "<0")) {
- commandSetProperty(gp, T_RETREATING, 0);
+ commandBaseSetProperty(gp, T_RETREATING, 0);
}
- commandSetProperty(dataPiece, COMBAT_STAGE, ++combatStage);
+ commandBaseSetProperty(dataPiece, COMBAT_STAGE, ++combatStage);
} else {
- commandLog("Game: There are units that have to retreat.");
+ commandBaseLog("Game: There are units that have to retreat.");
return;
}
}
if (combatStage == 5) {
//apply urban test for motorized units
if (RsrGlobal.getUrbanLossRequired() == 1) {
- commandLog("Game: Applying additional losses to motorized forces that attacked urban area.");
+ commandBaseLog("Game: Applying additional losses to motorized forces that attacked urban area.");
//refresh in case any units were removed
attackers = filter.filterPieces(mainMap, T_ATTACKER + ">0");
int chance;
@@ -1143,7 +1135,7 @@
}
}
}
- commandSetProperty(dataPiece, URBAN_LOSS_REQUIRED, 0);
+ commandBaseSetProperty(dataPiece, URBAN_LOSS_REQUIRED, 0);
}
//find victorious units
int victorious = 0;
@@ -1173,12 +1165,12 @@
for (GamePiece gp : defenders) {
advanceRange = getMaximumAdvance(gp);
if (advanceRange > 0) {
- commandSetProperty(gp, T_ADVANCING, advanceRange);
+ commandBaseSetProperty(gp, T_ADVANCING, advanceRange);
if (TerrainMapShaderRule.hasNonTraceHexes(getAdvanceHexes(gp))) {
- commandLog("Game: " + gp.getName() + " may advance up to " + advanceRange + " space(s).");
+ commandBaseLog("Game: " + gp.getName() + " may advance up to " + advanceRange + " space(s).");
victorious++;
} else {
- commandSetProperty(gp, T_ADVANCING, 0);
+ commandBaseSetProperty(gp, T_ADVANCING, 0);
}
}
}
@@ -1215,17 +1207,17 @@
if (combatMode == 0) {
advanceRange = getMaximumAdvance(gp);
if (advanceRange > 0) {
- commandSetProperty(gp, T_ADVANCING, advanceRange);
+ commandBaseSetProperty(gp, T_ADVANCING, advanceRange);
if (TerrainMapShaderRule.hasNonTraceHexes(getAdvanceHexes(gp))) {
- commandLog("Game: " + gp.getName() + " may advance up to " + advanceRange + " space(s).");
+ commandBaseLog("Game: " + gp.getName() + " may advance up to " + advanceRange + " space(s).");
victorious++;
} else {
- commandSetProperty(gp, T_ADVANCING, 0);
+ commandBaseSetProperty(gp, T_ADVANCING, 0);
}
}
} else {
//in overrun combat place attackers in defender hex and remove movement points for overrun
- commandMove(mainMap, gp, p);
+ commandBaseMove(mainMap, gp, p);
double mp = RsrTrait.getMovementLeft(gp) - getOverrunCost(gp);
if (mp > 0.0d) {
commandAllowMovement(gp, mp, false);
@@ -1250,13 +1242,13 @@
}
}
}
- commandSetProperty(dataPiece, COMBAT_STAGE, ++combatStage);
+ commandBaseSetProperty(dataPiece, COMBAT_STAGE, ++combatStage);
//if there are no advances possible, end combat immediately, otherwise let the player decide
if (victorious == 0) {
commandClearCombat();
return;
} else {
- commandLog("Game: Advance victorious units or end combat.");
+ commandBaseLog("Game: Advance victorious units or end combat.");
return;
}
}
@@ -1291,8 +1283,8 @@
property2 = DEFENDER_LOST;
newValue2 = RsrGlobal.getDefenderLost()+1;
}
- commandSetProperty(gp, T_LOST, RsrTrait.getLost(gp) + 1);
- commandSetProperty(dataPiece, property1, newValue1, property2, newValue2);
+ commandBaseSetProperty(gp, T_LOST, RsrTrait.getLost(gp) + 1);
+ commandBaseSetProperty(dataPiece, property1, newValue1, property2, newValue2);
}
public boolean commandRefreshCombatLossList(boolean ignoreOptional) {
@@ -2185,7 +2177,7 @@
}
if (column < 0) {
sb.append(". Attack is impossible due to low odds. Final result is NE.");
- commandLog(sb.toString());
+ commandBaseLog(sb.toString());
return "NE";
} else {
//ensure column is not greater than 9
@@ -2216,7 +2208,7 @@
int moddie = Math.max(0, Math.min(9, modifier + die));
String result = COMBAT_TABLE[column][moddie];
sb.append((modifier > 0 ? ". Die roll modifier is +" + modifier : "") + ". Die roll is " + (die+1) + ". Final result is " + result + ".");
- commandLog(sb.toString());
+ commandBaseLog(sb.toString());
return result;
}
}
@@ -2532,12 +2524,12 @@
public void commandBreakdown(ArrayList<GamePiece> pieces) {
if (pieces.size() != 1) {
- commandLog("Game: Select a single unit for breakdown.");
+ commandBaseLog("Game: Select a single unit for breakdown.");
return;
}
GamePiece gp = pieces.get(0);
if (RsrTrait.getReorganized(gp) > 0) {
- commandLog("Game: No breakdown allowed.");
+ commandBaseLog("Game: No breakdown allowed.");
return;
}
String unitType = RsrTrait.getUnitType(gp);
@@ -2574,27 +2566,27 @@
}
}
if (bb == null) {
- commandLog("Game: No breakdown allowed.");
+ commandBaseLog("Game: No breakdown allowed.");
return;
}
if (bb.size() < req) {
- commandLog("Game: No breakdown if not enough replacement units.");
+ commandBaseLog("Game: No breakdown if not enough replacement units.");
return;
}
if (RsrTrait.getSupplyLevel(gp) != SUPPLY_NORMAL) {
- commandLog("Game: No breakdown if not in supply.");
+ commandBaseLog("Game: No breakdown if not in supply.");
return;
}
HashSet<HexRef> inZOC = isMud() ? new HashSet<HexRef>() : pieceCache.getHexesInZOCEnemy(RsrTrait.getSide(gp));
if (inZOC.contains(getHexRef(gp.getPosition()))) {
- commandLog("Game: No breakdown if in contested space (unless it is a mud turn).");
+ commandBaseLog("Game: No breakdown if in contested space (unless it is a mud turn).");
return;
}
if (Filter.isAny(unitType, "AxisGermanTankCorps", "AxisGermanInfantryCorps")) {
commandSendToPiece(gp, bb.get(0), false);
commandSendToPiece(gp, bb.get(1), false);
if (currentStep == 1) {
- commandSetProperty(bb.get(1), T_CURRENT_STEP, 1);
+ commandBaseSetProperty(bb.get(1), T_CURRENT_STEP, 1);
}
commandSendToOffboardZone(gp, "German Breakdown & Buildup Box");
commandMarkAsReorganized(bb.get(0));
@@ -2602,17 +2594,17 @@
} else if (unitType.equals("AxisGermanMountainCorps")) {
commandSendToPiece(gp, bb.get(0), false);
if (currentStep == 1) {
- commandSetProperty(bb.get(0), T_CURRENT_STEP, 1);
+ commandBaseSetProperty(bb.get(0), T_CURRENT_STEP, 1);
}
commandSendToPiece(gp, bb.get(1), false);
- commandSetProperty(bb.get(1), T_CURRENT_STEP, 1);
+ commandBaseSetProperty(bb.get(1), T_CURRENT_STEP, 1);
commandSendToOffboardZone(gp, "German Breakdown & Buildup Box");
commandMarkAsReorganized(bb.get(0));
commandMarkAsReorganized(bb.get(1));
} else if (Filter.isAny(unitType, "AxisGermanTankBattlegroup", "AxisGermanInfantryBattlegroup", "AxisGermanMountainBattlegroup")) {
- commandSetProperty(gp, T_CURRENT_STEP, 1);
+ commandBaseSetProperty(gp, T_CURRENT_STEP, 1);
commandSendToPiece(gp, bb.get(0), false);
- commandSetProperty(bb.get(0), T_CURRENT_STEP, 1);
+ commandBaseSetProperty(bb.get(0), T_CURRENT_STEP, 1);
commandMarkAsReorganized(gp);
commandMarkAsReorganized(bb.get(0));
} else if (Filter.isAny(unitType, "SovietTankArmy", "SovietInfantryArmy")) {
@@ -2626,7 +2618,7 @@
public void commandBuildup(ArrayList<GamePiece> pieces) {
if (pieces.size() != 2) {
- commandLog("Game: Select two units for buildup.");
+ commandBaseLog("Game: Select two units for buildup.");
return;
}
GamePiece gp1 = pieces.get(0);
@@ -2637,7 +2629,7 @@
gp2 = gpr;
}
if ((RsrTrait.getReorganized(gp1) > 0) && (RsrTrait.getReorganized(gp2) > 0)) { //&& to allow buildup if one unit was part of earlier breakdown
- commandLog("Game: No buildup allowed.");
+ commandBaseLog("Game: No buildup allowed.");
return;
}
String unitType1 = RsrTrait.getUnitType(gp1);
@@ -2671,37 +2663,37 @@
ignoreZOC = true;
}
if (allowed == false) {
- commandLog("Game: No buildup allowed.");
+ commandBaseLog("Game: No buildup allowed.");
return;
}
HexRef hr1 = getHexRef(gp1.getPosition());
HexRef hr2 = getHexRef(gp2.getPosition());
if (hr1.equals(hr2) == false) {
- commandLog("Game: No buildup if not in the same space.");
+ commandBaseLog("Game: No buildup if not in the same space.");
return;
}
if ((RsrTrait.getSupplyLevel(gp1) != SUPPLY_NORMAL) || (RsrTrait.getSupplyLevel(gp2) != SUPPLY_NORMAL)) {
- commandLog("Game: No buildup if not in supply.");
+ commandBaseLog("Game: No buildup if not in supply.");
return;
}
HashSet<HexRef> inZOC = isMud() ? new HashSet<HexRef>() : pieceCache.getHexesInZOCEnemy(RsrTrait.getSide(gp1));
if ((ignoreZOC == false) && (inZOC.contains(hr1))) {
- commandLog("Game: No buildup if in contested space (unless it is a mud turn).");
+ commandBaseLog("Game: No buildup if in contested space (unless it is a mud turn).");
return;
}
if (Filter.isAny(unitType1, "AxisGermanTankCorps", "AxisGermanInfantryCorps", "AxisGermanMountainCorps")) {
- commandSetProperty(gp1, T_CURRENT_STEP, 2);
+ commandBaseSetProperty(gp1, T_CURRENT_STEP, 2);
commandSendToOffboardZone(gp2, "German Breakdown & Buildup Box");
commandMarkAsReorganized(gp1);
} else if (Filter.isAny(unitType1, "AxisGermanTankBattlegroup", "AxisGermanInfantryBattlegroup", "AxisGermanMountainBattlegroup")) {
if ((currentStep1 == 1) && (currentStep2 == 1)) {
- commandSetProperty(gp1, T_CURRENT_STEP, 2);
+ commandBaseSetProperty(gp1, T_CURRENT_STEP, 2);
commandSendToOffboardZone(gp2, "German Breakdown & Buildup Box");
commandMarkAsReorganized(gp1);
} else {
commandSendToPiece(gp1, bb.get(0), false);
if (currentStep1 + currentStep2 == size) {
- commandSetProperty(bb.get(0), T_CURRENT_STEP, 1);
+ commandBaseSetProperty(bb.get(0), T_CURRENT_STEP, 1);
}
commandSendToOffboardZone(gp1, "German Breakdown & Buildup Box");
commandSendToOffboardZone(gp2, "German Breakdown & Buildup Box");
@@ -2717,7 +2709,7 @@
public void commandIncorporate(ArrayList<GamePiece> pieces) {
if (pieces.size() != 2) {
- commandLog("Game: Select two units for incorporation.");
+ commandBaseLog("Game: Select two units for incorporation.");
return;
}
GamePiece gp1 = pieces.get(0);
@@ -2728,7 +2720,7 @@
gp2 = gpr;
}
if ((RsrTrait.getReorganized(gp1) > 0) || (RsrTrait.getReorganized(gp2) > 0)) {
- commandLog("Game: No incorporation allowed.");
+ commandBaseLog("Game: No incorporation allowed.");
return;
}
String unitType1 = RsrTrait.getUnitType(gp1);
@@ -2741,20 +2733,20 @@
allowed = (currentStep1 == 1) && (Filter.isAny(unitType2, "SovietMechanizedCorps", "SovietInfantryCorps", "SovietMarineCorps"));
}
if (allowed == false) {
- commandLog("Game: No incorporation allowed.");
+ commandBaseLog("Game: No incorporation allowed.");
return;
}
HexRef hr1 = getHexRef(gp1.getPosition());
HexRef hr2 = getHexRef(gp2.getPosition());
if (mainGrid.getHexesInRange(hr1, 1).contains(hr2) == false) {
- commandLog("Game: No incorporation if not in adjacent spaces.");
+ commandBaseLog("Game: No incorporation if not in adjacent spaces.");
return;
}
if ((RsrTrait.getSupplyLevel(gp1) != SUPPLY_NORMAL) || (RsrTrait.getSupplyLevel(gp2) != SUPPLY_NORMAL)) {
- commandLog("Game: No incorporation if not in supply.");
+ commandBaseLog("Game: No incorporation if not in supply.");
return;
}
- commandSetProperty(gp1, T_CURRENT_STEP, 2);
+ commandBaseSetProperty(gp1, T_CURRENT_STEP, 2);
commandSendToOffboardZone(gp2, "Force Pool Box");
commandMarkAsReorganized(gp1);
}
Modified: VSQL-src/branches/morvael/rsr/RsrGlobal.java
===================================================================
--- VSQL-src/branches/morvael/rsr/RsrGlobal.java 2009-06-02 13:21:35 UTC (rev 5699)
+++ VSQL-src/branches/morvael/rsr/RsrGlobal.java 2009-06-02 15:17:50 UTC (rev 5700)
@@ -21,7 +21,6 @@
import VASSAL.configure.StringConfigurer;
import VASSAL.counters.Decorator;
import VASSAL.counters.GamePiece;
-import VASSAL.counters.KeyCommand;
import VASSAL.counters.PieceEditor;
import VASSAL.i18n.TranslatablePiece;
import VASSAL.tools.SequenceEncoder;
@@ -63,8 +62,8 @@
private int repositioningRequired = 0;
// dynamic
private GamePiece gp;
- private KeyCommand[] commands0;
- private KeyCommand[] commands1;
+ private RsrKeyCommand[] commands0;
+ private RsrKeyCommand[] commands1;
private static RsrGlobal instance;
@@ -393,25 +392,25 @@
}
@Override
- protected KeyCommand[] myGetKeyCommands() {
+ protected RsrKeyCommand[] myGetKeyCommands() {
if ((commands0 == null) || (commands1 == null)) {
getGamePiece();
- commands0 = new KeyCommand[1];
- commands0[0] = new KeyCommand("Switch to Debug mode", KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), gp, this);
- commands1 = new KeyCommand[7];
- commands1[0] = new KeyCommand("Switch to Normal mode", KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), gp, this);
- commands1[1] = new KeyCommand("Use scenario 1", KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.CTRL_DOWN_MASK), gp, this);
- commands1[2] = new KeyCommand("Use scenario 2", KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.CTRL_DOWN_MASK), gp, this);
- commands1[3] = new KeyCommand("Use scenario 3", KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK), gp, this);
- commands1[4] = new KeyCommand("Use scenario 4", KeyStroke.getKeyStroke(KeyEvent.VK_4, InputEvent.CTRL_DOWN_MASK), gp, this);
- commands1[5] = new KeyCommand("Use scenario 5", KeyStroke.getKeyStroke(KeyEvent.VK_5, InputEvent.CTRL_DOWN_MASK), gp, this);
- commands1[6] = new KeyCommand("Use scenario 6", KeyStroke.getKeyStroke(KeyEvent.VK_6, InputEvent.CTRL_DOWN_MASK), gp, this);
+ commands0 = new RsrKeyCommand[1];
+ commands0[0] = new RsrKeyCommand("Switch to Debug mode", KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), gp, this);
+ commands1 = new RsrKeyCommand[7];
+ commands1[0] = new RsrKeyCommand("Switch to Normal mode", KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), gp, this);
+ commands1[1] = new RsrKeyCommand("Use scenario 1", KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.CTRL_DOWN_MASK), gp, this);
+ commands1[2] = new RsrKeyCommand("Use scenario 2", KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.CTRL_DOWN_MASK), gp, this);
+ commands1[3] = new RsrKeyCommand("Use scenario 3", KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK), gp, this);
+ commands1[4] = new RsrKeyCommand("Use scenario 4", KeyStroke.getKeyStroke(KeyEvent.VK_4, InputEvent.CTRL_DOWN_MASK), gp, this);
+ commands1[5] = new RsrKeyCommand("Use scenario 5", KeyStroke.getKeyStroke(KeyEvent.VK_5, InputEvent.CTRL_DOWN_MASK), gp, this);
+ commands1[6] = new RsrKeyCommand("Use scenario 6", KeyStroke.getKeyStroke(KeyEvent.VK_6, InputEvent.CTRL_DOWN_MASK), gp, this);
}
return debug == 0 ? commands0 : commands1;
}
public Command myKeyEvent(KeyStroke stroke) {
- KeyCommand[] commands = myGetKeyCommands();
+ RsrKeyCommand[] commands = myGetKeyCommands();
int match = -1;
for (int i = 0; i < commands.length; i++) {
if (commands[i].getKeyStroke().equals(stroke)) {
Modified: VSQL-src/branches/morvael/rsr/RsrImmobilized.java
===================================================================
--- VSQL-src/branches/morvael/rsr/RsrImmobilized.java 2009-06-02 13:21:35 UTC (rev 5699)
+++ VSQL-src/branches/morvael/rsr/RsrImmobilized.java 2009-06-02 15:17:50 UTC (rev 5700)
@@ -11,7 +11,6 @@
import VASSAL.counters.Decorator;
import VASSAL.counters.EditablePiece;
import VASSAL.counters.GamePiece;
-import VASSAL.counters.KeyCommand;
import VASSAL.counters.PieceEditor;
import VASSAL.counters.Properties;
import VASSAL.tools.SequenceEncoder;
@@ -43,8 +42,8 @@
return piece.getName();
}
- public KeyCommand[] myGetKeyCommands() {
- return new KeyCommand[0];
+ public RsrKeyCommand[] myGetKeyCommands() {
+ return new RsrKeyCommand[0];
}
public Command myKeyEvent(KeyStroke e) {
Added: VSQL-src/branches/morvael/rsr/RsrKeyCommand.java
===================================================================
--- VSQL-src/branches/morvael/rsr/RsrKeyCommand.java (rev 0)
+++ VSQL-src/branches/morvael/rsr/RsrKeyCommand.java 2009-06-02 15:17:50 UTC (rev 5700)
@@ -0,0 +1,54 @@
+package rsr;
+
+import VASSAL.counters.Decorator;
+import VASSAL.counters.GamePiece;
+import VASSAL.counters.KeyCommand;
+import VASSAL.i18n.TranslatablePiece;
+import VASSAL.tools.NamedKeyStroke;
+import java.awt.event.ActionEvent;
+import javax.swing.KeyStroke;
+
+/**
+ *
+ * @author derwido
+ * @since 2009-06-02
+ */
+public class RsrKeyCommand extends KeyCommand {
+
+ public RsrKeyCommand(String name, KeyStroke key, GamePiece target) {
+ super(name, key, target);
+ }
+
+ public RsrKeyCommand(String name, NamedKeyStroke key, GamePiece target) {
+ super(name, key, target);
+ }
+
+ public RsrKeyCommand(String name, KeyStroke key, GamePiece target, TranslatablePiece i18nPiece) {
+ super(name, key, target, i18nPiece);
+ }
+
+ public RsrKeyCommand(String name, NamedKeyStroke key, GamePiece target, TranslatablePiece i18nPiece) {
+ super(name, key, target, i18nPiece);
+ }
+
+ public RsrKeyCommand(String name, NamedKeyStroke key, GamePiece target, boolean enabled) {
+ super(name, key, target, enabled);
+ }
+
+ public RsrKeyCommand(String name, KeyStroke key, GamePiece target, boolean enabled) {
+ super(name, key, target, enabled);
+ }
+
+ public RsrKeyCommand(RsrKeyCommand command) {
+ super(command);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ if (getKeyStroke() != null) {
+ Decorator.getOutermost(getTarget()).keyEvent(getKeyStroke());
+ RsrAdvance.getInstance().sendAndLog();
+ }
+ }
+
+}
Modified: VSQL-src/branches/morvael/rsr/RsrPieceMover.java
===================================================================
--- VSQL-src/branches/morvael/rsr/RsrPieceMover.java 2009-06-02 13:21:35 UTC (rev 5699)
+++ VSQL-src/branches/morvael/rsr/RsrPieceMover.java 2009-06-02 15:17:50 UTC (rev 5700)
@@ -144,9 +144,9 @@
protected void performDrop(Point p) {
PieceIterator it = DragBuffer.getBuffer().getIterator();
while (it.hasMoreElements()) {
- RsrAdvance.getInstance().commandMove(map, it.nextPiece(), p);
+ RsrAdvance.getInstance().commandBaseMove(map, it.nextPiece(), p);
}
- RsrAdvance.getInstance().commandReportMoves();
+ RsrAdvance.getInstance().commandBaseReportMoves();
DragBuffer.getBuffer().clear();
}
Modified: VSQL-src/branches/morvael/rsr/RsrTrait.java
===================================================================
--- VSQL-src/branches/morvael/rsr/RsrTrait.java 2009-06-02 13:21:35 UTC (rev 5699)
+++ VSQL-src/branches/morvael/rsr/RsrTrait.java 2009-06-02 15:17:50 UTC (rev 5700)
@@ -17,7 +17,6 @@
import VASSAL.configure.StringConfigurer;
import VASSAL.counters.Decorator;
import VASSAL.counters.GamePiece;
-import VASSAL.counters.KeyCommand;
import VASSAL.counters.PieceEditor;
import VASSAL.i18n.TranslatablePiece;
import VASSAL.tools.SequenceEncoder;
@@ -65,7 +64,7 @@
private int repositioning = 0;
// dynamic counter information (volatile)
private GamePiece gp;
- private KeyCommand[] commands;
+ private RsrKeyCommand[] commands;
//common to all traits
private static RsrAdvance core;
@@ -585,7 +584,7 @@
}
@Override
- protected KeyCommand[] myGetKeyCommands() {
+ protected RsrKeyCommand[] myGetKeyCommands() {
commands = getCore().getCommands(this, getGamePiece());
return commands;
}
@@ -688,7 +687,7 @@
//T_DISPLAY_STRENGTH is set due to T_CURRENT_STEP and T_SUPPLY_LEVEL
//T_DISPLAYED_ATTACK is set due to T_CURRENT_STEP and T_SUPPLY_LEVEL
//T_DISPLAYED_DEFENCE is set due to T_CURRENT_STEP and T_SUPPLY_LEVEL
- getCore().commandSetProperty(gp,
+ getCore().commandBaseSetProperty(gp,
//external elements (Markers)
PROPERTY_SUPPLY_MODE, 1,
//RsrTrait elements
@@ -716,7 +715,7 @@
}
public static void commandClearCombatAttributes(GamePiece gp, boolean attacked) {
- getCore().commandSetProperty(gp,
+ getCore().commandBaseSetProperty(gp,
T_HL_LOSS, 0,
T_ATTACKER, 0,
T_DEFENDER, 0,
@@ -730,7 +729,7 @@
public static void commandCopyAttributes(GamePiece from, GamePiece to) {
double dif = getMovement(to) - getMovement(from);
double mov = Math.max(0, getMovementLeft(from) + dif);
- getCore().commandSetProperty(to,
+ getCore().commandBaseSetProperty(to,
//RsrTrait elements
T_HL_LOSS, getHlLoss(from),
T_HL_ACTION, getHlAction(from),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|