Skip to content

Commit 28a278c

Browse files
committed
Beta version completed still minor bugs check readme.md for bugs and future development
1 parent bfbbe45 commit 28a278c

File tree

9 files changed

+72
-34
lines changed

9 files changed

+72
-34
lines changed

.meteor/packages

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ profile-online
1111
bootstrap
1212
accounts-password
1313
accounts-ui-bootstrap-dropdown
14+
bootboxjs

bubblepopper.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
background-image: none;
2626
}
2727

28-
.game-in-progress {
29-
margin-top: 40px;
28+
.score {
29+
margin-bottom: 45px;
3030
padding: 0px;
3131
border: none;
3232
}

client/client.js

+34-10
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,45 @@ Template.home.helpers({
99
},
1010
player1Score: function(){
1111
var game = Games.findOne({current: true});
12-
console.log(game);
13-
if(!game)
12+
if(!game){
1413
return;
14+
}
1515
var player = game.players[0];
16-
console.log(player);
1716
var bubbles = Bubbles.find({userId: player, gameId: game._id}).fetch();
1817
return bubbles.length;
1918
},
2019
player2Score: function(){
2120
var game = Games.findOne({current: true});
22-
if(!game)
21+
if(!game){
2322
return;
23+
}
2424
var player = game.players[1];
25-
return Bubbles.find({userId: player, gameId: game._id}).fetch().length;
25+
var bubbles = Bubbles.find({userId: player, gameId: game._id}).fetch();
26+
return bubbles.length;
27+
},
28+
endGame: function(){
29+
var game = Games.findOne({current: true});
30+
if(!game){
31+
return;
32+
}
33+
var player1 = Bubbles.find({userId: game.players[0], gameId: game._id}).fetch().length;
34+
var player2 = Bubbles.find({userId: game.players[1], gameId: game._id}).fetch().length;
35+
var totalPressed = player1 + player2;
36+
var winner;
37+
if(player1 > player2){
38+
winner = "Player 1 Wins!!!";
39+
}
40+
else if(player2 > player1){
41+
winner = "Player 2 Wins!!!";
42+
}
43+
else{
44+
winner = "Tie Game!!!!";
45+
}
46+
if(totalPressed !== 64){
47+
return;
48+
}
49+
bootbox.alert(winner);
50+
Meteor.call('finishGame', game._id)
2651
}
2752
});
2853

@@ -33,19 +58,18 @@ Template.home.events({
3358
"click #finishGame": function(){
3459
var game = Games.findOne({current: true});
3560
Meteor.call('finishGame', game._id);
36-
}
61+
}
3762
});
3863

3964
Template.grid.helpers({
4065
buttons: function (){
41-
console.log('Inside the grid -> button helper');
4266
var user = Meteor.user();
4367
if(!user){
44-
return;
68+
return;
4569
}
4670
var game = Games.findOne({players: {$in: [user._id]}, current: true});
4771
if(!game){
48-
return;
72+
return;
4973
}
5074
return Bubbles.find({gameId: game._id});
5175
}
@@ -57,5 +81,5 @@ Template.grid.events({
5781
var _id = clickedElement.attr('button_id');
5882
Meteor.call('hideButton', _id, Meteor.userId());
5983
}
60-
})
84+
});
6185

client/todo.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Users can't play themselves
2+
Bubbles need an order
3+
Add ordering to the Bubble query
4+
Users need to have a better idea of what a "Game" is <- Developer detail :)
5+
Client security

main.html

