Giter VIP home page Giter VIP logo

hearthstone-tracker's Introduction

Circle CI Code Climate Test Coverage Issue Count An electron based Hearthstone tracker Greenkeeper badge

hearthstone-tracker

An electron based Hearthstone tracker

To get started:

git clone [email protected]:gregstewart/hearthstone-tracker.git && cd hearthstone-tracker

Then run:

npm i && npm start

After a shortish time you should see something like the below the firs time you start the app:

First screenshot

Launch Hearthstone and play a few games, the UI should update after each completed game.

If you see an error similar to the below:

> [email protected] start /Users/gregstewart/Projects/GitHub/hearthstone-tracker
> electron .

info: undefined undefined
error:  Error: Module version mismatch. Expected 50, got 48. This generally implies that leveldown was built with a different version of node than that which is running now.  You may try fully removing and reinstalling PouchDB or leveldown to resolve.

Then run:

npm run rebuild:leveldb && npm start

To run the tests:

npm test

Some reources:

For packaging

hearthstone-tracker's People

Contributors

greenkeeper[bot] avatar greenkeeperio-bot avatar gregstewart avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hearthstone-tracker's Issues

Unique users

Thinking long term if I decide to sync the data with a service later on so that users can log in and view their data whenever, I will need to uniquely identify them.

To get things rolling maybe use a service like Auth0.

Current records would need to be updated to associate a unique identifier, so some kind of migration scripts will need to be written as well.

Warning: Accessing PropTypes

Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Replaced the old Node.js version in your .nvmrc with the new one
  • The engines config in 1 of your package.json files was updated to the new Node.js version

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Seasons

Show the stats for the current season only and maybe last seasons, that looks something like this:

Current season Last season
Wins: x Wins: x
Losses: x Losses: x
Ratio: xx.xx% Ratio: xx.xx%

Win condition is incorrect

It looks like the the win condition is preserved from the first encounter. I.e. if I loose the first match, then play another one (which I win), then the win condition still shows that I have lost.

Stats as a chart

Currently we display the season stats as text. It would be great to display these as a pie chart instead.

Getting error with winston-transport

Getting the following error. I tried with both latest node and also Node 8.2.1 listed in package.json. I am running on MacOSX 10.14.1

> electron .

App threw an error during load
Error: Invalid transport, must be an object with a log method.
    at new LegacyTransportStream (/Users/vidalgraupera/code/2018/hearthstone-tracker/node_modul
es/winston-transport/legacy.js:18:11)
    at DerivedLogger.add (/Users/vidalgraupera/code/2018/hearthstone-tracker/node_modules/winst
on/lib/winston/logger.js:245:9)
    at Object.winston.(anonymous function).args [as add] (/Users/vidalgraupera/code/2018/hearth
stone-tracker/node_modules/winston/lib/winston.js:101:55)
    at Object.<anonymous> (/Users/vidalgraupera/code/2018/hearthstone-tracker/index.js:34:9)
    at Object.<anonymous> (/Users/vidalgraupera/code/2018/hearthstone-tracker/index.js:117:3)
    at Module._compile (module.js:642:30)
    at loader (/Users/vidalgraupera/code/2018/hearthstone-tracker/node_modules/babel-register/l
ib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/vidalgraupera/code/2018/
hearthstone-tracker/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:561:32)

Capture player name

Currently the data structure for an encounter looks as follows:

{
  matchId: "",
  playerId: "",
  for: "",
  against: "",
  log: [],
  hasWon: ""
}

I would like to change it so that it includes the player's name as well. If I do that then then for/against key should store an object:

{
  matchId: "",
  for: {name: "bob": class:"Hunter", playerId: 1},
  against: {name: "al": class:"Priest", playerId: 2},
  log: [],
  hasWon: ""
}

Warning: Shallow renderer

Warning: Shallow renderer has been moved to react-test-renderer/shallow. Update references to remove this warning.

Logging and end game conditions

Throw an exception:

