From 16555e24b285930462b9a60b3b874e12738ad33e Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Fri, 16 Sep 2011 19:18:13 +0000 Subject: [PATCH] Skirmish strength for both sides, "chess-clock"s and tokens scale with cards. --- .../gemp-lotr-web/src/main/webapp/game.html | 6 +- .../src/main/webapp/js/gameUi.js | 112 +++++++++--------- .../src/main/webapp/js/jCardGroup.js | 6 +- gemp-lotr/todo.txt | 4 +- 4 files changed, 66 insertions(+), 62 deletions(-) diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html index b44f67678..fb371c293 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html @@ -58,11 +58,13 @@ } .fpStrength, .shadowStrength { + border-radius: 6px; text-align: center; vertical-align: middle; background-color: #ffffff; - opacity: 0.5; + opacity: 0.7; color: #000000; + font-size: 300%; } #chatBox { @@ -91,7 +93,7 @@ .clock { float: right; - font-size: 70%; + font-size: 100%; } .ui-button-text-only .ui-button-text { diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js index b3e7740f4..566a652d8 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js @@ -205,21 +205,21 @@ var GempLotrGameUI = Class.extend({ initializeDialogs: function() { this.smallDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: false, - resizable: false, - width: 400, - height: 200 - }); + autoOpen: false, + closeOnEscape: false, + resizable: false, + width: 400, + height: 200 + }); this.cardActionDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: false, - resizable: true, - width: 600, - height: 300 - }); + autoOpen: false, + closeOnEscape: false, + resizable: true, + width: 600, + height: 300 + }); var that = this; @@ -231,15 +231,15 @@ var GempLotrGameUI = Class.extend({ this.infoDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: true, - resizable: true, - title: "Card information", - minHeight: 80, - minWidth: 200, - width: 600, - height: 300 - }); + autoOpen: false, + closeOnEscape: true, + resizable: true, + title: "Card information", + minHeight: 80, + minWidth: 200, + width: 600, + height: 300 + }); var swipeOptions = { threshold: 20, @@ -311,13 +311,13 @@ var GempLotrGameUI = Class.extend({ if (currentPlayerTurn) { this.skirmishShadowGroup.setBounds(x + 3, y + 3, groupWidth - 6, heightScales[2] * heightPerScale - 6); this.skirmishFellowshipGroup.setBounds(x + 3, y + heightScales[2] * heightPerScale + padding + 3, groupWidth - 6, heightScales[3] * heightPerScale - 6); - this.fpStrengthDiv.css({position: "relative", left: 2 + "px", top: groupHeight - strengthBoxSize - 2 + "px", width: strengthBoxSize, height: strengthBoxSize, "z-index": 50}); - this.shadowStrengthDiv.css({position: "relative", left: 2 + "px", top: 2 + "px", width: strengthBoxSize, height: strengthBoxSize, "z-index": 50}); + this.fpStrengthDiv.css({position: "absolute", left: groupWidth - strengthBoxSize - 2 + "px", top: groupHeight - strengthBoxSize - 2 + "px", width: strengthBoxSize, height: strengthBoxSize, "z-index": 50}); + this.shadowStrengthDiv.css({position: "absolute", left: groupWidth - strengthBoxSize - 2 + "px", top: 2 + "px", width: strengthBoxSize, height: strengthBoxSize, "z-index": 50}); } else { this.skirmishFellowshipGroup.setBounds(x + 3, y + 3, groupWidth - 6, heightScales[1] * heightPerScale - 6); this.skirmishShadowGroup.setBounds(x + 3, y + heightScales[1] * heightPerScale + padding + 3, groupWidth - 6, heightScales[2] * heightPerScale - 6); - this.shadowStrengthDiv.css({position: "relative", left: 2 + "px", top: groupHeight - strengthBoxSize - 2 + "px", width: strengthBoxSize, height: strengthBoxSize, "z-index": 50}); - this.fpStrengthDiv.css({position: "relative", left: 2 + "px", top: 2 + "px", width: strengthBoxSize, height: strengthBoxSize, "z-index": 50}); + this.shadowStrengthDiv.css({position: "absolute", left: groupWidth - strengthBoxSize - 2 + "px", top: groupHeight - strengthBoxSize - 2 + "px", width: strengthBoxSize, height: strengthBoxSize, "z-index": 50}); + this.fpStrengthDiv.css({position: "absolute", left: groupWidth - strengthBoxSize - 2 + "px", top: 2 + "px", width: strengthBoxSize, height: strengthBoxSize, "z-index": 50}); } i++; } @@ -436,23 +436,25 @@ var GempLotrGameUI = Class.extend({ this.shadowStrengthDiv.text(skirmish[0].getAttribute("shadowStrength")); } - var clocks = element.getElementsByTagName("clocks")[0].getElementsByTagName("clock"); - for (var i = 0; i < clocks.length; i++) { - var clock = clocks[i]; - var participantId = clock.getAttribute("participantId"); - var index = -1; - for (var plId = 0; plId < this.allPlayerIds.length; plId++) - if (this.allPlayerIds[plId] == participantId) - index = plId; + if (this.allPlayerIds != null) { + var clocks = element.getElementsByTagName("clocks")[0].getElementsByTagName("clock"); + for (var i = 0; i < clocks.length; i++) { + var clock = clocks[i]; + var participantId = clock.getAttribute("participantId"); + var index = -1; + for (var plId = 0; plId < this.allPlayerIds.length; plId++) + if (this.allPlayerIds[plId] == participantId) + index = plId; - var value = parseInt(clock.childNodes[0].nodeValue); + var value = parseInt(clock.childNodes[0].nodeValue); - var sign = (value < 0) ? "-" : ""; - value = Math.abs(value); - var minutes = Math.floor(value / 60); - var seconds = value % 60; + var sign = (value < 0) ? "-" : ""; + value = Math.abs(value); + var minutes = Math.floor(value / 60); + var seconds = value % 60; - $("#clock" + index).text(sign + minutes + ":" + seconds); + $("#clock" + index).text(sign + minutes + ":" + seconds); + } } if (gameEvents.length > 0) @@ -641,7 +643,7 @@ var GempLotrGameUI = Class.extend({ if (index != -1) cardData.attachedCards.splice(index, 1); } - ); + ); var card = $(".card:cardId(" + cardId + ")"); var cardData = card.data("card"); @@ -704,7 +706,7 @@ var GempLotrGameUI = Class.extend({ if (index != -1) cardData.attachedCards.splice(index, 1); } - ); + ); } card.remove(); @@ -771,13 +773,13 @@ var GempLotrGameUI = Class.extend({ this.smallDialog .html(text + "
") .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', typedata: { @@ -808,13 +810,13 @@ var GempLotrGameUI = Class.extend({ this.smallDialog .html(html) .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"); }, diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js index 236021f61..84004aa4c 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js @@ -47,7 +47,7 @@ var CardGroup = Class.extend({ borderOverlay.css({position: "absolute", left: 0 + "px", top: 0 + "px", width: width - 4, height: height - 4}); var maxDimension = Math.max(width, height); - var tokenSize = Math.floor(maxDimension / 20) * 2; + var tokenSize = Math.floor(maxDimension / 12) * 2; var tokens = cardElem.data("card").tokens; if (tokens != null) { @@ -64,7 +64,7 @@ var CardGroup = Class.extend({ var tokenCount = tokens[token]; for (var i = 0; i < tokenCount; i++) { - var tokenElem = $("").css({position: "absolute", left: tokenX + "px", top: (tokenSize / 2) * (1 + i) + "px"}); + var tokenElem = $("").css({position: "absolute", left: tokenX + "px", top: (1 * tokenSize / 2) * (1 + i) + "px"}); tokenOverlay.append(tokenElem); } tokenIndex ++; @@ -101,7 +101,7 @@ var AdvPathCardGroup = CardGroup.extend({ function(first, second) { return (first.data("card").siteNumber - second.data("card").siteNumber); } - ); + ); var cardCount = cardsToLayout.length; var totalHeight = 0; diff --git a/gemp-lotr/todo.txt b/gemp-lotr/todo.txt index 48523cc6f..eef6e7ce5 100644 --- a/gemp-lotr/todo.txt +++ b/gemp-lotr/todo.txt @@ -1,8 +1,6 @@ TO DO: Before release: 15. Add join game screen, where players can choose to play and get paired automatically when a pair becomes available. -22. If skirmish is in progress, the total strength of each side should be displayed. -20. Display "chess-clock" for each player. Next priority: 13. Add dead/discard pile displays. @@ -39,3 +37,5 @@ with Filters.sameCard(...) filter. and go with different selection. 18. Add display of site where player is on adventure path. 21. Scale wounds, burdens, other tokens with the card size. +22. If skirmish is in progress, the total strength of each side should be displayed. +20. Display "chess-clock" for each player.