Skip to content

Commit

Permalink
Merge pull request #125 from hunterjm/develop
Browse files Browse the repository at this point in the history
v0.4.1
  • Loading branch information
hunterjm authored Feb 11, 2017
2 parents 6123d51 + 4115a17 commit 0350821
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ main.js
main.js.map

.idea

_site/
5 changes: 5 additions & 0 deletions app/components/player/PlayerHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class PlayerHistory extends Component {
const meanSold = ss.mean(soldPrices) || 'N/A';
const medianSold = ss.median(soldPrices) || 'N/A';
const meanSoldTime = ss.mean(soldTime) || 'N/A';
const totalProfit = ss.sum(profits) || 'N/A';
const meanProfit = ss.mean(profits) || 'N/A';

const tabDailyClasses = classNames({
Expand Down Expand Up @@ -233,6 +234,10 @@ export class PlayerHistory extends Component {
<td>Completed Trades</td>
<td>{both.length}</td>
</tr>
<tr>
<td>Lifetime Profit</td>
<td>{totalProfit}</td>
</tr>
<tr>
<td>Average Profit per Trade</td>
<td>{meanProfit}</td>
Expand Down
9 changes: 8 additions & 1 deletion app/components/player/PlayerListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { remote } from 'electron';
import { OverlayTrigger, Tooltip } from 'react-bootstrap';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import ss from 'simple-statistics';
import numeral from 'numeral';
import * as PlayerActions from '../../actions/player';

Expand Down Expand Up @@ -57,6 +58,11 @@ export class PlayerListItem extends Component {
</OverlayTrigger>
);

const history = Object.values(this.props.history);
const both = history.filter(trade => trade.bought > 0 && trade.sold > 0);
const profits = both.map(trade => (trade.sold * 0.95) - trade.bought);
const totalProfit = ss.sum(profits) || 'N/A';

return (
<div ref={node => (this.node = node)}>
<li
Expand All @@ -71,7 +77,7 @@ export class PlayerListItem extends Component {
{player.name}
</div>
<div className="image">
{player.rating} | {player.position}
profit: {numeral(totalProfit).format('0,0')}
<br />
{numeral(_.get(player, 'price.buy')).format('0,0')}/
{numeral(_.get(player, 'price.sell')).format('0,0')}/
Expand All @@ -94,6 +100,7 @@ PlayerListItem.propTypes = {
id: PropTypes.int,
name: PropTypes.string
}),
history: PropTypes.shape({}),
remove: PropTypes.func.isRequired,
};

Expand Down
11 changes: 11 additions & 0 deletions app/components/player/PlayerSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import classNames from 'classnames';
import _ from 'lodash';
import { shell } from 'electron';
import PlayerCard from './SmallPlayerCard';
import * as PlayerActions from '../../actions/player';

Expand Down Expand Up @@ -185,6 +186,16 @@ export class PlayerSearch extends Component {
results = (
<div className="no-results">
<h2>Search for players above.</h2>
<div>
This autobuyer is free and open source (unless you bought it off eBay from
<a onClick={() => shell.openExternal('http://www.ebay.com/usr/youssekafe_0')}> this guy</a>).
</div>
<div>Please consider donating to help support development of new features.</div>
<div>
<a onClick={() => shell.openExternal('https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=hunterjm%40gmail%2ecom&lc=US&item_name=FIFA%20Autobuyer&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted')}>
<img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="Donate Here" width="94" height="20" />
</a>
</div>
</div>
);
}
Expand Down
4 changes: 3 additions & 1 deletion app/containers/Players.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Players extends Component {

const players = _.map(
_.get(this.props, 'player.list', {}),
player => <ConnectedPlayerListItem key={player.id} player={player} />
player => <ConnectedPlayerListItem key={player.id} player={player} history={_.get(this.props.history, player.id, {})} /> // eslint-disable-line max-len
);

const overviewClasses = classNames({
Expand Down Expand Up @@ -278,6 +278,7 @@ export class Players extends Component {
Players.propTypes = {
children: PropTypes.element.isRequired,
player: PropTypes.shape({}),
history: PropTypes.shape({}),
location: PropTypes.shape({
pathname: PropTypes.string
}),
Expand All @@ -294,6 +295,7 @@ Players.contextTypes = {
function mapStateToProps(state) {
return {
player: state.player,
history: state.history,
bidding: state.bid.bidding
};
}
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fifa-autobuyer",
"productName": "FIFA Autobuyer",
"version": "0.4.0",
"version": "0.4.1",
"description": "Autobuyer for FIFA 17 Ultimate Team",
"main": "./main.js",
"author": {
Expand Down
3 changes: 3 additions & 0 deletions app/styles/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ html, body {
img {
pointer-events: none;
}
a {
cursor: pointer;
}
}

#root, #root-main {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fifa-autobuyer",
"productName": "FIFA Autobuyer",
"version": "0.4.0",
"version": "0.4.1",
"description": "Autobuyer for FIFA 17 Ultimate Team",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -175,7 +175,7 @@
"react": "^15.4.1",
"react-bootstrap": "^0.30.3",
"react-dom": "^15.4.1",
"react-joyride": "^1.9.0",
"react-joyride": "1.9.0",
"react-redux": "^5.0.1",
"react-retina-image": "^2.0.3",
"react-router": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions test/components/player/PlayerListItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function setup(active = false) {
router: React.PropTypes.object
}
};
const component = shallow(<PlayerListItem player={player} {...actions} />, context);
const component = shallow(<PlayerListItem player={player} history={{}} {...actions} />, context);
return {
component,
actions,
Expand All @@ -64,7 +64,7 @@ describe('components', () => {
const { stats } = setup();
expect(stats).to.have.length(1);
expect(stats.text()).to.equal(
`${player.rating} | ${player.position}${numeral(_.get(player, 'price.buy')).format('0,0')}/${numeral(_.get(player, 'price.sell')).format('0,0')}/${numeral(_.get(player, 'price.bin')).format('0,0')}`
`profit: 0${numeral(_.get(player, 'price.buy')).format('0,0')}/${numeral(_.get(player, 'price.sell')).format('0,0')}/${numeral(_.get(player, 'price.bin')).format('0,0')}`
);
});

Expand Down
3 changes: 2 additions & 1 deletion test/containers/Players.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ describe('containers', () => {
67276528: totwPlayer
},
search: {}
}
},
history: {}
});
expect(playerCards).to.have.length(2);
});
Expand Down

0 comments on commit 0350821

Please sign in to comment.