Multiple choice response is now an index of the response, rather than the whole text of it.
This commit is contained in:
@@ -15,18 +15,12 @@ public abstract class MultipleChoiceAwaitingDecision extends AbstractAwaitingDec
|
||||
public final void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
if (result == null)
|
||||
throw new DecisionResultInvalidException();
|
||||
int index = resultIndex(result);
|
||||
if (index < 0)
|
||||
throw new DecisionResultInvalidException();
|
||||
|
||||
validDecisionMade(index, result);
|
||||
}
|
||||
|
||||
private int resultIndex(String result) {
|
||||
for (int i = 0; i < _possibleResults.length; i++) {
|
||||
if (_possibleResults[i].equals(result))
|
||||
return i;
|
||||
try {
|
||||
int index = Integer.parseInt(result);
|
||||
validDecisionMade(index, _possibleResults[index]);
|
||||
} catch (NumberFormatException exp) {
|
||||
throw new DecisionResultInvalidException("Unkown response number");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ public abstract class AbstractAtTest {
|
||||
playerDecided(P2, "0");
|
||||
|
||||
// Seating choice
|
||||
playerDecided(P1, "1");
|
||||
playerDecided(P1, "0");
|
||||
}
|
||||
|
||||
protected void skipMulligans() throws DecisionResultInvalidException {
|
||||
// Mulligans
|
||||
playerDecided(P1, "No");
|
||||
playerDecided(P2, "No");
|
||||
playerDecided(P1, "0");
|
||||
playerDecided(P2, "0");
|
||||
}
|
||||
|
||||
protected void validateContents(String[] array1, String[] array2) {
|
||||
@@ -97,6 +97,14 @@ public abstract class AbstractAtTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getMultipleDecisionIndex(AwaitingDecision awaitingDecision, String result) {
|
||||
String[] actionTexts = (String[]) awaitingDecision.getDecisionParameters().get("results");
|
||||
for (int i = 0; i < actionTexts.length; i++)
|
||||
if (actionTexts[i].equals(result))
|
||||
return String.valueOf(i);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addPlayerDeck(String player, Map<String, LotroDeck> decks, Map<String, Collection<String>> additionalCardsInDeck) {
|
||||
LotroDeck deck = createSimplestDeck();
|
||||
if (additionalCardsInDeck != null) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DeathAtTest extends AbstractAtTest {
|
||||
|
||||
// Decide not to move
|
||||
assertEquals(Phase.REGROUP, _game.getGameState().getCurrentPhase());
|
||||
playerDecided(P1, "No");
|
||||
playerDecided(P1, getMultipleDecisionIndex(_userFeedback.getAwaitingDecision(P1), "No"));
|
||||
|
||||
// Fellowship of player2
|
||||
assertEquals(Phase.FELLOWSHIP, _game.getGameState().getCurrentPhase());
|
||||
|
||||
@@ -233,7 +233,7 @@ public class IndividualCardAtTest extends AbstractAtTest {
|
||||
// End fellowship phase
|
||||
playerDecided(P1, "");
|
||||
|
||||
// End fellowship phase
|
||||
// End shadow phase
|
||||
playerDecided(P2, "");
|
||||
|
||||
playerDecided(P1, "0");
|
||||
@@ -280,4 +280,75 @@ public class IndividualCardAtTest extends AbstractAtTest {
|
||||
|
||||
assertEquals(0, _game.getGameState().getWounds(_game.getGameState().findCardById(Integer.parseInt(legolasCardId))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void endofTheGameGivingDamagePlusOne() throws DecisionResultInvalidException {
|
||||
initializeSimplestGame();
|
||||
|
||||
skipMulligans();
|
||||
|
||||
PhysicalCardImpl aragorn = new PhysicalCardImpl(100, "1_89", P1, _library.getLotroCardBlueprint("1_89"));
|
||||
PhysicalCardImpl urukHaiRaidingParty = new PhysicalCardImpl(100, "1_158", P2, _library.getLotroCardBlueprint("1_158"));
|
||||
PhysicalCardImpl endOfTheGame = new PhysicalCardImpl(100, "10_30", P1, _library.getLotroCardBlueprint("10_30"));
|
||||
|
||||
_game.getGameState().addCardToZone(_game, aragorn, Zone.FREE_CHARACTERS);
|
||||
_game.getGameState().addWound(aragorn);
|
||||
_game.getGameState().addWound(aragorn);
|
||||
_game.getGameState().addWound(aragorn);
|
||||
|
||||
_game.getGameState().addCardToZone(_game, endOfTheGame, Zone.HAND);
|
||||
|
||||
// End fellowship phase
|
||||
playerDecided(P1, "");
|
||||
|
||||
_game.getGameState().addCardToZone(_game, urukHaiRaidingParty, Zone.SHADOW_CHARACTERS);
|
||||
|
||||
// End shadow phase
|
||||
playerDecided(P2, "");
|
||||
|
||||
// End maneuvers phase
|
||||
playerDecided(P1, "");
|
||||
playerDecided(P2, "");
|
||||
|
||||
// End arhcery phase
|
||||
playerDecided(P1, "");
|
||||
playerDecided(P2, "");
|
||||
|
||||
// End assignment phase
|
||||
playerDecided(P1, "");
|
||||
playerDecided(P2, "");
|
||||
|
||||
// Assign
|
||||
playerDecided(P1, aragorn.getCardId() + " " + urukHaiRaidingParty.getCardId());
|
||||
|
||||
// Start skirmish
|
||||
playerDecided(P1, String.valueOf(aragorn.getCardId()));
|
||||
|
||||
AwaitingDecision playSkirmishEvent = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, playSkirmishEvent.getDecisionType());
|
||||
playerDecided(P1, "0");
|
||||
|
||||
assertEquals(10, _game.getModifiersQuerying().getStrength(_game.getGameState(), aragorn));
|
||||
|
||||
// End skirmish phase
|
||||
playerDecided(P2, "");
|
||||
playerDecided(P1, "");
|
||||
|
||||
AwaitingDecision skirmishWinResponse = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.ACTION_CHOICE, skirmishWinResponse.getDecisionType());
|
||||
playerDecided(P1, getCardActionId(skirmishWinResponse, "Required"));
|
||||
|
||||
AwaitingDecision effectChoice = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.MULTIPLE_CHOICE, effectChoice.getDecisionType());
|
||||
|
||||
int index = -1;
|
||||
String[] choices = ((String[]) effectChoice.getDecisionParameters().get("results"));
|
||||
for (int i = 0; i < choices.length; i++)
|
||||
if (choices[i].startsWith("Make "))
|
||||
index = i;
|
||||
|
||||
playerDecided(P1, String.valueOf(index));
|
||||
|
||||
assertEquals(2, _game.getGameState().getWounds(urukHaiRaidingParty));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,21 +609,21 @@ var GempLotrGameUI = Class.extend({
|
||||
initializeDialogs: function() {
|
||||
this.smallDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
width: 400,
|
||||
height: 200
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
width: 400,
|
||||
height: 200
|
||||
});
|
||||
|
||||
this.cardActionDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
resizable: true,
|
||||
width: 600,
|
||||
height: 300
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
resizable: true,
|
||||
width: 600,
|
||||
height: 300
|
||||
});
|
||||
|
||||
var that = this;
|
||||
|
||||
@@ -638,11 +638,11 @@ var GempLotrGameUI = Class.extend({
|
||||
|
||||
this.infoDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: false,
|
||||
title: "Card information"
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: false,
|
||||
title: "Card information"
|
||||
});
|
||||
|
||||
var swipeOptions = {
|
||||
threshold: 20,
|
||||
@@ -1113,12 +1113,12 @@ var GempLotrGameUI = Class.extend({
|
||||
|
||||
if (!this.replayMode) {
|
||||
this.smallDialog.dialog("option", "buttons",
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#integerDecision").val());
|
||||
}
|
||||
});
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#integerDecision").val());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#integerDecision").SpinnerControl({ type: 'range',
|
||||
@@ -1145,7 +1145,7 @@ var GempLotrGameUI = Class.extend({
|
||||
|
||||
var html = text + "<br /><select id='multipleChoiceDecision' selectedIndex='0'>";
|
||||
for (var i = 0; i < results.length; i++)
|
||||
html += "<option value='" + results[i] + "'>" + results[i] + "</option>";
|
||||
html += "<option value='" + i + "'>" + results[i] + "</option>";
|
||||
html += "</select>";
|
||||
|
||||
var that = this;
|
||||
@@ -1154,12 +1154,12 @@ var GempLotrGameUI = Class.extend({
|
||||
|
||||
if (!this.replayMode) {
|
||||
this.smallDialog.dialog("option", "buttons",
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#multipleChoiceDecision").val());
|
||||
}
|
||||
});
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#multipleChoiceDecision").val());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.smallDialog.dialog("open");
|
||||
@@ -1523,8 +1523,8 @@ var GempLotrGameUI = Class.extend({
|
||||
$(div).find('LI.hover').removeClass('hover');
|
||||
$(this).parent().addClass('hover');
|
||||
}).mouseout(function() {
|
||||
$(div).find('LI.hover').removeClass('hover');
|
||||
});
|
||||
$(div).find('LI.hover').removeClass('hover');
|
||||
});
|
||||
|
||||
var getRidOfContextMenu = function() {
|
||||
$(div).remove();
|
||||
|
||||
Reference in New Issue
Block a user