Permalink
Browse files

minor changes with mock

  • Loading branch information...
1 parent 26b2c79 commit 9e43cfbe8c635f2b046e3f344a405e45f809564b Ryan Patterson committed Apr 8, 2012
View
@@ -5,8 +5,6 @@
<link rel="stylesheet" type="text/css" href="/public/css/game.css" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<script type="text/javascript" src="/public/lib/zepto.js"></script>
- <script type="text/javascript" src="/js/pkg/globalize.js?dev"></script>
- <script type="text/javascript" src="/public/js/views.js"></script>
<script type="text/javascript" src="/js/pkg/mock.js?dev"></script>
</head>
<body>
View
@@ -12,5 +12,6 @@ _.extend(window,
require('./views/CollectionView'),
require('./views/PlayerIconView'),
require('./views/FacepileView'),
- require('./views/MissionView')
+ require('./views/MissionView'),
+ require('./views/GameView')
);
View
@@ -1,6 +1,13 @@
+var Backbone = require('backbone');
var _ = require('underscore')._;
+var G_STATE = require('constants').G_STATE;
var PLAYER_DB = require('mock/database').PLAYER_DB;
+var ClientState = require('models/ClientState').ClientState;
+var Game = require('models/Game').Game;
+var Mission = require('models/Mission').Mission;
+var GameView = require('views/GameView').GameView;
+
$(document).ready(function() {
socket = {
emit: function(event, data) {
@@ -11,7 +18,7 @@ $(document).ready(function() {
_(socket).extend(Backbone.events);
var clientstate = window.clientstate = new ClientState({
- my_id: 693594821
+ my_id: PLAYER_DB[0].id
});
var game = new Game(), mission;
@@ -30,7 +37,7 @@ $(document).ready(function() {
mission = new Mission({
turn: 1,
attempt: 1,
- leader: 1341660327
+ leader_id: PLAYER_DB[1].id
}, { parse: true });
game.missions.add(mission);
game.set('state', G_STATE.CHOOSING_MISSION);
@@ -41,6 +41,7 @@ var ClientState = exports.ClientState = Backbone.Model.extend({
didJoinGame: function(game) {
this.game = game;
+ this.game.set('local_player_id', this.get('my_id'));
this.trigger('join_game', this.game);
},
View
@@ -46,12 +46,6 @@ var Game = exports.Game = Backbone.Model.extend({
socket.emit('leave_game');
},
- getPlayer: function(id) {
- return this.players.find(function(p) {
- return p.id == id;
- });
- },
-
getCurrentMission: function() {
if (this.get('state') == G_STATE.FINISHED) {
return null;
@@ -1,4 +1,6 @@
var Backbone = require('backbone-extensions');
+var G_STATE = require('constants').G_STATE;
+var MISSION_STATES = require('constants').MISSION_STATES;
var PlayerList = require('./Player').PlayerList;
@@ -55,7 +57,7 @@ var Mission = exports.Mission = Backbone.Model.extend({
},
getLeader: function() {
- return this.game.getPlayer(this.get('leader_id'));
+ return this.game.players.get(this.get('leader_id'));
},
addToParty: function(player) {
View
@@ -16,67 +16,3 @@ var RosterView = CollectionView.extend({
});
}
});
-
-var GameView = Backbone.View.extend({
- className: 'viewport',
- events: {
- 'click #start_game' : 'startGame'
- },
-
- initialize: function() {
- _(this).bindAll('updateStartButton');
- this._rosterView = new RosterView({
- collection: this.model.game.players
- });
- this._missionListView = new MissionListView({
- collection: this.model.game.missions
- });
-
- this.model.game.players.on('add remove reset', this.updateStartButton);
-
- this.model.game.on('change', _(function() {
- this.$el.addClass(this.model.game.get('state'));
- }).bind(this));
-
- },
-
- startGame : function() {
- this.model.game.startGame();
- },
-
- updateStartButton : function() {
- if (this.model.get('my_id') == this.model.game.get('creator')
- && this.model.game.players.length > 0
- && this.model.game.get('state') == G_STATE.FINDING_PLAYERS) {
- this.startButton.show();
- } else {
- this.startButton.hide();
- }
- },
-
- render: function() {
- var template = [
- '<div class="navigation">',
- '<div data-id="1" class="token"></div>',
- '<div data-id="2" class="token"></div>',
- '<div data-id="3" class="token"></div>',
- '<div data-id="4" class="token"></div>',
- '<div data-id="5" class="token"></div>',
- '</div>'
- ].join('');
-
- this.$el.html(template);
- this.$el.addClass(this.model.game.get('state'));
- this.$el.append(this._rosterView.render().el);
- this.$el.append($('<hr/>'));
- this.$el.append(this._missionListView.render().el);
- this.startButton =
- $('<div id="start_game" class="button title layer accept full center">' +
- 'Start Game' +
- '</div>'
- );
- this.$el.append(this.startButton);
- this.updateStartButton();
- return this;
- }
-});
@@ -0,0 +1,29 @@
+var Backbone = require('backbone');
+var _ = require('underscore')._;
+
+var MissionListView = require('./MissionView').MissionListView;
+
+var GameView = exports.GameView = Backbone.View.extend({
+ initialize: function() {
+ this._missionListView = new MissionListView({
+ collection: this.model.game.missions
+ });
+
+ },
+
+ render: function() {
+ var template = [
+ '<div class="navigation">',
+ '<div data-id="1" class="token"></div>',
+ '<div data-id="2" class="token"></div>',
+ '<div data-id="3" class="token"></div>',
+ '<div data-id="4" class="token"></div>',
+ '<div data-id="5" class="token"></div>',
+ '</div>'
+ ].join('');
+
+ this.$el.html(template);
+ this.$el.append(this._missionListView.render().el);
+ return this;
+ }
+});
@@ -1,10 +1,14 @@
var _ = require('underscore')._;
var Backbone = require('backbone');
var Mustache = require('mustache');
+var GameInfo = require('constants').GameInfo;
+var M_STATE = require('constants').M_STATE;
+var MISSION_STATES = require('constants').MISSION_STATES;
var ChoosePeopleView = require('./ChoosePeopleView').ChoosePeopleView;
var CollectionView = require('./CollectionView').CollectionView;
var PlayerIconView = require('./PlayerIconView').PlayerIconView;
+var FacepileView = require('./FacepileView').FacepileView;
var MissionActView = Backbone.View.extend({
render: function() {

0 comments on commit 9e43cfb

Please sign in to comment.