"Fixing" Athelas and other possesions - basically any card that had multiple possible actions to use, now a context menu pops up with possible actions.

This commit is contained in:
marcins78@gmail.com
2011-09-22 23:17:27 +00:00
parent 72ed85fb6e
commit 60550389d5
4 changed files with 111 additions and 5 deletions

View File

@@ -0,0 +1,48 @@
/* Generic context menu styles */
.contextMenu {
position: absolute;
width: 200px;
z-index: 99999;
border: solid 1px #CCC;
background: #EEE;
padding: 0px;
margin: 0px;
display: none;
}
.contextMenu LI {
list-style: none;
padding: 0px;
margin: 0px;
overflow: hidden;
}
.contextMenu A {
color: #333;
text-decoration: none;
display: block;
line-height: 20px;
height: 20px;
background-position: 6px center;
background-repeat: no-repeat;
outline: none;
padding: 1px 5px;
}
.contextMenu LI.hover A {
color: #FFF;
background-color: #3399FF;
}
.contextMenu LI.disabled A {
color: #AAA;
cursor: default;
}
.contextMenu LI.hover.disabled A {
background-color: transparent;
}
.contextMenu LI.separator {
border-top: solid 1px #CCC;
}

View File

@@ -116,6 +116,7 @@
}
</style>
<link rel="stylesheet" type="text/css" href="css/dark-hive/jquery-ui-1.8.16.custom.css">
<link rel="stylesheet" type="text/css" href="css/jquery.contextMenu.css">
<link rel="stylesheet" type="text/css" href="js/jquery/styles/jquery.spinnercontrol.css">
<script type="text/javascript" src="js/jquery/jquery-1.6.2.js"></script>

View File

@@ -3,6 +3,9 @@
- Changed the main page after logging in to give access to additional documents.
- Changed the play event animation so that player might actually recognize the card.
- The animations are no longer shown to the player who initiated the effect, he should know what he played.
- Fixed Athelas and some other possessions, that could not be used during Fellowship phase if a valid transfer target
could be spotted. The problem was, that in that case there are 2 (or more) possible actions to do with 1 card. Now
a small context menu will show up in that case and user will be able to choose, which action to perform.
21 Sept. 2011
- Increased the time per game per player to 40 minutes, as 30 seems not enough.

View File

@@ -241,7 +241,7 @@ var GempLotrGameUI = Class.extend({
if (event.shiftKey) {
this.displayCardInfo(selectedCardElem.data("card"));
} else if (selectedCardElem.hasClass("selectableCard"))
this.selectionFunction(selectedCardElem.data("card").cardId);
this.selectionFunction(selectedCardElem.data("card").cardId, event);
}
}
}
@@ -1182,12 +1182,12 @@ var GempLotrGameUI = Class.extend({
actions.push({ actionId: actionId, actionText: actionText });
}
that.selectionFunction = function(cardId) {
that.selectionFunction = function(cardId, event) {
var cardIdElem = $(".card:cardId(" + cardId + ")");
var actions = cardIdElem.data("action");
if (actions.length == 1) {
var action = actions[0];
selectedCardIds.push(action.actionId);
var selectActionFunction = function(actionId) {
selectedCardIds.push(actionId);
if (that.settingsAutoAccept) {
finishChoice();
} else {
@@ -1195,6 +1195,13 @@ var GempLotrGameUI = Class.extend({
$(".card:cardId(" + cardId + ")").addClass("selectedCard");
processButtons();
}
};
if (actions.length == 1) {
var action = actions[0];
selectActionFunction(action.actionId);
} else {
that.createActionChoiceContextMenu(actions, event, selectActionFunction);
}
};
@@ -1205,6 +1212,53 @@ var GempLotrGameUI = Class.extend({
processButtons();
},
createActionChoiceContextMenu: function(actions, event, selectActionFunction) {
// Remove context menus that may be showing
$(".contextMenu").remove();
var div = $("<ul class='contextMenu'></ul>");
for (var i = 0; i < actions.length; i++) {
var action = actions[i];
var text = action.actionText;
div.append("<li><a href='#" + action.actionId + "'>" + text + "</a></li>");
}
$("#main").append(div);
var x = event.pageX;
var y = event.pageY;
$(div).css({left: x, top: y}).fadeIn(150);
$(div).find('A').mouseover(function() {
$(div).find('LI.hover').removeClass('hover');
$(this).parent().addClass('hover');
}).mouseout(function() {
$(div).find('LI.hover').removeClass('hover');
});
var getRidOfContextMenu = function() {
$(div).remove();
$(document).unbind("click", getRidOfContextMenu);
return false;
};
// When items are selected
$(div).find('A').unbind('click');
$(div).find('LI:not(.disabled) A').click(function() {
$(document).unbind('click', getRidOfContextMenu);
$(".contextMenu").remove();
var actionId = $(this).attr('href').substr(1);
selectActionFunction(actionId);
return false;
});
// Hide bindings
setTimeout(function() { // Delay for Mozilla
$(document).click(getRidOfContextMenu);
}, 0);
},
// Choosing one action to resolve, for example required triggered actions
actionChoiceDecision: function (decision) {
var id = decision.getAttribute("id");