fungi-game.js
/*
  This helper function tells the external controller whether the game is
  'continuable' or 'lost'. It checks four conditions:
  1) can the inventory be sold for a value that results in positive gold,
  2) can the board be advanced,
  3) can anything be picked up from the board.
  It returns NO_LEGAL_MOVES when no condition is met - i.e. when
  absolutely nothing can be done to gain gold in the next move.
  It is up to the external controller whether this results in an info,
  a warning or a gameover-type halt.
  */
This helper function tells the external controller whether the game is
'continuable' or 'lost'. It checks four conditions:
1) can the inventory be sold for a value that results in positive gold,
2) can the board be advanced,
3) can anything be picked up from the board.
It returns NO_LEGAL_MOVES when no condition is met - i.e. when
absolutely nothing can be done to gain gold in the next move.
It is up to the external controller whether this results in an info,
a warning or a gameover-type halt.
This helper function tells the external controller whether the game is ' continuable ' or ' lost ' . It checks four conditions : 1 ) can the inventory be sold for a value that results in positive gold 2 ) can the board be advanced 3 ) can anything be picked up from the board . It returns NO_LEGAL_MOVES when no condition is met - i . e . when absolutely nothing can be done to gain gold in the next move . It is up to the external controller whether this results in an info a warning or a gameover - type halt .
checkLegalMoves () {
    let inventoryContentCondition = this.inventory.isFull()
    let inventoryValueCondition = this.inventory.getTotalValue(
      this.mushroomTable,
      this.stageBonusExponent,
      this.sameTypeBonusMultiplier,
      this.sameStageBonusMultiplier,
      this.tricolorBonus
    ) + this.gold > 0
    let inventoryCondition = inventoryContentCondition && inventoryValueCondition
    let advanceCondition = this.gold >= this.advanceCost
    let boardPickupCondition = false
    for (let slot of this.board) {
      if (slot.isPickable() && slot.getPickupCost(this.pickupCost, this.pickupPenalty, this.pickupPenaltyExponent) <= this.gold) {
        boardPickupCondition = true
      }
    }
    if (inventoryCondition || advanceCondition || boardPickupCondition) {
      return Game.actionResponses.CONTINUE
    }
    else {
      return Game.actionResponses.NO_LEGAL_MOVES
    }
  }
checkLegalMoves ( ) { let inventoryContentCondition = this . inventory . isFull ( ) let inventoryValueCondition = this . inventory . getTotalValue ( this . mushroomTable , this . stageBonusExponent , this . sameTypeBonusMultiplier , this . sameStageBonusMultiplier , this . tricolorBonus ) + this . gold > 0 let inventoryCondition = inventoryContentCondition && inventoryValueCondition let advanceCondition = this . gold >= this . advanceCost let boardPickupCondition = false for ( let slot of this . board ) { if ( slot . isPickable ( ) && slot . getPickupCost ( this . pickupCost , this . pickupPenalty , this . pickupPenaltyExponent ) <= this . gold ) { boardPickupCondition = true } } if ( inventoryCondition || advanceCondition || boardPickupCondition ) { return Game . actionResponses . CONTINUE } else { return Game . actionResponses . NO_LEGAL_MOVES } }
This helper function tells the external controller whether the game is
'continuable' or 'lost'.
This helper function tells the external controller whether the game is ' continuable ' or ' lost ' .