src/util.js
function getAttackResults(_cards) {
  // Force the cards into an array. Clone is too
  // to avoid side effects from the simulation.
  const cards = Util.clone(Array.isArray(_cards) ? _cards : [_cards])
  const Junkyard = require('./junkyard')
  const game = new Junkyard('1', '')
  game.addPlayer('2', '')
  game.addPlayer('3', '')
  game.start()
  const [p1, , p3] = game.players
  p1.hand = cards
  game.play(p1, [...cards], p3.id)
  game.pass(p3)
  return {
    damage: p3.maxHp - p3.hp,
    missTurns: p3.missTurns
  }
}
function getAttackResults(_cards) {
  // Force the cards into an array. Clone is too
  // to avoid side effects from the simulation.
  const cards = Util.clone(Array.isArray(_cards) ? _cards : [_cards])
  const Junkyard = require('./junkyard')
  const game = new Junkyard('1', '')
  game.addPlayer('2', '')
  game.addPlayer('3', '')
  game.start()
  const [p1, , p3] = game.players
  p1.hand = cards
  game.play(p1, [...cards], p3.id)
  game.pass(p3)
  return {
    damage: p3.maxHp - p3.hp,
    missTurns: p3.missTurns
  }
}
function getAttackResults ( _cards ) { // Force the cards into an array. Clone is too // to avoid side effects from the simulation. const cards = Util . clone ( Array . isArray ( _cards ) ? _cards : [ _cards ] ) const Junkyard = require ( './junkyard' ) const game = new Junkyard ( '1' , '' ) game . addPlayer ( '2' , '' ) game . addPlayer ( '3' , '' ) game . start ( ) const [ p1 , , p3 ] = game . players p1 . hand = cards game . play ( p1 , [ ... cards ] , p3 . id ) game . pass ( p3 ) return { damage : p3 . maxHp - p3 . hp , missTurns : p3 . missTurns } }
Determine an attack's damages by simulating playing it
Determine an attack s damages by simulating playing it