diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/css/gemp-001/game.css b/gemp-lotr/gemp-lotr-async/src/main/web/css/gemp-001/game.css index fad6a3f36..ea7e73026 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/css/gemp-001/game.css +++ b/gemp-lotr/gemp-lotr-async/src/main/web/css/gemp-001/game.css @@ -283,11 +283,16 @@ body { font-size: 70%; } -.clock { + +.gameClock { float: right; font-size: 100%; } +.decisionClock{ + font-size: 150%; +} + .alertButtons .ui-button-text-only .ui-button-text { font-size: 70%; padding: .2em .5em; diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/gameAnimations.js b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/gameAnimations.js index 133e5cee8..d1714bda3 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/gameAnimations.js +++ b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/gameAnimations.js @@ -887,6 +887,18 @@ var GameAnimations = Class.extend({ var that = this; $("#main").queue( function (next) { + that.game.countdownIntervalId = window.setInterval(function(){ + that.game.totalTime -= 1; + that.game.decisionTime += 1; + + if(that.game.allPlayerIds == null) + return; + + var index = that.game.getPlayerIndex(that.game.currentPlayerId); + $("#clock-1").text(that.game.parseTime(that.game.decisionTime)); + $("#clock" + index).text(that.game.parseTime(that.game.totalTime)); + }, 1000); + var decisionType = decision.getAttribute("decisionType"); if (decisionType == "INTEGER") { that.game.integerDecision(decision); @@ -903,7 +915,7 @@ var GameAnimations = Class.extend({ } else if (decisionType == "ASSIGN_MINIONS") { that.game.assignMinionsDecision(decision); } - + if (!animate) that.game.layoutUI(false); diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/gameUi.js b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/gameUi.js index 5cea1d109..3115931d9 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/gameUi.js +++ b/gemp-lotr/gemp-lotr-async/src/main/web/js/gemp-022/gameUi.js @@ -70,6 +70,10 @@ var GempLotrGameUI = Class.extend({ animations: null, replayPlay: false, + + decisionTime: 0, + totalTime: 0, + countdownIntervalId: 0, init: function (url, replayMode) { this.replayMode = replayMode; @@ -301,12 +305,13 @@ var GempLotrGameUI = Class.extend({ this.gameStateElem.css({"border-radius": "7px"}); for (var i = 0; i < this.allPlayerIds.length; i++) { - this.gameStateElem.append("
" + (i + 1) + ". " + this.allPlayerIds[i] + "
" + this.gameStateElem.append("
" + (i + 1) + ". " + this.allPlayerIds[i] + "
" + "
"); } this.gameStateElem.append("
0
"); this.gameStateElem.append("
"); + this.gameStateElem.append("
"); $("#main").append(this.gameStateElem); @@ -463,6 +468,7 @@ var GempLotrGameUI = Class.extend({ }); }, + processGameEnd: function() { var that = this; if(this.allPlayerIds == null) @@ -1125,6 +1131,7 @@ var GempLotrGameUI = Class.extend({ decisionFunction: function (decisionId, result) { var that = this; this.stopAnimatingTitle(); + clearInterval(this.countdownIntervalId); this.communication.gameDecisionMade(decisionId, result, this.channelNumber, function (xml) { @@ -1323,6 +1330,7 @@ var GempLotrGameUI = Class.extend({ } if (this.allPlayerIds != null) { + var clocksXml = element.getElementsByTagName("clocks"); if (clocksXml.length > 0) { var clocks = clocksXml[0].getElementsByTagName("clock"); @@ -1332,17 +1340,13 @@ var GempLotrGameUI = Class.extend({ var index = this.getPlayerIndex(participantId); var value = parseInt(clock.childNodes[0].nodeValue); + + if(this.bottomPlayerId == participantId) + this.totalTime = value; + else if(index == -1) + this.decisionTime = value; - var sign = (value < 0) ? "-" : ""; - value = Math.abs(value); - var hours = Math.floor(value / 3600); - var minutes = Math.floor(value / 60) % 60; - var seconds = value % 60; - - if (hours > 0) - $("#clock" + index).text(sign + hours + ":" + ((minutes < 10) ? ("0" + minutes) : minutes) + ":" + ((seconds < 10) ? ("0" + seconds) : seconds)); - else - $("#clock" + index).text(sign + minutes + ":" + ((seconds < 10) ? ("0" + seconds) : seconds)); + $("#clock" + index).text(this.parseTime(value)); } } } @@ -1354,6 +1358,22 @@ var GempLotrGameUI = Class.extend({ } } catch (e) { this.showErrorDialog("Game error", "There was an error while processing game events in your browser. Reload the game to continue", true, false, false); + console.log(e); + } + }, + + parseTime: function(value) { + var sign = (value < 0) ? "-" : ""; + value = Math.abs(value); + var hours = Math.floor(value / 3600); + var minutes = Math.floor(value / 60) % 60; + var seconds = value % 60; + + if(hours > 0) { + return sign + hours + ":" + ((minutes < 10) ? ("0" + minutes) : minutes) + ":" + ((seconds < 10) ? ("0" + seconds) : seconds); + } + else { + return sign + minutes + ":" + ((seconds < 10) ? ("0" + seconds) : seconds); } },