Uncaught Exception:
TypeError: _winston2.default.change is not a function
    at Changes$1.<anonymous> (index.js:49:13)
    at emitOne (events.js:77:13)
    at Changes$1.emit (events.js:169:7)
    at Object.Changes$1.opts.onChange (/Users/gregstewart/Projects/github/hearthstone-tracker/node_modules/pouchdb/lib/index.js:710:10)
    at Changes$1.<anonymous> (/Users/gregstewart/Projects/github/hearthstone-tracker/node_modules/pouchdb/lib/index.js:6056:14)
    at emitOne (events.js:77:13)
    at Changes$1.emit (events.js:169:7)
    at Object.Changes$1.opts.onChange (/Users/gregstewart/Projects/github/hearthstone-tracker/node_modules/pouchdb/lib/index.js:710:10)
    at onGetWinningDoc (/Users/gregstewart/Projects/github/hearthstone-tracker/node_modules/pouchdb/lib/index.js:7851:20)
    at onGetMetadata (/Users/gregstewart/Projects/github/hearthstone-tracker/node_modules/pouchdb/lib/index.js:7869:18)
    at /Users/gregstewart/Projects/github/hearthstone-tracker/node_modules/pouchdb/lib/index.js:7893:9
    at /Users/gregstewart/Projects/github/hearthstone-tracker/node_modules/pouchdb/node_modules/level-sublevel/shell.js:102:12
    at /Users/gregstewart/Projects/github/hearthstone-tracker/node_modules/pouchdb/node_modules/level-sublevel/nut.js:121:19

Listening for crash events

When using devtron I get a linting error suggesting I start listening for crashed event on the webContents property of the BrowserWindow. Something like this should help fix the issue:

myWindow.webContents.on('crashed', () => {})

Running coverage on ci server is broken

For some reason on Circle CI I get this when trying to run code coverage:

npm run coverage

> [email protected] coverage /home/ubuntu/hearthstone-tracker
> nyc --reporter=lcov --reporter=text ./node_modules/.bin/_mocha test

