Skip to content

Commit

Permalink
Show p1 starting hand in replay cards
Browse files Browse the repository at this point in the history
  • Loading branch information
linrock committed Feb 14, 2019
1 parent a4eab24 commit 772c1f6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ gem 'slim'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'webpacker', '>= 4.0.x'
# gem 'mini_racer', platforms: :ruby

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
# Access an interactive console on exception pages or
# by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'pry'
Expand Down
4 changes: 4 additions & 0 deletions app/console/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module MetaLegend
module Console
# convenience functions

def migrate(hsreplay_id)
CombinedReplayDataMigrator.new(hsreplay_id).migrate!
end

def rx(hsreplay_id)
ReplayXmlData.find_by(hsreplay_id: hsreplay_id)
end
Expand Down
39 changes: 29 additions & 10 deletions app/javascript/beta/components/replay_card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@
use(xlink:href="#crown")
.archetype
| {{ p2.archetype }} {{ p2.className }}
.replay-info
.num-turns {{ replay.numTurns }} turns
.duration {{ parseInt(replay.durationSeconds / 60) }} minutes
.game-type {{ replay.gameType }}
.under-info
.starting-hand
.post
div(v-for="card in p1.postMulliganCards")
span.cost {{ card.cost }}
span.name {{ card.name }}
.replay-info
.num-turns {{ replay.numTurns }} turns
.duration {{ parseInt(replay.durationSeconds / 60) }} minutes
.game-type {{ replay.gameType }}

</template>

Expand Down Expand Up @@ -97,17 +103,30 @@
justify-content center
display flex
.replay-info
// info under the list of game players
.under-info
display flex
justify-content flex-end
font-size 14px
justify-content space-between
margin-top 15px
padding-right 15px
opacity 0.5
> div
.starting-hand
font-size 13px
line-height 18px
margin-left 15px
.cost
margin-right 10px
.replay-info
display flex
justify-content flex-end
font-size 14px
padding-right 15px
opacity 0.5
> div
margin-left 15px
.player
display flex
flex-direction column
Expand Down
18 changes: 15 additions & 3 deletions app/javascript/beta/models/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ export interface PlayerOptions {
is_winner: boolean
deck_cards: Array<Card>
predicted_deck_cards?: Array<Card>
pre_mulligan_cards?: Array<Card>
post_mulligan_cards?: Array<Card>
}

const initCards = (cardData): Array<Card> => cardData.map(c => new Card(c))

export class Player {
public className: string
public archetype: string
private battletag: string
public legendRank: number
public rank: number
public deckCards: Array<Card>
public preMulliganCards: Array<Card>
public postMulliganCards: Array<Card>
public deckStatus: string
public isWinner: boolean

Expand All @@ -29,15 +35,21 @@ export class Player {
this.rank = parseInt(options.rank, 10)
this.isWinner = options.is_winner
if (this.nCards(options.deck_cards) === 30) {
this.deckCards = options.deck_cards.map(c => new Card(c))
this.deckCards = initCards(options.deck_cards)
this.deckStatus = `full`
} else if (options.predicted_deck_cards) {
this.deckCards = options.predicted_deck_cards.map(c => new Card(c))
this.deckCards = initCards(options.predicted_deck_cards)
this.deckStatus = `predicted`
} else {
this.deckCards = options.deck_cards.map(c => new Card(c))
this.deckCards = initCards(options.deck_cards)
this.deckStatus = `partial`
}
if (options.pre_mulligan_cards) {
this.preMulliganCards = initCards(options.pre_mulligan_cards)
}
if (options.post_mulligan_cards) {
this.postMulliganCards = initCards(options.post_mulligan_cards)
}
}

get name(): string {
Expand Down

0 comments on commit 772c1f6

Please sign in to comment.