Skip to content

Commit

Permalink
Game flow now cycles through full round
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorterrill committed Jul 21, 2016
1 parent c9b5b22 commit cb31522
Show file tree
Hide file tree
Showing 14 changed files with 781 additions and 343 deletions.
467 changes: 404 additions & 63 deletions ashes.sublime-workspace

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions client/public/build.css

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions client/public/build.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/public/build.js.map

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion client/src/components/game/card.vue
Expand Up @@ -6,10 +6,13 @@
height:140px;
position:relative;
background-image:url('../img/back-standard.jpg');
background-position:center center;
background-repeat:no-repeat;
background-size:100px 140px;
border-radius:6px;
text-align:center;
padding-top:20px;
border:2px solid transparent;
}
.card__token {
Expand All @@ -35,7 +38,7 @@
</style>

<template>
<div @click.stop="openContext" class="card" :style="{ backgroundImage: 'url(' + imageUri + ')' }" @mouseover="turnPreviewOn" @mouseleave="turnPreviewOff" >
<div @click.stop="openContext" class="card{{ isSelected ? ' selected': '' }}" :style="{ backgroundImage: 'url(' + imageUri + ')' }" @mouseover="turnPreviewOn" @mouseleave="turnPreviewOff" >
<div v-show="(cardData.tokens.wound >= 1)" class="card__token card__token--wound">{{ cardData.tokens.wound }}</div>
<div v-show="(cardData.tokens.status >= 1)" class="card__token card__token--status">{{ cardData.tokens.status }}</div>
<div v-show="(cardData.tokens.exhaustion >= 1)" class="card__token card__token--exhaustion">{{ cardData.tokens.exhaustion }}</div>
Expand All @@ -54,6 +57,13 @@ export default {
},
computed: {
isSelected: function() {
//TODO
return false;
},
contextActions: function() {
actions = [];
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/game/die.vue
@@ -1,11 +1,14 @@
<style lang="sass">
.die {
background-position:center center;
background-repeat:no-repeat;
position:relative;
width:29px;
height:29px;
display:inline-block;
margin-right: 2px;
border-radius:4px;
border:2px solid transparent;
&.die--exhausted::after {
content: "";
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/game/stack.vue
Expand Up @@ -6,7 +6,10 @@
height:140px;
position:relative;
background-size:100px 140px;
background-position:center center;
background-repeat:no-repeat;
border-radius:6px;
border:2px solid transparent;
}
.stack--empty {
Expand Down Expand Up @@ -90,7 +93,7 @@ export default {
store.socket.emit('userAction', store.state.gameId, {
playerSocketId: store.socketId,
actionVerb: 'move',
object: store.state.players[store.socketId].deck[Math.floor(Math.random() * store.state.players[store.socketId].deck.length)],
object: store.state.players[store.socketId].deck[(3 * i) + 1],
targetType: 'stack',
target: 'hand',
targetOwnerSocketId: store.socketId
Expand Down
8 changes: 4 additions & 4 deletions client/src/sass/main.scss
Expand Up @@ -15,10 +15,6 @@ html, body {
$red: #963535;
$green: #185400;

.targeted {
outline:2px solid $red;
}

// -----------------------------------------------------------[ LINKS / BUTTONS ]

a {
Expand Down Expand Up @@ -250,6 +246,10 @@ x:-o-prefocus, .select-container::after {
font-size:0.825rem;
}

.selected {
border-color:red !important;
}

// -----------------------------------------------------------[ LAYOUT ]
.container {
display:flex;
Expand Down
23 changes: 14 additions & 9 deletions server/app.js
Expand Up @@ -21,6 +21,7 @@ app.use(express.static('../client/public'));
// load list data and setup script
var lists = require('./data/decks.json');
var setup = require('./controllers/game-setup.js');
var userActions = require('./controllers/user-actions.js');

// basic routing
app.get('/', function(req, res){
Expand Down Expand Up @@ -97,6 +98,8 @@ function getPlayerUsername(gameId, playerSocketId) {
// Deletes the game if their departure makes it empty
function removePlayerFromGames(playerSocketId) {

console.log('REMOVING A PLAYER FROM A GAME');

//look through each game
_.each(activeGames, function(game, gameId) {
//if they were in this game
Expand All @@ -119,12 +122,14 @@ function removePlayerFromGames(playerSocketId) {

// -----------------------------------------------------------[ ADD CHAT TO GAME ]
function chatToGame(gameId, sender, msg) {
activeGames[gameId].chatLog.push({
sender: sender,
message: msg
});
//emit an event that alerts the sidebar to scroll to the bottom
server.to(gameId).emit('chat');
if (activeGames[gameId]) {
activeGames[gameId].chatLog.push({
sender: sender,
message: msg
});
//emit an event that alerts the sidebar to scroll to the bottom
server.to(gameId).emit('chat');
}
}


Expand Down Expand Up @@ -231,12 +236,12 @@ server.on('connection', function(socket){
socket.on('userAction', function(gameId, action) {

//handle the action
var actionResults = gameFlow.handleUserAction(activeGames[gameId], action);
var actionResults = userActions.handleUserAction(activeGames[gameId], action);
var actionDescription = actionResults.actionDescription;
activeGames[gameId] = actionResults.game;

//tell everyone what happened if we need to
if (actionDescription) {
if (actionDescription && actionDescription !== '') {
chatToGame(gameId, 'server', actionDescription);
}

Expand Down

0 comments on commit cb31522

Please sign in to comment.