Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ rules:
no-implicit-coercion: warn
no-warning-comments: warn
no-useless-return: warn
no-use-before-define: off
no-new: warn
no-multi-spaces:
- warn
- exceptions:
ImportDeclaration: true
no-undef-init: warn
no-undefined: warn
computed-property-spacing:
- warn
- never
Expand All @@ -41,9 +41,6 @@ rules:
- stroustrup
- allowSingleLine: true
block-spacing: warn
array-element-newline:
- warn
- consistent
array-bracket-spacing: warn
array-bracket-newline:
- warn
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v10.15.1
v12.6.0
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
{
"name": "react-rpg.com",
"version": "1.0.1",
"version": "1.1.0",
"private": true,
"dependencies": {
"body-scroll-lock": "^2.6.1",
"customize-cra": "^0.2.11",
"customize-cra": "^0.8.0",
"hammerjs": "^2.0.8",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"node-sass": "^4.11.0",
"react": "^16.8.1",
"react": "16.10.1",
"react-app-rewired": "^2.1.0",
"react-device-detect": "^1.6.2",
"react-dom": "^16.8.1",
"react-ga": "^2.5.7",
"react-redux": "^5.0.7",
"react-scripts": "^2.1.3",
"react-redux": "^7.1.1",
"react-scripts": "^3.2.0",
"react-sound": "^1.2.0",
"react-timeout": "^1.1.2",
"redux": "^4.0.0",
"redux-persist": "^5.10.0",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"typeface-montserrat": "^0.0.54",
"typeface-roboto": "^0.0.54"
"typeface-montserrat": "^0.0.75",
"typeface-roboto": "^0.0.75"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "eslint ."
},
"browserslist": [
">0.2%",
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const App = ({ appState, world }) => {
if(!nativeApp && !optOutDownload) {
setShowDownloadPopup(true);
}
}, []);
}, [nativeApp, optOutDownload]);

const { optOutDownload, sideMenu } = appState;
const { gameMode, floorNum } = world;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/utils/get-surrounding-tiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('getSurroundingTiles tests:', () => {
expect(getSurroundingTiles(startPos).tiles).toEqual(expected);
});

