Skip to content

Commit

Permalink
fix game profile due to slippi-js changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilNarayana committed May 12, 2021
1 parent 9bb748d commit b65c440
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions app/components/stats/GameProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,12 @@ export default class GameProfile extends Component {
<KillsTable
game={this.props.store.game}
playerDisplay={this.renderPlayerColHeader(true)}
playerIndex={this.getPlayerIndex(true)}
playerIndex={this.getPlayerIndex(false)}
/>
<KillsTable
game={this.props.store.game}
playerDisplay={this.renderPlayerColHeader(false)}
playerIndex={this.getPlayerIndex(false)}
playerIndex={this.getPlayerIndex(true)}
/>
</div>
</Segment>
Expand All @@ -451,24 +451,24 @@ export default class GameProfile extends Component {
<PunishesTable
game={this.props.store.game}
playerDisplay={this.renderPlayerColHeader(true)}
playerIndex={this.getPlayerIndex(true)}
playerIndex={this.getPlayerIndex(false)}
playFile={this.props.playFile}
/>
<PunishesTable
game={this.props.store.game}
playerDisplay={this.renderPlayerColHeader(false)}
playerIndex={this.getPlayerIndex(false)}
playerIndex={this.getPlayerIndex(true)}
playFile={this.props.playFile}
/>
</div>
</Segment>
);
}

getPlayerIndex(isFirstPlayer = true) {
getPlayerIndex(wantFirstPlayer = true) {
const gameSettings = _.get(this.props.store, ['game', 'settings']) || {};
const players = gameSettings.players || [];
const player = (isFirstPlayer ? _.first(players) : _.last(players)) || {};
const player = (wantFirstPlayer ? _.first(players) : _.last(players)) || {};
return player.playerIndex;
}

Expand Down
6 changes: 3 additions & 3 deletions app/components/stats/KillsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ export default class KillsTable extends Component {
renderStocksRows() {
const stats = this.props.game.getStats() || {};
const stocks = _.get(stats, 'stocks') || [];
const stocksByOpponent = _.groupBy(stocks, 'opponentIndex');
const opponentStocks = stocksByOpponent[this.props.playerIndex] || [];
const stocksByPlayer = _.groupBy(stocks, 'playerIndex');
const playerStocks = stocksByPlayer[this.props.playerIndex] || [];

return opponentStocks.map(this.generateStockRow);
return playerStocks.map(this.generateStockRow);
}

render() {
Expand Down
10 changes: 5 additions & 5 deletions app/components/stats/PunishesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ export default class PunishesTable extends Component {
const playerPunishes = punishesByPlayer[this.props.playerIndex] || [];

const stocks = _.get(stats, 'stocks') || [];
const stocksByOpponent = _.groupBy(stocks, 'opponentIndex');
const opponentStocks = stocksByOpponent[this.props.playerIndex] || [];
const stocksByPlayer = _.groupBy(stocks, 'playerIndex');
const playerStocks = stocksByPlayer[this.props.playerIndex] || [];

const elements = [];

const addStockRows = punish => {
const shouldDisplayStockLoss = () => {
// Calculates whether we should display a stock loss row in this position
const currentStock = _.first(opponentStocks);
const currentStock = _.first(playerStocks);
const currentStockWasLost = currentStock && currentStock.endFrame;
const wasLostBeforeNextPunish =
!punish || currentStock.endFrame < punish.startFrame;
Expand All @@ -233,7 +233,7 @@ export default class PunishesTable extends Component {
// stock
let shouldAddEmptyState = punish === _.first(playerPunishes);
while (shouldDisplayStockLoss()) {
const stock = opponentStocks.shift();
const stock = playerStocks.shift();

if (shouldAddEmptyState) {
const emptyPunishes = this.generateEmptyRow(stock);
Expand All @@ -251,7 +251,7 @@ export default class PunishesTable extends Component {

// Special case handling when a player finishes their opponent without getting hit
// on their last stock. Still want to show an empty state
const stock = _.first(opponentStocks);
const stock = _.first(playerStocks);
if (stock && addedStockRow && !punish) {
const emptyPunishes = this.generateEmptyRow(stock);
elements.push(emptyPunishes);
Expand Down

0 comments on commit b65c440

Please sign in to comment.