+14-15
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,21 @@
1919
<h1> Welcome to bubblePopper</h1>
2020
<p> Current Game Status:
2121
{{#if game.active}}
22-
<div class='game-in-progress'>Game in progress. <a href="#" id="finishGame">Finish Game</a></div>
23-
<center>{{>grid}}</center>
24-
{{else}}
25-
{{#if game.finished}}
26-
Game done or another player left.<a href="#" id="newGame">Start a new game</a>
27-
{{else}}
28-
Waiting for a new player to login. Find a <a href="#" id="newGame">new game</a>
29-
{{/if}}
22+
{{endGame}}
23+
Game in progress. <a href="#" id="finishGame">Finish Game</a>
24+
<div class="score"><center><strong>Player 1</strong> {{player1Score}}
25+
<strong>Player 2</strong> {{player2Score}}</center>
26+
</div>
27+
<center>{{>grid}}</center>
28+
{{else}}
29+
{{#if game.finished}}
30+
Game done or another player left.<a href="#" id="newGame">Start a new game</a>
31+
{{else}}
32+
Waiting for a new player to login. Find a <a href="#" id="newGame">new game</a>
33+
{{/if}}
3034
{{/if}}
31-
</p>
32-
<p><strong> Current Game ID: </strong>{{game._id}}</p>
35+
</p>
36+
<p><strong> Current Game ID: </strong>{{game._id}}</p>
3337
<p><strong> Current Game Player Count: </strong>{{game.players.length}}</p
34-
3538
<p><strong> Current Game Active: </strong>{{game.active}}</p>
36-
<div class="score"><label>Player 1</label>{{player1Score}}</div>
37-
<div class="score"><label>Player 2</label>{{player2Score}}</div>
38-
39-
4039
</template>

packages/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/accounts-entry
44
/iron-router
55
/accounts-ui-bootstrap-dropdown
6+
/bootboxjs

server/server.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Meteor.methods({
22
newGame: function() {
33
allocateGame(this.userId);
44
},
5-
finishGame: function(_id) {
5+
finishGame: function(_id){
66
Games.update({_id: _id}, {$set: {active: false, finished: true}});
77
},
88
hideButton: function(bubble_id, userId){
@@ -30,7 +30,8 @@ allocateGame = function(userId) {
3030
Bubbles.insert({gameId: gameId});
3131
});
3232

33-
} else {
33+
}
34+
else {
3435
console.log("connecting with an existing waiting player");
3536
Games.update({_id: gameWaiting._id}, {$set: {active: true}, $push: {players: userId}});
3637
}
@@ -40,17 +41,17 @@ leaveGames = function(userId) {
4041
console.log("leaving all unfinished games");
4142
Games.remove({$and: [{players: userId, players: {$size: 1}}]});
4243
var games = Games.find({$and: [{players: userId, active: true}]});
43-
games.forEach(function(game) {
44+
games.forEach(function(game){
4445
Games.update({_id: game._id}, {$set: {active: false, finished: true}});
4546
})
4647
};
4748

4849
Meteor.publish('games', function(userId) {
49-
if(userId)
50+
if(userId){
5051
return Games.find({players: this.userId});
52+
}
5153
});
5254

5355
Meteor.publish('Bubbles', function(){
54-
//Bubbles was bubbles
5556
return Bubbles.find();
5657
});

smart.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"packages": {
33
"profile-online": {},
4-
"accounts-ui-bootstrap-dropdown": {}
4+
"accounts-ui-bootstrap-dropdown": {},
5+
"bootboxjs": {}
56
}
67
}

smart.lock

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"dependencies": {
44
"basePackages": {
55
"profile-online": {},
6-
"accounts-ui-bootstrap-dropdown": {}
6+
"accounts-ui-bootstrap-dropdown": {},
7+
"bootboxjs": {}
78
},
89
"packages": {
910
"profile-online": {
@@ -15,6 +16,11 @@
1516
"git": "https://github.com/erobit/meteor-accounts-ui-bootstrap-dropdown.git",
1617
"tag": "v0.6.5.1",
1718
"commit": "c8b29d2e7f8611d6dec9d6d23c1c2b94e000b0fb"
19+
},
20+
"bootboxjs": {
21+
"git": "https://github.com/TimHeckel/meteor-bootboxjs.git",
22+
"tag": "v3.2.2",
23+
"commit": "580adfebfa12b4d2186a80cec1109dab74ad6228"
1824
}
1925
}
2026
}

0 commit comments

Comments
 (0)