test('startPos is top right corner: [19, 0]', () => {
test('startPos is top right corner: [19, 0]', () => {
const startPos = [(MAP_DIMENSIONS[0] - 1), 0];
const expected = [
[16, 0], [17, 0], [18, 0], [19, 0],
Expand Down
27 changes: 14 additions & 13 deletions src/components/dialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@ import './styles.scss';
const Dialog = ({ children, goBack, onKeyPress }) => {

useEffect(() => {
const handleKeyPress = event => {
// case for 'enter' or 'space' key
if(event.keyCode === 13 || event.keyCode === 32) {
onKeyPress();
}
};

if(onKeyPress) window.addEventListener('keydown', handleKeyPress);
return () => {
if(onKeyPress) window.removeEventListener('keydown', handleKeyPress);
};
}, []);
}, [onKeyPress]);

function handleKeyPress(event) {
// case for 'enter' or 'space' key
if(event.keyCode === 13 || event.keyCode === 32) {
onKeyPress();
}
}

return(
<div className='dialog__container white-border'>
{
goBack &&
<button onClick={goBack} className='dialog__back-button'>
<i className={`fa fa-arrow-left`} />
</button>
}
{goBack && (
<button onClick={goBack} className='dialog__back-button'>
<i className={`fa fa-arrow-left`} />
</button>
)}

{ children }
</div>
);
Expand Down
34 changes: 17 additions & 17 deletions src/components/micro-dialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ import './styles.scss';
const MicroDialog = ({ noButton, onClose, children, fullsize, className, onKeyPress }) => {

useEffect(() => {
const handleKeyPress = event => {
// case for 'enter' or 'space' key
if(event.keyCode === 13 || event.keyCode === 32) {
onKeyPress();
}
};

if(onKeyPress) window.addEventListener('keydown', handleKeyPress);
return () => {
if(onKeyPress) window.removeEventListener('keydown', handleKeyPress);
};
}, []);

function handleKeyPress(event) {
// case for 'enter' or 'space' key
if(event.keyCode === 13 || event.keyCode === 32) {
onKeyPress();
}
}
}, [onKeyPress]);

const noSpacing = { top: 0, bottom: 0, left: 0, right: 0 };

return(
<div style={fullsize ? noSpacing : {}}
className={`micro-dialog__container white-border ${className || ''}`}>

{
!noButton &&
<button className='micro-dialog__close' onClick={onClose}>
<i className={`fa fa-times`} />
</button>
}
<div
style={fullsize ? noSpacing : {}}
className={`micro-dialog__container white-border ${className || ''}`}
>
{!noButton && (
<button className='micro-dialog__close' onClick={onClose}>
<i className={`fa fa-times`} />
</button>
)}

{ children }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const useGameViewportScaling = () => {

_updateViewportScale({ largeView, sideMenu });

}, [height, width]);
}, [height, width, _updateViewportScale]);

function updateViewportScale({ largeView, sideMenu }) {
store.dispatch({
Expand Down
27 changes: 13 additions & 14 deletions src/features/dialog-manager/dialogs/chest-loot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ChestLoot = ({ dialog, pickupItem, openChest, closeChestDialog }) => {

useEffect(() => {
if(!chestOpen) openChest();
}, []);
}, [chestOpen, openChest]);

function handleContinue() {
pickupItem();
Expand Down Expand Up @@ -44,19 +44,18 @@ const ChestLoot = ({ dialog, pickupItem, openChest, closeChestDialog }) => {
<span>{ exp }</span>
</div>

{
item &&
<div className='flex-row chest-loot__item'>
<div style={{
backgroundImage: `url('${item.image}')`,
width: '40px',
height: '40px'
}} />
<span className='flex-column chest-loot__item-name'>
{item.name}
</span>
</div>
}
{item && (
<div className='flex-row chest-loot__item'>
<div style={{
backgroundImage: `url('${item.image}')`,
width: '40px',
height: '40px'
}} />
<span className='flex-column chest-loot__item-name'>
{item.name}
</span>
</div>
)}
</div>

<div className='flex-column chest-loot__buttons'>
Expand Down
106 changes: 55 additions & 51 deletions src/features/game-menus/game-music/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import Sound from 'react-sound';
import React, { useState, useEffect, useCallback } from 'react';
import { connect } from 'react-redux';
import Sound from 'react-sound';

import AmbientMusic from './ambient-music.mp3';
import setGameSound from '../actions/set-game-sound';
import AmbientMusic from './ambient-music.mp3';
import setGameSound from '../actions/set-game-sound';
import gameSoundEnabled from '../actions/game-sound-enabled';

import './styles.scss';
Expand All @@ -12,23 +12,13 @@ const GameMusic = ({ sideMenu, gameSoundEnabled, setGameSound }) => {

const [gameMusic, setGameMusic] = useState(null);

useEffect(() => {
window.addEventListener('mousedown', handleKeyPress);
window.addEventListener('keydown', handleKeyPress);
window.addEventListener('focus', handleFocus);
window.addEventListener('blur', handleBlur);
return () => {
window.removeEventListener('mousedown', handleKeyPress);
window.removeEventListener('keydown', handleKeyPress);
window.removeEventListener('focus', handleFocus);
window.removeEventListener('blur', handleBlur);
};
}, []);
function turnOffSound() {
setGameMusic(null);
setGameSound(false);
}

function handleKeyPress() {
// we have to load music only have user has clicked or pressed a key
// chrome disables auto play until user has interacted with window
if(gameSoundEnabled()) {
const turnOnSound = useCallback(
() => {
setGameMusic(
<Sound
url={AmbientMusic}
Expand All @@ -37,11 +27,10 @@ const GameMusic = ({ sideMenu, gameSoundEnabled, setGameSound }) => {
loop={true}
volume={50} />
);
}
// now we no longer need our key or mouse event listeners
window.removeEventListener('mousedown', handleKeyPress);
window.removeEventListener('keydown', handleKeyPress);
}
setGameSound(true);
},
[setGameSound]
);

function toggleMusic() {
if(gameMusic) {
Expand All @@ -52,34 +41,49 @@ const GameMusic = ({ sideMenu, gameSoundEnabled, setGameSound }) => {
}
}

function handleFocus() {
// make sure the player has music enabled before turning it back on
if(gameSoundEnabled()) {
turnOnSound();
}
}
useEffect(() => {
const handleKeyPress = () => {
// we have to load music only have user has clicked or pressed a key
// chrome disables auto play until user has interacted with window
if(gameSoundEnabled()) {
setGameMusic(
<Sound
url={AmbientMusic}
playStatus={'PLAYING'}
autoLoad={true}
loop={true}
volume={50} />
);
}
// now we no longer need our key or mouse event listeners
window.removeEventListener('mousedown', handleKeyPress);
window.removeEventListener('keydown', handleKeyPress);
};

function handleBlur() {
// during blur, don't change the sound redux state, just turn off music
setGameMusic(null);
}

function turnOffSound() {
setGameMusic(null);
setGameSound(false);
}
function handleFocus() {
// make sure the player has music enabled before turning it back on
if(gameSoundEnabled()) {
turnOnSound();
}
}

function turnOnSound() {
setGameMusic(
<Sound
url={AmbientMusic}
playStatus={'PLAYING'}
autoLoad={true}
loop={true}
volume={50} />
);
setGameSound(true);
}
function handleBlur() {
// during blur, don't change the sound redux state, just turn off music
setGameMusic(null);
}

window.addEventListener('mousedown', handleKeyPress);
window.addEventListener('keydown', handleKeyPress);
window.addEventListener('focus', handleFocus);
window.addEventListener('blur', handleBlur);
return () => {
window.removeEventListener('mousedown', handleKeyPress);
window.removeEventListener('keydown', handleKeyPress);
window.removeEventListener('focus', handleFocus);
window.removeEventListener('blur', handleBlur);
};
}, [gameSoundEnabled, turnOnSound]);

return (
<button className='game-music__button white-border'
Expand Down
Loading