Skip to content
This repository has been archived by the owner on Aug 19, 2021. It is now read-only.

Commit

Permalink
WIP support sfx; Refactor file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kcgidw committed May 4, 2020
1 parent 6095ae7 commit 55ccdab
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"babel-loader": "^8.0.5",
"compression": "^1.7.4",
"compression-webpack-plugin": "^3.0.1",
"copy-webpack-plugin": "^5.1.1",
"core-js": "^3.0.1",
"css-loader": "^3.4.1",
"csv": "^5.3.0",
Expand Down
4 changes: 3 additions & 1 deletion src/common/cli-game.js → src/public/js/client-game.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function generateClientGameState() {
},
getUserColor(username) {
let userIdx = this.getUsernames().findIndex((u) => u === username); // needs es6 polyfill
return userIdx >= 0 ? Color.HEX[Color.ORDER[userIdx]] || 'var(--grey6)' : 'var(--grey6)';
return userIdx >= 0
? Color.HEX[Color.ORDER[userIdx]] || 'var(--grey6)'
: 'var(--grey6)';
},
getMostRecentStroke() {
return this.strokes[this.strokes.length - 1];
Expand Down
File renamed without changes.
9 changes: 8 additions & 1 deletion src/public/js/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import VIEW from './view';
import CONNECTION_STATE from './connection-state';
import GAME_PHASE from '../../common/game-phase';
import MESSAGE from '../../common/message';
import { generateClientGameState } from '../../common/cli-game';
import { generateClientGameState } from './client-game';
import { validateUsername } from '../../common/util';

const socket = io();
// const sfx = new Audio('static/sfx-shake.wav');

const Store = {
state: {
Expand Down Expand Up @@ -83,7 +84,13 @@ function handleSocket(messageName, handler, errHandler) {
handler(data);
}
if (data.roomState !== undefined) {
const prevStrokesLength = Store.state.gameState
? Store.state.gameState.strokes.length
: 0;
Store.setGameState(data.roomState);
// if (prevStrokesLength < data.roomState.strokes.length) {
// sfx.play();
// }
}
});
}
Expand Down
15 changes: 7 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const CompressionPlugin = require('compression-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');

module.exports = (env) => {
const prod = env.production;
Expand Down Expand Up @@ -42,14 +43,6 @@ module.exports = (env) => {
'html-loader',
],
},
{
test: /\.svg$/,
loader: [
{ loader: 'file-loader', options: { name: '[name].svg' } },
'extract-loader',
'svg-inline-loader',
],
},
{
test: /\.(sa|sc|c)ss$/,
use: [
Expand Down Expand Up @@ -94,6 +87,12 @@ module.exports = (env) => {
new MiniCssExtractPlugin({
filename: 'style.bundle.css',
}),
new CopyPlugin([
{
from: path.resolve(__dirname, 'src', 'public/static'),
to: path.resolve(__dirname, 'dist', 'public/static'),
},
]),
],

externals: prod
Expand Down

0 comments on commit 55ccdab

Please sign in to comment.