Giter Site home page Giter Site logo

inooid / react-redux-card-game Goto Github PK

View Code? Open in Web Editor NEW
106.0 7.0 20.0 389 KB

A web version of Blizzard's Hearthstone game built with React, Redux and ImmutableJS

License: MIT License

JavaScript 91.92% CSS 7.87% HTML 0.21%
hearthstone react redux immutablejs socket-io

react-redux-card-game's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-redux-card-game's Issues

Datastructure thoughts

Structure 1:

{
  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:
}

Structure 2:

{
  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!

Make production webpack config

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
  • might be: webpack/server.js

How to add board mechanics?

First implementation (not looking at any code styling, just raw implementation):

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]

Upgrade dependencies

There's a lot of dependencies that are outdated. There are some easy updates and some harder ones.

Some problematic ones:

  • Webpack
  • Airbnb ESLint config

Remove hardcoded width and height in CustomDragLayer

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.

Hand hover-over visuals

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.