From 3f503c7d27879be641abfe41390f86345fe07a45 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Thu, 1 Sep 2011 22:09:59 +0000 Subject: [PATCH] Adding chance of choosing trigger to resolve to UI. --- .../gemp-lotr-web/src/main/webapp/js/ui.js | 64 +++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/ui.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/ui.js index 339a3d0fe..e2832c184 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/ui.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/ui.js @@ -299,8 +299,10 @@ var GempLotrUI = Class.extend({ this.multipleChoiceDecision(decision); } else if (decisionType == "ARBITRARY_CARDS") { this.arbitraryCardsDecision(decision); - } else if (decisionType == "CARD_ACTION_CHOICE") { + } else if (decisionType == "ACTION_CHOICE") { this.actionChoiceDecision(decision); + } else if (decisionType == "CARD_ACTION_CHOICE") { + this.cardActionChoiceDecision(decision); } else if (decisionType == "CARD_SELECTION") { this.cardSelectionDecision(decision); } else if (decisionType == "ASSIGN_MINIONS") { @@ -591,8 +593,8 @@ var GempLotrUI = Class.extend({ this.dialogInstance.dialog("open"); }, - createCardDiv: function(card) { - var cardDiv = $("
"); + createCardDiv: function(card, text) { + var cardDiv = $("
" + ((text != null) ? text : "") + "
"); cardDiv.data("card", card); var borderDiv = $("
"); cardDiv.append(borderDiv); @@ -673,7 +675,7 @@ var GempLotrUI = Class.extend({ this.dialogInstance.dialog("open"); }, - actionChoiceDecision: function (decision) { + cardActionChoiceDecision: function (decision) { var id = decision.getAttribute("id"); var text = decision.getAttribute("text"); @@ -717,6 +719,60 @@ var GempLotrUI = Class.extend({ }; }, + actionChoiceDecision: function (decision) { + var id = decision.getAttribute("id"); + var text = decision.getAttribute("text"); + + var blueprintIds = this.getDecisionParameters(decision, "blueprintId"); + var actionIds = this.getDecisionParameters(decision, "actionId"); + var actionTexts = this.getDecisionParameters(decision, "actionText"); + + var that = this; + + this.dialogInstance + .html("
") + .dialog("option", "title", text) + .dialog("option", "buttons", {}) + .dialog("option", "width", "600") + .dialog("option", "height", "300"); + + var cardIds = new Array(); + + for (var i = 0; i < blueprintIds.length; i++) { + var blueprintId = blueprintIds[i]; + + cardIds.push("temp" + i); + var card = new Card(blueprintId, "SPECIAL", "temp" + i, this.selfParticipantId); + + var cardDiv = this.createCardDiv(card, actionTexts[i]); + + $("#arbitraryChoice").append(cardDiv); + } + + this.selectionFunction = function(cardId) { + var actionId = actionIds[parseInt(cardId.substring(4))]; + + this.dialogInstance.dialog("option", "buttons", { + "DONE": function() { + $(this).dialog("close"); + $("#arbitraryChoice").html(""); + that.clearSelection(); + that.decisionFunction(id, "" + actionId); + } + }); + + that.clearSelection(); + $(".card:cardId(" + cardId + ")").addClass("selectedCard"); + }; + + $(".card:cardId(" + cardIds + ")").addClass("selectableCard"); + + this.specialGroup.setBounds(10, 10, 547, 188); + + $(".ui-dialog-titlebar").show(); + this.dialogInstance.dialog("open"); + }, + cardSelectionDecision: function(decision) { var id = decision.getAttribute("id"); var text = decision.getAttribute("text");