File [/home/ubuntu/hearthstone-tracker/src/parse-friendly-player.js] ignored, nothing could be mapped
File [/home/ubuntu/hearthstone-tracker/src/data-structures.js] ignored, nothing could be mapped
File [/home/ubuntu/hearthstone-tracker/src/find-class.js] ignored, nothing could be mapped
File [/home/ubuntu/hearthstone-tracker/src/win-condition.js] ignored, nothing could be mapped
/home/ubuntu/hearthstone-tracker/src/log-watcher.js:1
(function (exports, require, module, __filename, __dirname) { 'use strict';var __cov_ONYfe_P3ZtfWuOqICRtWaopgy90=function(){var path="/home/ubuntu/hearthstone-tracker/src/log-watcher.js",hash="86442683bb5ce726c8ba154cd6c26fcbfd7675ed",global=new Function('return this')(),gcv="__coverage__",coverageData={path:"/home/ubuntu/hearthstone-tracker/src/log-watcher.js",statementMap:{"1":{start:{line:3,column:0},end:{line:5,column:3}},"2":{start:{line:7,column:21},end:{line:7,column:663}},"3":{start:{line:7,column:79},end:{line:7,column:81}},"4":{start:{line:7,column:92},end:{line:7,column:96}},"5":{start:{line:7,column:107},end:{line:7,column:112}},"6":{start:{line:7,column:123},end:{line:7,column:132}},"7":{start:{line:7,column:134},end:{line:7,column:413}},"8":{start:{line:7,column:140},end:{line:7,column:283}},"9":{start:{line:7,column:226},end:{line:7,column:246}},"10":{start:{line:7,column:247},end:{line:7,column:281}},"11":{start:{line:7,column:275},end:{l

TypeError: Cannot read property '0' of undefined
    at _slicedToArray (/home/ubuntu/hearthstone-tracker/src/log-watcher.js:1:15378)

Disabled it for now, maybe look into an alternative?

Listening for unresponsive events

When using devtron I get a linting error suggesting I start listening for unresponsive event on the webContents property of the BrowserWindow. Something like this should help fix the issue:

myWindow.webContents.on('unresponsive', () => {})

Breakdown of match outcomes

Regardless of win or loss, I think it would be interesting to show what the class breakdown would be for each category and against whom the outcome came:

  • Wins: 5
    • Paladin: 3
      • Warlock: 1
      • Hunter: 2
    • Priest: 1
      • Hunter: 1
    • Hunter:
      Druid: 1

Using a graph and being able to drill down would be good too: Wins -> Class -> Opponent

Fix linting issues

Getting these warnings recently:

The react/require-extension rule is deprecated. Please use the import/extensions rule from eslint-plugin-import instead.
The react/wrap-multilines rule is deprecated. Please use the react/jsx-wrap-multilines rule instead.

Generate test data

Just throwing some ideas out there...

generateResult().wins(2).as(‘Priest').against(‘Warlock’).and(‘Druid);
generateResult(
 [ doc(for(‘rogue’), true, against(‘shaman’), 1453420291617, 10)]
)

class(‘druid’).beats().class(’Shaman’),
class(‘rogue’).looses().class(‘warlock’),
class(‘rogue’).beats().class(‘warlock’),
class(‘rogue’).beats().class(‘mage’),
class(‘rogue’).looses().class(‘rogue’),
class(‘priest’).beats().class(’Shaman’),

for = (className)  => {
     return {
	name: randomName(),
        id: 1,
        class: className
     }
}

against = (className) => {
     return {
        name: randomName(),
        id: 2,
        class: className
      }
},

/**
for: Me
against: my opponent
started: unix time stamp
lasted: time in minutes the match lasted
*/
doc = (for, outcome, against, started, lasted) => {
	startTime: toDate(started)
	endTime: toDate(started).add(lasted)
	for: for
        against: against
        log: []
        hasWon: outcome
       _id: toString(started)
       _rev: ‘some pouch db value'
}

Listening for uncaughtException events

When using devtron I get a linting error suggesting I start listening for uncaughtException event on the main process. Something like this should help fix the issue:

process.on('uncaughtException', () => {})

This will stop the nasty popup, so we can log it but we should still notify the user.

Show win/loss streak

Display the last 5 games played:

  1. Win
    • Rogue vs Warlock
  2. Win
    • Paladin vs Druid
  3. Win
    • Paladin vs Paladin
  4. Loss
    • Paladin vs Hunter
  5. Loss
    • Hunter vs Shaman

To make it look prettier we could use either the class colours or the hero avatars.

Another option would be to maybe use a simple Sparkeline graph:

Sparkleline

Breakdown of matches

I show the percentage of wins by class, i.e. out of a 100% wins, 35% are with a warrior, etc... This is basically a breakdown of the wins/losses by class.

It would be good to show the win rate by class, i.e. out of 100% of matches played as a warrior, I win xx%.

Track pack openings

Would you be interested in including a mechanism to track pack openings?

I'm thinking of something that would track how close you are to hitting your pity timer limits for Legendaries, Epics, and golden cards.

I'd be available to help or lead out on coding this up if it's something you're willing to incorporate.

Warning: Unhandled promise rejection

(node:17410) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): TypeError: db.allDocs is not a function
(node:17410) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Handle disconnected games

The other night while playing a match I got disconnected and as a result lost the game. The tracker did not catch this. Some other event must get fired when you log back in.

Import lint warnings

Since switching to eslint-plugin-import I get the following warnings:

/Users/gregstewart/Projects/GitHub/hearthstone-tracker/app/views/app.jsx
  4:18  warning  Unable to resolve path to module './main'  import/no-unresolved

/Users/gregstewart/Projects/GitHub/hearthstone-tracker/app/views/game-stats-by-class.jsx
  3:29  warning  Unable to resolve path to module './game-stat-by-class'  import/no-unresolved

/Users/gregstewart/Projects/GitHub/hearthstone-tracker/app/views/main.jsx
  3:19  warning  Unable to resolve path to module './stats'            import/no-unresolved
  4:24  warning  Unable to resolve path to module './win-streaks'      import/no-unresolved
  5:28  warning  Unable to resolve path to module './match-breakdown'  import/no-unresolved

/Users/gregstewart/Projects/GitHub/hearthstone-tracker/app/views/match-breakdown.jsx
  3:30  warning  Unable to resolve path to module './game-stats-by-class'  import/no-unresolved

/Users/gregstewart/Projects/GitHub/hearthstone-tracker/app/views/stats.jsx
  3:18  warning  Unable to resolve path to module './stat'  import/no-unresolved

/Users/gregstewart/Projects/GitHub/hearthstone-tracker/app/views/win-streaks.jsx
  3:23  warning  Unable to resolve path to module './win-streak'  import/no-unresolved

✖ 8 problems (0 errors, 8 warnings)

Tied matches

info: no game start event
info:  name=artaios, id=1, status=TIED
info: false

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.