mirror of
https://github.com/exane/not-gwent-online
synced 2024-11-20 11:26:54 +00:00
lobby changes
This commit is contained in:
parent
f9a2278b64
commit
cdbb5443af
BIN
assets/content-load.gif
Normal file
BIN
assets/content-load.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
@ -49,6 +49,14 @@ let App = Backbone.Router.extend({
|
||||
},
|
||||
connect: function(){
|
||||
this.socket = socket(Config.Server.hostname + ":" + Config.Server.port);
|
||||
var self = this;
|
||||
console.log(this.socket.connected);
|
||||
this.socket.on("connect", function(socket){
|
||||
self.user.set("serverOffline", false);
|
||||
})
|
||||
this.socket.on("disconnect", function(socket){
|
||||
self.user.set("serverOffline", true);
|
||||
})
|
||||
},
|
||||
receive: function(event, cb){
|
||||
this.socket.on(event, cb);
|
||||
@ -681,8 +689,9 @@ let ChooseSideModal = Modal.extend({
|
||||
|
||||
let User = Backbone.Model.extend({
|
||||
defaults: {
|
||||
name: "",
|
||||
deckKey: "northern"
|
||||
name: localStorage["userName"] || null,
|
||||
deck: localStorage["userDeck"] || null,
|
||||
serverOffline: true
|
||||
},
|
||||
initialize: function(){
|
||||
let self = this;
|
||||
@ -792,7 +801,8 @@ let User = Backbone.Model.extend({
|
||||
new Notification(data).render();
|
||||
})
|
||||
|
||||
app.send("request:name", this.get("name") == "unnamed" ? null : {name: this.get("name")});
|
||||
app.send("request:name", this.get("name") === null ? null : {name: this.get("name")});
|
||||
app.send("set:deck", this.get("deck") === null ? null : {deck: this.get("deck")});
|
||||
},
|
||||
startMatchmaking: function(){
|
||||
this.set("inMatchmakerQueue", true);
|
||||
@ -809,10 +819,12 @@ let User = Backbone.Model.extend({
|
||||
},
|
||||
setName: function(name){
|
||||
this.get("app").send("request:name", {name: name});
|
||||
localStorage["userName"] = name;
|
||||
},
|
||||
setDeck: function(deckKey){
|
||||
//console.log("deck: ", deckKey);
|
||||
this.set("deckKey", deckKey);
|
||||
localStorage["userDeck"] = deckKey;
|
||||
this.get("app").send("set:deck", {deck: deckKey});
|
||||
},
|
||||
chooseSide: function(roomSide){
|
||||
@ -832,7 +844,6 @@ let Lobby = Backbone.View.extend({
|
||||
this.user = options.user;
|
||||
this.app = options.app;
|
||||
this.listenTo(this.app.user, "change", this.render);
|
||||
//$(this.el).prependTo('body');
|
||||
$(".gwent-battle").html(this.el);
|
||||
this.render();
|
||||
},
|
||||
@ -848,7 +859,7 @@ let Lobby = Backbone.View.extend({
|
||||
},
|
||||
render: function(){
|
||||
this.$el.html(this.template(this.user.attributes));
|
||||
/*this.$el.find("#deckChoice option[value='" + this.app.user.get("setDeck") + "']").attr("selected", "selected")*/
|
||||
this.$el.find("#deckChoice").val(this.user.get("deck")).attr("selected", true);
|
||||
return this;
|
||||
},
|
||||
startMatchmaking: function(){
|
||||
|
@ -321,6 +321,20 @@ $game-height: 800px;
|
||||
}
|
||||
}
|
||||
|
||||
.startMatchmaking {
|
||||
height: 50px;
|
||||
line-height: 35px;
|
||||
width: 200px;
|
||||
text-align: left;
|
||||
}
|
||||
.image-gif-loader {
|
||||
background: url("../../assets/content-load.gif");
|
||||
display: block;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
margin-left: 10px;
|
||||
|
||||
}
|
||||
|
||||
@keyframes waitForOpponent{
|
||||
0% {
|
||||
|
@ -1,11 +1,18 @@
|
||||
<div class="col-xs-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Gwent</div>
|
||||
<div class="panel-heading">Gwent
|
||||
{{#if serverOffline}}
|
||||
<span class="pull-right">Server Status: <span class="label label-danger">Offline</span></span>
|
||||
{{else}}
|
||||
<span class="pull-right">Server Status: <span class="label label-success">Online</span></span>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<input type="text" class="name-input" value="{{name}}">
|
||||
<select id="deckChoice">
|
||||
<option value="random">Deck: Random</option>
|
||||
<option value="northern">Deck: Northern Realms</option>
|
||||
<option value="scoiatael">Deck: Scoia'tael</option>
|
||||
<option value="monster">Deck: Monster</option>
|
||||
@ -13,16 +20,17 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<button type="button" class="btn btn-primary startMatchmaking"{{#if inMatchmakerQueue}} disabled{{/if}}>
|
||||
Search Opponent
|
||||
{{#if inMatchmakerQueue}}<img src="../site/public/assets/img/content-load.gif" width=20 style="margin: 5px;"> {{/if}}
|
||||
{{#if inMatchmakerQueue}}
|
||||
<i class="image-gif-loader pull-right"></i>
|
||||
{{/if}}
|
||||
</button>
|
||||
<!--<button type="button" class="btn btn-primary join-room">Join Room</button>-->
|
||||
<button type="button" class="btn btn-success note">debug note</button>
|
||||
</div>
|
||||
|
||||
<!--<button type="button" class="btn btn-success note">debug note</button>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -34,7 +34,7 @@ Battleside = (function(){
|
||||
this._name = user.getName();
|
||||
this.battle = battle;
|
||||
this.hand = Hand();
|
||||
this.deck = Deck(DeckData[deck], this);
|
||||
this.deck = Deck(deck, this);
|
||||
this._discard = [];
|
||||
|
||||
this.runEvent = this.battle.runEvent.bind(this.battle);
|
||||
|
@ -1,6 +1,7 @@
|
||||
var Card = require("./Card");
|
||||
/*var CardManager = require("./CardManager");*/
|
||||
var DeckData = require("../assets/data/deck");
|
||||
var _ = require("underscore");
|
||||
|
||||
var Deck = (function(){
|
||||
var Deck = function(deck, side){
|
||||
@ -14,11 +15,10 @@ var Deck = (function(){
|
||||
this.side = side;
|
||||
this._deck = [];
|
||||
|
||||
if(typeof deck !== "object") throw new Error("Deck is not an object!");
|
||||
//if(typeof deck !== "object") throw new Error("Deck is not an object!");
|
||||
|
||||
this._originalDeck = [];
|
||||
this._faction = deck.faction;
|
||||
this.setDeck(deck.data);
|
||||
this.setDeck(deck);
|
||||
};
|
||||
var r = Deck.prototype;
|
||||
/**
|
||||
@ -40,12 +40,17 @@ var Deck = (function(){
|
||||
MONSTERS: "monster"
|
||||
}
|
||||
|
||||
r.setDeck = function(deckData){
|
||||
if(!Array.isArray(deckData)) {
|
||||
deckData = DeckData["northern"];
|
||||
r.setDeck = function(deckKey){
|
||||
var deck = DeckData[deckKey] ? DeckData[deckKey] : DeckData["northern"];
|
||||
|
||||
if(deckKey === "random"){
|
||||
var decks = _.allKeys(DeckData);
|
||||
deck = DeckData[decks[(Math.random() * decks.length) | 0]];
|
||||
}
|
||||
this._originalDeck = deckData.slice();
|
||||
this._deck = deckData.slice();
|
||||
|
||||
this._originalDeck = deck.data.slice();
|
||||
this._deck = deck.data.slice();
|
||||
this._faction = deck.faction;
|
||||
|
||||
this._loadCards();
|
||||
this.shuffle();
|
||||
|
@ -45,8 +45,7 @@ var User = (function(){
|
||||
}
|
||||
|
||||
r.generateName = function(){
|
||||
var name = "Player" + (((Math.random() * 8999) + 1000) | 0);
|
||||
//if(lobby.hasUser(name)) return generateName();
|
||||
var name = "Guest" + (((Math.random() * 8999) + 1000) | 0);
|
||||
this._name = name;
|
||||
return name;
|
||||
}
|
||||
@ -70,7 +69,7 @@ var User = (function(){
|
||||
}
|
||||
|
||||
r.getDeck = function() {
|
||||
return this._deck || "northern";
|
||||
return this._deck;
|
||||
}
|
||||
|
||||
r.addRoom = function(room) {
|
||||
|
Loading…
Reference in New Issue
Block a user