inooid / react-redux-card-game Goto Github PK
View Code? Open in Web Editor NEWA web version of Blizzard's Hearthstone game built with React, Redux and ImmutableJS
License: MIT License
A web version of Blizzard's Hearthstone game built with React, Redux and ImmutableJS
License: MIT License
For a better developer experience we should add the persistState enhancer for our redux store. More about that here:
https://github.com/gaearon/redux-devtools/blob/master/docs/Walkthrough.md#storeconfigurestorejs
If ESLint finds an error, it should not break the build. It should just warn the developer.
Title says it all
Includes #34, but also other libraries that get hit by the Snyk vulnerability scan: https://snyk.io/org/inooid/project/inooid%2Freact-redux-card-game
{
board: {
you: [null, null, null, null, null, null, null],
opponent: [null, null, null, null, null, null, null]
},
player: {
you: {
name: 'Inooid'
hero: 'Mage'
health: 30,
mana: 1,
weapon: {
portait: 'imgurl'
damage: 2,
durability: 8,
callback: fn
},
heropower: {
portait: '',
mana: 2,
fireOff: fn
}
}
opponent: {
name: 'Inooid'
hero: 'Mage'
health: 30,
mana: 1,
weapon: null,
heropower: {
portait: '',
mana: 2,
fireOff: fn
}
}
},
decks: {
you: [],
opponent: {
count: 30
}
},
hand: {
you: [],
opponent: []
},
history: [],
turn:
}
{
you: {
player: {
name: 'Inooid'
health: 30,
mana: 1,
armor: 0,
damage: 0,
weapon: null,
hero: null
},
deck: [],
hand: [],
board: [null, null, null, null, null, null, null]
},
opponent: {
player: {
name: 'Kanopi',
health: 30,
mana: 1,
weapon: null,
hero: {
heroClass: 'Warlock'
portrait: ''
power: {
mana: 2,
portrait: 'images/heroes/portraits/warlock.png',
callback: function() { }
}
}
heropower: {
mana: 2,
portait:
}
}
},
turn: 'you'
}
My preference goes to structure 2, but if there's any other way of doing it, I am open to suggestions!
Don't forget to also remove Redux DevTools in production.
Files that have ESLint errors disables, because of this issue:
containers/DevTools/DevTools.js
redux/configureStore.js
webpack/server.js
As described in the redux recipe about using selectors we are using a selector in two different containers. This will make the selector not memoizable, so we might want to rewrite that into a function as described here: https://github.com/reactjs/redux/blob/master/docs/recipes/ComputingDerivedData.md#containersvisibletodolistjs-2
File: src/redux/modules/board.js
class Board {
constructor() {
this.board = [null, null, null, 'card', null, null, null];
}
addCard(card, index) {
let emptyIndex;
const center = 3;
if (this.board[center] === null) { return this.board[center] = card; }
if (index < center) {
emptyIndex = this._findEmptySpotIndex(2, true);
if (emptyIndex !== -1) {
return this.board[emptyIndex] = card;
}
}
emptyIndex = this._findEmptySpotIndex(4);
if (emptyIndex !== -1) {
return this.board[emptyIndex] = card;
}
}
_findEmptySpotIndex(start, backwards = false) {
if (backwards) {
for(let i = start; i >= 0; i--) {
if (this.board[i] === null) {
return i;
}
}
} else {
for(let i = start; i < 7; i++) {
if (this.board[i] === null) {
return i;
}
}
}
return -1;
}
}
const board = new Board;
board.addCard('card2', 0);
board.board
=> [null, null, 'card2', 'card', null, null, null]
Currently minions are both DropTarget
's and DragSource
's, because you can drag the minion, but also drag a minion on top of another minion to position them next to them. In order to fix some ugly styling issues, I found this useful issue that might clean up our code.
Thanks to @iljadaderko for pointing that out.
There's a lot of dependencies that are outdated. There are some easy updates and some harder ones.
Some problematic ones:
Title says it all
See: containers/BoardSideDropTarget/BoardSideDropTarget.js
for an example on usage of
ReactDOM.findDOMNode()
Possible solution: react-dnd/react-dnd#329
On Windows > npm install > npm start >
"error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style"
Solution:
react-redux-card-game (directory) > .eslintrc (file) > rules > add "linebreak-style": 0,
This still needs to be done ๐
Remove the hardcoded width and height that were added for debug purposes. Also it might be useful to split out the CustomDragLayer
into multiple components.
See containers/CustomDragLayer/CustomDragLayer.js
's render()
function.
Title says it all
When you mouse over a card, the graphics of the card expands and blocks mousing over the other cards. This gives a bad user experience.
Seems like there needs to be a fundamental separation of card graphics and mouseover collision.
Here is a short clip of how Hearthstone does it
You bashed your head against this problem a bit on stream, but decided to put it off for later, so I'm making an issue to remind you later.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.