Browse Source

Added text boxes, updated HTML text, have to fix judge(Right now they have a text box too which is not good)

master
Stephen Downward 4 years ago
parent
commit
5826e4ab3a
8 changed files with 52 additions and 30 deletions
  1. +16
    -12
      game.js
  2. BIN
      nodejs-against-humanity.png
  3. +4
    -0
      public/js/app/controllers.js
  4. +3
    -0
      public/js/app/services.js
  5. +6
    -0
      server.js
  6. +8
    -8
      views/game.html
  7. +4
    -4
      views/index.html
  8. +11
    -6
      views/lobby.html

+ 16
- 12
game.js View File

@ -45,11 +45,11 @@ function addGame(game) {
game.winningCardId = null;
game.isStarted = false;
game.deck = getDeck();
game.currentBlackCard = "";
game.isReadyForScoring = false;
game.isReadyForReview = false;
game.pointsToWin = config.pointsToWin;
game.maxPlayers = config.maxPlayers;
game.situation = "You are in a room.";
gameList.push(game);
return game;
}
@ -63,15 +63,14 @@ function joinGame(game, player) {
id: player.id,
name: player.name,
isReady: false,
cards : [],
selectedWhiteCardId: null,
awesomePoints: 0,
isCzar: false
};
for(var i = 0; i < config.whiteCardsPerHand; i++) {
/*for(var i = 0; i < config.whiteCardsPerHand; i++) {
drawWhiteCard(game, joiningPlayer);
}
}*/
game.players.push(joiningPlayer);
@ -110,7 +109,6 @@ function departGame(gameId, playerId) {
function startGame(game) {
game.isStarted = true;
setCurrentBlackCard(game);
game.players[0].isCzar = true;
}
@ -132,7 +130,7 @@ function roundEnded(game) {
game.isReadyForScoring = false;
game.isReadyForReview = false;
setCurrentBlackCard(game);
//setCurrentBlackCard(game);
_.each(game.players, function(player) {
if(!player.isCzar) {
@ -155,17 +153,17 @@ function roundEnded(game) {
}
}
function drawWhiteCard(game, player) {
/*function drawWhiteCard(game, player) {
var whiteIndex = Math.floor(Math.random() * game.deck.white.length);
player.cards.push(game.deck.white[whiteIndex]);
game.deck.white.splice(whiteIndex, 1);
}
}*/
function setCurrentBlackCard(game) {
/*function setCurrentBlackCard(game) {
var index = Math.floor(Math.random() * game.deck.black.length);
game.currentBlackCard = game.deck.black[index].text;
game.deck.black.splice(index, 1);
}
}*/
function getPlayer(gameId, playerId) {
var game = getGame(gameId);
@ -190,6 +188,11 @@ function readyForNextRound(gameId, playerId) {
roundEnded(game);
}
}
function selectSituation(gameId, playerId, textBox) {
var player = getPlayer(gameId, playerId)
player.situation = textBox;
console.log(textBox);
}
function selectCard(gameId, playerId, whiteCardId) {
var player = getPlayer(gameId, playerId);
@ -207,12 +210,13 @@ function selectCard(gameId, playerId, whiteCardId) {
}
}
function selectWinner(gameId, cardId) {
function selectWinner(gameId, cardId) { //Where we update the situation, probably
var player = getPlayerByCardId(gameId, cardId);
var game = getGame(gameId);
game.winningCardId = cardId;
game.isReadyForReview = true;
player.awesomePoints = player.awesomePoints + 1;
game.situation += " " + player.situation;
game.history.push({ black: game.currentBlackCard, white: cardId, winner: player.name });
if(player.awesomePoints === game.pointsToWin) {
game = getGame(gameId);
@ -235,7 +239,7 @@ exports.departGame = departGame;
exports.readyForNextRound = readyForNextRound;
exports.reset = reset;
exports.roundEnded = roundEnded;
exports.selectCard = selectCard;
exports.selectSituation = selectSituation;
exports.selectWinner = selectWinner;
exports.removeFromArray = removeFromArray;
exports.getDeck = getDeck;

BIN
nodejs-against-humanity.png View File

Before After
Width: 1609  |  Height: 858  |  Size: 199 KiB

+ 4
- 0
public/js/app/controllers.js View File

@ -138,6 +138,10 @@ angular.module('myApp.controllers', [])
return status;
}
$scope.selectSituation = function(textToAppend) {
GameService.selectSituation($scope.gameId, $scope.playerId, textToAppend);
};
$scope.selectCard = function(card) {
GameService.selectCard($scope.gameId, $scope.playerId, card);
};


+ 3
- 0
public/js/app/services.js View File

@ -40,6 +40,9 @@ angular.module('myApp.services', [])
selectCard: function(gameId, playerId, selectedCard){
$http.post("/selectCard", { gameId: gameId, playerId: playerId, whiteCardId: selectedCard });
},
selectSituation: function(gameId, playerId, textBoxText){
$http.post("/selectSituation", { gameId: gameId, playerId: playerId, textBoxText : textBoxText });
},
selectWinner: function(gameId, selectedCard) {
$http.post("/selectWinner", { gameId: gameId, cardId: selectedCard });
},


+ 6
- 0
server.js View File

@ -115,6 +115,12 @@ app.post('/selectcard', function(req, res) {
returnGame(req.body.gameId, res);
});
app.post('/selectSituation', function(req, res) {
Game.selectSituation(req.body.gameId, req.body.playerId, req.body.textBoxText);
broadcastGame(req.body.gameId);
returnGame(req.body.gameId, res);
});
app.post('/selectWinner', function(req, res) {
Game.selectWinner(req.body.gameId, req.body.cardId);
broadcastGame(req.body.gameId);


+ 8
- 8
views/game.html View File

@ -8,21 +8,21 @@
<hr/>
</div>
<div id="notificationWaitingOnRound" ng-show="!game.isStarted" class="center row alert alert-warning">waiting on round to start</div>
<div class="row blackCard" ng-show="game.isStarted" ng-bind-html="game.currentBlackCard"></div>
<div class="row blackCard" ng-show="game.isStarted" ng-bind-html="game.situation"></div>
<br>
<div id="notificationCardCzar" ng-show="currentPlayer.isCzar" class="row alert alert-info center">You are the Card Czar.</div>
<div id="notificationCardCzar" ng-show="currentPlayer.isCzar" class="row alert alert-info center">You are the Judge! </div>
<div id="notificationSelectCard" ng-show="showNotificationSelectCard()" class="row alert alert-success center">Select a card to play.</div>
<div id="notificationWaitingOnCzar" ng-show="showNotificationWaitingOnCzar()" class="row alert alert-warning center">Waiting for the Card Czar to pick winner.</div>
<div id="notificationWaitingOnCzar" ng-show="showNotificationWaitingOnCzar()" class="row alert alert-warning center">Waiting for the judge to pick winner.</div>
<div id="notificationWaitingOnCards" ng-show="showNotificationWaitingOnCards()" class="row alert alert-warning center">Waiting for other players.</div>
<div id="notificationSelectWinner" ng-show="showNotificationSelectWinner()" class="row alert alert-success center">Select a card to be the winner.</div>
<div class="row" ng-show="showWhiteCardList()">
<div id="notificationSelectWinner" ng-show="showNotificationSelectWinner()" class="row alert alert-success center">Select one of the answers below to join the existing paragraph permanently. Choose an answer that is original, clever and subtle.</div>
<div class="row" ng-show="showWhiteCardList()>
<table id="whiteCards" class="table">
<tbody id="whiteCardSelection">
<tr ng-repeat="whiteCard in currentPlayer.cards">
<tr>
<td>
<button class="btn btn-default" ng-class="getButtonClass(whiteCard)" ng-click="selectCard(whiteCard)">{{getButtonText(whiteCard)}}</button>
<textarea ng-model="situationAppendage"></textarea>
<button class="btn btn-default" ng-click="selectSituation(situationAppendage)">Submit</button>
</td>
<td class="col-lg-10 col-md-10" style="font-size: 16px; font-weight: bold; line-height: 25px;">{{whiteCard}}</td>
</tr>
</tbody>
</table>


+ 4
- 4
views/index.html View File

@ -2,7 +2,7 @@
<html lang="en" ng-app="myApp" ng-controller="HomeCtrl">
<head>
<meta charset="utf-8">
<title>NodeJS Against Humanity</title>
<title>Entropy</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Le styles -->
<link href="/public/css/bootstrap.min.css" rel="stylesheet">
@ -20,7 +20,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">NodeJS Against Humanity</a>
<a class="navbar-brand" href="/">Entropy</a>
</div>
<div class="navbar-collapse collapse" id="humanity-navbar-collapse">
<ul class="nav navbar-nav">
@ -49,8 +49,8 @@
<br />
<small>This site is not affliated in any way with the official Cards Against Humanities.</small>
<br/>
<a href="https://github.com/amirrajan/nodejs-against-humanity">The source is here. I accept pull requests (tech: NodeJS, AngularJS)</a>.
<div>Last Release:&nbsp;<span app-version></span></div>
<a href="https://git.scd31.com/laptopdude90/entropy">Source</a><BR>
<a href="https://github.com/amirrajan/nodejs-against-humanity">Based on Node.Js Against Humanity</a>.
</div>
</div>
</div>


+ 11
- 6
views/lobby.html View File

@ -1,14 +1,19 @@
<h4>Instructions</h4>
<h2>Welcome to Entropy!</h2>
<ul>
<li>Enter your name at the top.</li>
<li>You need at least 3 players to play.</li>
<li>Use the Create Game link at the top to start a game or...</li>
<li>click below to join a game.</li>
Entropy is a game where you and your fellow players will turn by turn create the worst situation imaginable. Each turn, every player must write a sentence that worsens the situation one step further. A judge is chosen each round starting with the Host, and at the end of each turn will assign a point to the player who wrote the best sentence to add onto the situation.
<h3>Gameplay</h3><BR>
1. The host is the first judge and provides the initial prompt to begin the game (ex: "You are trapped in a room"). The prompt should be general and create some setting.<BR>
2. Players each give their own original addition to the first prompt. Additions must be a full sentence that take the situation one step further downhill in a creative, subtle way (ex: "The room is slowly filling with water")<BR>
3. The Judge reviews all sentences submitted and chooses one to permanently add onto the original prompt. The addition chosen should be the most imaginative, humorous and otherwise unique. Answers are anonymous until the Judge chooses, and the player who wrote the chosen answer is awarded a point.<BR>
4. Steps 2-3 repeat the following round, with a new Judge and players now adding onto existing sentences. Gameplay continues until one player reaches 10 points and wins.<BR>
</ul>
<hr />
<div class="row" id="availableGames" >
<div class="col-lg-10">
<strong id="noGames" ng-show="availableGames.length == 0">no open games... use the Create Game link at the top to start one.</strong>
<strong id="noGames" ng-show="availableGames.length == 0">No open games... use the Create Game link at the top to start one.</strong>
<div ng-repeat="game in availableGames" class="well">
<button ng-click="joinGame(game.id)" type="button" class="btn btn-primary" style="margin-right: 10px;">Join Game</button>
<span style="font-size: larger">{{game.name}} - {{game.players}} of {{game.maxPlayers}} players</span>


Loading…
Cancel
Save