1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-11-23 19:36:53 +00:00

some notification changes

This commit is contained in:
exane 2015-06-30 13:43:03 +02:00
parent 4863e0e634
commit 521116027e
5 changed files with 64 additions and 25 deletions

View File

@ -865,6 +865,9 @@ let Preview = Backbone.View.extend({
let Notification = Backbone.View.extend({ let Notification = Backbone.View.extend({
className: "notification", className: "notification",
template: require("../templates/notification.handlebars"), template: require("../templates/notification.handlebars"),
events: {
"click .alert": "onClick"
},
initialize: function(opt){ initialize: function(opt){
this.opt = opt; this.opt = opt;
$(".notifications").append(this.el); $(".notifications").append(this.el);
@ -880,7 +883,7 @@ let Notification = Backbone.View.extend({
}, { }, {
duration: 600, duration: 600,
complete: this.hide.bind(this) complete: this.hide.bind(this)
}).delay(2500); }).delay(2000);
}, },
hide: function(){ hide: function(){
@ -889,6 +892,9 @@ let Notification = Backbone.View.extend({
}, { }, {
complete: this.remove.bind(this) complete: this.remove.bind(this)
}) })
},
onClick: function(e) {
this.remove();
} }
}); });

View File

@ -304,13 +304,15 @@ $game-height: 800px;
position: absolute; position: absolute;
top: 0; top: 0;
z-index: 200; z-index: 200;
width: 100%; width: 500px;
left: calc(50% - (500px/2));
} }
.notification { .notification {
height: 0; height: 0;
margin-left: 250px; /*margin-left: 250px;
margin-right: 250px; margin-right: 250px;*/
.alert { .alert {
margin-bottom: 0; margin-bottom: 0;

View File

@ -20,7 +20,7 @@
{{#if inMatchmakerQueue}}<img src="../site/public/assets/img/content-load.gif" width=20 style="margin: 5px;"> {{/if}} {{#if inMatchmakerQueue}}<img src="../site/public/assets/img/content-load.gif" width=20 style="margin: 5px;"> {{/if}}
</button> </button>
<!--<button type="button" class="btn btn-primary join-room">Join Room</button>--> <!--<button type="button" class="btn btn-primary join-room">Join Room</button>-->
<!--<button type="button" class="btn btn-success note">debug note</button>--> <button type="button" class="btn btn-success note">debug note</button>
</div> </div>
</div> </div>

View File

@ -133,6 +133,7 @@ var Battle = (function(){
this.waitForScoiatael(this.p2); this.waitForScoiatael(this.p2);
} }
else { else {
this.sendNotification(loser.getName() + " begins!");
this.switchTurn(loser); this.switchTurn(loser);
} }
} }
@ -147,6 +148,7 @@ var Battle = (function(){
if(data.side !== "p1" && data.side !== "p2") if(data.side !== "p1" && data.side !== "p2")
throw new Error("Unknown side property! - ", data.side); throw new Error("Unknown side property! - ", data.side);
self.sendNotification(side.getName() + " choose " + self[data.side].getName());
self.switchTurn(self[data.side]); self.switchTurn(self[data.side]);
}) })
} }

View File

@ -56,6 +56,7 @@ Battleside = (function(){
ability.onActivate.apply(self); ability.onActivate.apply(self);
leaderCard.setDisabled(true); leaderCard.setDisabled(true);
self.battle.sendNotification(self.getName() + " activated " + leaderCard.getName() + "! (leadercard)");
self.update(); self.update();
}) })
this.receive("play:cardFromHand", function(data){ this.receive("play:cardFromHand", function(data){
@ -78,6 +79,8 @@ Battleside = (function(){
this.receive("set:passing", function(){ this.receive("set:passing", function(){
self.setPassing(true); self.setPassing(true);
self.update(); self.update();
self.battle.sendNotification(self.getName() + " passed!");
self.runEvent("NextTurn", null, [self.foe]); self.runEvent("NextTurn", null, [self.foe]);
}) })
this.receive("medic:chooseCardFromDiscard", function(data){ this.receive("medic:chooseCardFromDiscard", function(data){
@ -321,7 +324,11 @@ Battleside = (function(){
} }
this.checkAbilities(card, obj); this.checkAbilities(card, obj);
if(obj._cancelPlacement && !obj.forceField) return 0; if(obj._cancelPlacement && !obj.forceField){
//this.battle.sendNotification(this.getName() + " played " + card.getName() + "!");
return 0;
}
if(obj._nextTurn && !obj.forceField){ if(obj._nextTurn && !obj.forceField){
this.update(); this.update();
this.runEvent("NextTurn", null, [this.foe]); this.runEvent("NextTurn", null, [this.foe]);
@ -390,6 +397,8 @@ Battleside = (function(){
disabled: true disabled: true
}); });
self.hand.remove(card); self.hand.remove(card);
self.battle.sendNotification(self.getName() + " played " + card.getName());
}) })
} }
@ -495,6 +504,7 @@ Battleside = (function(){
self.update(); self.update();
self.runEvent("NextTurn", null, [self.foe]); self.runEvent("NextTurn", null, [self.foe]);
self.battle.sendNotification(self.getName() + " played Decoy!");
}) })
} }
if(ability.onEachTurn){ if(ability.onEachTurn){
@ -527,14 +537,19 @@ Battleside = (function(){
} }
} }
r.setWeather = function(weather){ r.setWeather = function(weather, opt){
var targetRow = weather; var targetRow = weather;
var field; var field;
if(typeof targetRow === "undefined") return; if(typeof targetRow === "undefined") return;
opt = opt || {};
var onRoundEnd = opt.onTurnEnd || false;
//console.log(this.field[Card.TYPE.WEATHER]); //console.log(this.field[Card.TYPE.WEATHER]);
if(targetRow === Card.TYPE.WEATHER){ if(targetRow === Card.TYPE.WEATHER){
if(!onRoundEnd){
this.battle.sendNotification(this.getName() + " played Clear Weather!");
}
field = this.field[targetRow]; field = this.field[targetRow];
field.removeAll(); field.removeAll();
@ -576,7 +591,19 @@ Battleside = (function(){
var cards = field.getHighestCards(); var cards = field.getHighestCards();
var removeCards = field.removeCard(cards); var removeCards = field.removeCard(cards);
side.addToDiscard(removeCards);/*
this.battle.sendNotification(this.getName() + " played " + card.getName());
var txt = "Scorch destroyed:\n";
for (var i = 0; i < removeCards.length; i++) {
var c = removeCards[i];
txt += c.getName() + "\n";
}
this.battle.sendNotification(txt);
side.addToDiscard(removeCards);
/*
this.hand.remove(card); this.hand.remove(card);
this.addToDiscard(card);*/ this.addToDiscard(card);*/
} }
@ -631,7 +658,9 @@ Battleside = (function(){
r.resetNewRound = function(){ r.resetNewRound = function(){
this.clearMainFields(); this.clearMainFields();
this.setWeather(5); //clear weather this.setWeather(5, {
onTurnEnd: true
}); //clear weather
this.setPassing(false); this.setPassing(false);
} }