-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some buttons for basic functionality
- Loading branch information
Showing
16 changed files
with
134 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ | |
}, | ||
"dependencies": { | ||
"uikit": "^3.0.0-beta.40", | ||
"vue": "^2.4.2", | ||
"vue": "^2.5.16", | ||
"vue-router": "^2.7.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require('./game-log.scss') | ||
|
||
module.exports = require('vue').component('game-log', { | ||
props: { | ||
log: Array | ||
}, | ||
template: require('./game-log.pug')() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.game-log | ||
p(v-for="message in log") • {{ message }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.game-log { | ||
height: 40em; | ||
line-height: 0.2em; | ||
position: absolute; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
require('./player-card.scss') | ||
|
||
module.exports = require('vue').component('player-card', { | ||
methods: { | ||
toggleSelect | ||
}, | ||
props: { | ||
disabled: Boolean, | ||
card: Object | ||
}, | ||
template: require('./player-card.pug')() | ||
}) | ||
|
||
function toggleSelect(card) { | ||
if (!card.disabled) { | ||
card.selected = !card.selected | ||
console.log(this.card.selected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.player-card(:class="{ disabled: card.disabled }") | ||
.player-card( | ||
@click="toggleSelect(card)", | ||
v-bind:class="{ disabled: card.disabled, selected: card.selected }") | ||
.front | ||
p {{ card.name }} | ||
p {{ card.type.toUpperCase() }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,10 @@ | |
&.disabled { | ||
opacity: 0.3; | ||
} | ||
|
||
&.selected { | ||
border-color: red; | ||
border-style: solid; | ||
border-width: 2px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ div | |
player-card( | ||
:card="card", | ||
:disabled="false", | ||
:key="card.uid", | ||
v-for="card in hand") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { getGame } = require('../state') | ||
|
||
module.exports = (socket, payload) => { | ||
const game = getGame(socket.gameId) | ||
if (game) { | ||
game.pass(socket.id) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { getGame } = require('../state') | ||
|
||
module.exports = (socket, payload) => { | ||
const game = getGame(socket.gameId) | ||
if (game) { | ||
const player = game.getPlayer(socket.id) | ||
game.play(socket.id, payload.map((card) => { | ||
return player.hand.find(_card => _card.uid === card.uid) | ||
}).filter(card => card)) | ||
} | ||
} | ||
|
||
module.exports.validator = (payload) => { | ||
if (!Array.isArray(payload)) return false | ||
payload.forEach((card) => { | ||
if (typeof card.id !== 'string') { | ||
return false | ||
} | ||
if (typeof card.uid !== 'string') { | ||
return false | ||
} | ||
}) | ||
return true | ||
} | ||
|
||
module.exports.validatorMessage = 'Expected array of card objects.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters