Fixing "Armor" to work only in Skirmish phase.

Moving animations to separate JS file.
Preventing non-players from conceding the game.
This commit is contained in:
marcins78@gmail.com
2011-09-21 22:53:57 +00:00
parent f40e7fea93
commit af93d4d435
5 changed files with 74 additions and 59 deletions

View File

@@ -39,7 +39,8 @@ public class Card1_092 extends AbstractAttachableFPPossession {
@Override @Override
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) { public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (PlayConditions.isWounded(effectResult, self.getAttachedTo())) { if (PlayConditions.isWounded(effectResult, self.getAttachedTo())
&& game.getGameState().getCurrentPhase() == Phase.SKIRMISH) {
RequiredTriggerAction action = new RequiredTriggerAction(self, null, "Apply damage prevention"); RequiredTriggerAction action = new RequiredTriggerAction(self, null, "Apply damage prevention");
action.addEffect(new CardAffectsCardEffect(self, self.getAttachedTo())); action.addEffect(new CardAffectsCardEffect(self, self.getAttachedTo()));
action.addEffect( action.addEffect(

View File

@@ -167,7 +167,7 @@ public class LotroGameMediator {
public void concede(String playerId) { public void concede(String playerId) {
_writeLock.lock(); _writeLock.lock();
try { try {
if (_lotroGame.getWinnerPlayerId() == null) if (_lotroGame.getWinnerPlayerId() == null && _playersPlaying.contains(playerId))
_lotroGame.playerLost(playerId, "Concession"); _lotroGame.playerLost(playerId, "Concession");
} finally { } finally {
_writeLock.unlock(); _writeLock.unlock();

View File

@@ -128,6 +128,7 @@
<script type="text/javascript" src="js/communication.js"></script> <script type="text/javascript" src="js/communication.js"></script>
<script type="text/javascript" src="js/chat.js"></script> <script type="text/javascript" src="js/chat.js"></script>
<script type="text/javascript" src="js/gameUi.js"></script> <script type="text/javascript" src="js/gameUi.js"></script>
<script type="text/javascript" src="js/gameAnimations.js"></script>
<script type="text/javascript" src="js/jCardGroup.js"></script> <script type="text/javascript" src="js/jCardGroup.js"></script>
<script type="text/javascript" src="js/jCards.js"></script> <script type="text/javascript" src="js/jCards.js"></script>
<script type="text/javascript" src="js/logging.js"></script> <script type="text/javascript" src="js/logging.js"></script>

View File

@@ -0,0 +1,65 @@
var GameAnimations = Class.extend({
game: null,
animationEffectDiv: null,
init: function(gameUI) {
this.game = gameUI;
this.animationEffectDiv = $("<div id='animation'></div>");
this.animationEffectDiv.hide();
$("#main").append(this.animationEffectDiv);
},
cardAffectsCard: function(element) {
var participantId = element.getAttribute("participantId");
var blueprintId = element.getAttribute("blueprintId");
var targetCardId = element.getAttribute("targetCardId");
this.animationEffectDiv.queue("anim",
function(next) {
var targetCard = $(".card:cardId(" + targetCardId + ")");
if (targetCard.length > 0) {
var card = new Card(blueprintId, "ANIMATION", "anim", participantId);
var cardDiv = createCardDiv(card.imageUrl);
cardDiv.data("card", card);
targetCard = targetCard[0];
$("#animation").html(cardDiv);
$("#animation").show();
var targetCardWidth = $(targetCard).width();
var targetCardHeight = $(targetCard).height();
var maxDimension = Math.max(targetCardWidth, targetCardHeight);
var borderWidth = Math.floor(maxDimension / 30);
var endBorderWidth = Math.floor(maxDimension * 2 / 30);
$("#animation").css({
position: "absolute",
left: $(targetCard).position().left,
top: $(targetCard).position().top,
width: targetCardWidth,
height: targetCardHeight,
"z-index": 100,
opacity: 1});
$("#animation").animate(
{
opacity: 0,
left: "-=" + (targetCardWidth / 2),
top: "-=" + (targetCardHeight / 2),
width: "+=" + targetCardWidth,
height: "+=" + targetCardHeight},
{
duration: 800,
easing: "easeInCubic",
queue: false,
complete: next
});
}
}).queue("anim",
function(next) {
$("#animation").hide();
next();
}).dequeue("anim");
}
});

View File

@@ -54,11 +54,14 @@ var GempLotrGameUI = Class.extend({
tabPane: null, tabPane: null,
animationEffectDiv: null, animations: null,
init: function(url) { init: function(url) {
log("ui initialized"); log("ui initialized");
var that = this; var that = this;
this.animations = new GameAnimations(this);
this.communication = new GempLotrCommunication("/gemp-lotr/server", this.communication = new GempLotrCommunication("/gemp-lotr/server",
function() { function() {
that.chatBox.appendMessage("There was a problem communicating with the server, if the game is finished, it has been removed, otherwise you have lost connection to the server.", "warningMessage"); that.chatBox.appendMessage("There was a problem communicating with the server, if the game is finished, it has been removed, otherwise you have lost connection to the server.", "warningMessage");
@@ -182,9 +185,6 @@ var GempLotrGameUI = Class.extend({
that.clickCardFunction(event); that.clickCardFunction(event);
}); });
this.animationEffectDiv = $("<div id='animation'></div>");
this.animationEffectDiv.hide();
$("#main").append(this.animationEffectDiv);
}, },
addBottomLeftTabPane: function() { addBottomLeftTabPane: function() {
@@ -517,7 +517,7 @@ var GempLotrGameUI = Class.extend({
var gameEvent = gameEvents[i]; var gameEvent = gameEvents[i];
var eventType = gameEvent.getAttribute("type"); var eventType = gameEvent.getAttribute("type");
if (eventType == "CARD_AFFECTS_CARD") { if (eventType == "CARD_AFFECTS_CARD") {
this.cardAffectsCard(gameEvent); this.animations.cardAffectsCard(gameEvent);
} }
} }
@@ -648,58 +648,6 @@ var GempLotrGameUI = Class.extend({
this.chatBox.appendMessage(message, "warningMessage"); this.chatBox.appendMessage(message, "warningMessage");
}, },
cardAffectsCard: function(element) {
var participantId = element.getAttribute("participantId");
var blueprintId = element.getAttribute("blueprintId");
var targetCardId = element.getAttribute("targetCardId");
var card = new Card(blueprintId, "ANIMATION", "anim", participantId);
var cardDiv = createCardDiv(card.imageUrl);
cardDiv.data("card", card);
this.animationEffectDiv.queue("anim",
function(next) {
var targetCard = $(".card:cardId(" + targetCardId + ")");
if (targetCard.length > 0) {
targetCard = targetCard[0];
$("#animation").html(cardDiv);
$("#animation").show();
var targetCardWidth = $(targetCard).width();
var targetCardHeight = $(targetCard).height();
var maxDimension = Math.max(targetCardWidth, targetCardHeight);
var borderWidth = Math.floor(maxDimension / 30);
var endBorderWidth = Math.floor(maxDimension * 2 / 30);
$("#animation").css({
position: "absolute",
left: $(targetCard).position().left,
top: $(targetCard).position().top,
width: targetCardWidth,
height: targetCardHeight,
"z-index": 100,
opacity: 1});
$("#animation").animate(
{
opacity: 0,
left: "-=" + (targetCardWidth / 2),
top: "-=" + (targetCardHeight / 2),
width: "+=" + targetCardWidth,
height: "+=" + targetCardHeight},
{
duration: 500,
easing: "easeInCubic",
queue: false,
complete: next
});
}
}).queue("anim",
function(next) {
$("#animation").hide();
next();
}).dequeue("anim");
},
startSkirmish: function(element) { startSkirmish: function(element) {
var cardId = element.getAttribute("cardId"); var cardId = element.getAttribute("cardId");
var opposingCardIds = element.getAttribute("opposingCardIds").split(","); var opposingCardIds = element.getAttribute("opposingCardIds").split(",");