Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed "Any button" option when filters are selected #2311

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/ui/js/Newgame.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,23 @@ Newgame.getButtonSelectTd = function(player) {
Newgame.activity.buttonList.player,
Newgame.activity.buttonGreyed,
Newgame.activity.playerButton);
} else {
} else if (Newgame.activity.buttonLimits.opponent.button_sets.ANY &&
Newgame.activity.buttonLimits.opponent.tourn_legal.ANY &&
Newgame.activity.buttonLimits.opponent.die_skills.ANY) {
return Newgame.getSelectTd(
'Opponent\'s button',
'opponent_button',
Newgame.activity.buttonList.opponent,
Newgame.activity.buttonGreyed,
Newgame.activity.opponentButton,
'Any button');
} else {
return Newgame.getSelectTd(
'Opponent\'s button',
'opponent_button',
Newgame.activity.buttonList.opponent,
Newgame.activity.buttonGreyed,
Newgame.activity.opponentButton);
}
};

Expand All @@ -601,14 +610,23 @@ Newgame.updateButtonSelectTd = function(player) {
Newgame.activity.buttonList.player,
Newgame.activity.buttonGreyed,
Newgame.activity.playerButton);
} else {
} else if (Newgame.activity.buttonLimits.opponent.button_sets.ANY &&
Newgame.activity.buttonLimits.opponent.tourn_legal.ANY &&
Newgame.activity.buttonLimits.opponent.die_skills.ANY) {
selectid = 'opponent_button';
optionlist = Newgame.getSelectOptionList(
'Opponent\'s button',
Newgame.activity.buttonList.opponent,
Newgame.activity.buttonGreyed,
Newgame.activity.opponentButton,
'Any button');
} else {
selectid = 'opponent_button';
optionlist = Newgame.getSelectOptionList(
'Opponent\'s button',
Newgame.activity.buttonList.opponent,
Newgame.activity.buttonGreyed,
Newgame.activity.opponentButton);
}

var optioncount = optionlist.length;
Expand Down
65 changes: 63 additions & 2 deletions test/src/ui/js/test_Newgame.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,72 @@ test("test_Newgame.getButtonSelectTd", function(assert) {
},
},
'buttonGreyed': { 'Adam Spam': true, },
'buttonLimits': {
'player': {
'button_sets': {
'ANY': true
},
'tourn_legal': {
'ANY': true
},
'die_skills': {
'ANY': true
}
},
'opponent': {
'button_sets': {
'ANY': true,
'limit_opponent_button_sets_50_states': false
},
'tourn_legal': {
'ANY': true
},
'die_skills': {
'ANY': true
}
}
},
'playerButton': null,
'opponentButton': null,
};
var item = Newgame.getButtonSelectTd();
assert.equal(item[0].tagName, "TD", "Return value is of type td");
var playerTd = Newgame.getButtonSelectTd('player')[0];
assert.equal(playerTd.tagName, 'TD', 'Return value is of type td');
assert.equal(playerTd.childElementCount, 1, 'player TD should have one child');
var playerTdSelect = playerTd.firstChild;
assert.equal(playerTdSelect.childElementCount, 3, 'player TD select should have three children');
assert.equal(playerTdSelect.children[0].text, 'Choose your button', 'The first row in the player TD select should ask the player to select a button');
assert.equal(playerTdSelect.children[0].value, '', 'The first row in the player TD select should have an empty value');
assert.equal(playerTdSelect.children[1].text, 'Avis: (4) (4) (10) (12) (X)', 'The second row in the player TD select should show the recipe for Avis');
assert.equal(playerTdSelect.children[1].value, 'Avis', 'The second row in the player TD select should have a value of Avis');
assert.equal(playerTdSelect.children[2].text, 'Jellybean: p(20) s(20) (V) (X)', 'The third row in the player TD select should show the recipe for Jellybean');
assert.equal(playerTdSelect.children[2].value, 'Jellybean', 'The third row in the player TD select should have a value of Jellybean');

var opponentTd = Newgame.getButtonSelectTd('opponent')[0];
assert.equal(opponentTd.tagName, 'TD', 'Return value is of type td');
assert.equal(opponentTd.childElementCount, 1, 'opponent TD should have one child');
var opponentTdSelect = opponentTd.firstChild;
assert.equal(opponentTdSelect.childElementCount, 3, 'opponent TD select should have three children');
assert.equal(opponentTdSelect.children[0].text, 'Any button', 'The first row in the opponent TD select should be any button');
assert.equal(opponentTdSelect.children[0].value, '', 'The first row in the opponent TD select should have an empty value');
assert.equal(opponentTdSelect.children[1].text, 'Avis: (4) (4) (10) (12) (X)', 'The second row in the opponent TD select should show the recipe for Avis');
assert.equal(opponentTdSelect.children[1].value, 'Avis', 'The second row in the opponent TD select should have a value of Avis');
assert.equal(opponentTdSelect.children[2].text, '-- Adam Spam: F(4) F(6) (6) (12) (X)', 'The third row in the opponent TD select should show the recipe for Adam Spam');
assert.equal(opponentTdSelect.children[2].value, 'Adam Spam', 'The third row in the opponent TD select should have a value of Adam Spam');

Newgame.activity.buttonLimits.opponent.button_sets.ANY = false;
Newgame.activity.buttonLimits.opponent.button_sets.limit_opponent_button_sets_50_states = true;

var opponentTdLimited = Newgame.getButtonSelectTd('opponent')[0];
assert.equal(opponentTdLimited.tagName, 'TD', 'Return value is of type td');
assert.equal(opponentTdLimited.childElementCount, 1, 'opponent TD should have one child');
var opponentTdLimitedSelect = opponentTdLimited.firstChild;
assert.equal(opponentTdLimitedSelect.childElementCount, 3, 'limited opponent TD select should have three children');
assert.equal(opponentTdLimitedSelect.children[0].text, 'Choose opponent\'s button', 'The first row in the limited opponent TD select should ask the player to select a button for the opponent');
assert.equal(opponentTdLimitedSelect.children[0].value, '', 'The first row in the limited opponent TD select should have an empty value');
assert.equal(opponentTdLimitedSelect.children[1].text, 'Avis: (4) (4) (10) (12) (X)', 'The second row in the limited opponent TD select should show the recipe for Avis');
assert.equal(opponentTdLimitedSelect.children[1].value, 'Avis', 'The second row in the limited opponent TD select should have a value of Avis');
assert.equal(opponentTdLimitedSelect.children[2].text, '-- Adam Spam: F(4) F(6) (6) (12) (X)', 'The third row in the limited opponent TD select should show the recipe for Adam Spam');
assert.equal(opponentTdLimitedSelect.children[2].value, 'Adam Spam', 'The third row in the limited opponent TD select should have a value of Adam Spam');
});

test("test_Newgame.updateButtonSelectTd", function(assert) {
Expand Down