Match
Date: 2017-05-13

game_frontend

## Class Match

- java.lang.Object
- - game_frontend.Match

- Direct Known Subclasses:
    Debug, Interactive, Simulation

      public abstract class Match
      extends java.lang.Object

  Represents an abstract type that defines the routines to play a Card Game
  Author:
    joaovieira

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Match.States`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `actualBet`
    `protected Card[]` | `discarded`
    `protected Play` | `game`
    `protected int` | `initialCredit`
    `protected Player` | `player`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Match(int credits)` Constructor of Match that creates a default deck
    `Match(int credits, java.util.ArrayList<Card> cards)` Constructor of Match that receives the cards to be loaded into deck

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int[]` | `advice()` Advises the user about the cards he should hold according to the implemented strategy
    `boolean` | `bet(int amount)` Performs a bet, meaning that the amount specified by amount is credited from player's account
    `int` | `credit()` Shows the player's actual credit
    `java.lang.String` | `deal()` Performs the deal, which means that the amount bet is sent to the game and five cards are retrieved from it
    `java.lang.String` | `getStats()` Retrieves the statistics of the actual game until the moment
    `java.lang.String` | `hold(int[] positions)` Holds the cards at the specified positions, discards those that are not to hold, retrieves more from the game to replace them, retrieves and evaluates the final hand and gives the player its prize (even if zero) and finally, gives back to game all the cards.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### game

          protected Play game

    - #### player

          protected Player player

    - #### discarded

          protected Card[] discarded

    - #### actualBet

          protected int actualBet

    - #### initialCredit

          protected int initialCredit

  - ### Constructor Detail

    - #### Match

          public Match(int credits)

      Constructor of Match that creates a default deck
      Parameters:
        `credits` - Amount of credits in the beginning

    - #### Match

          public Match(int credits,
                       java.util.ArrayList<Card> cards)

      Constructor of Match that receives the cards to be loaded into deck
      Parameters:
        `credits` - Amount of credits in the beginning
        `cards` - Cards to be loaded into deck

  - ### Method Detail

    - #### bet

          public boolean bet(int amount)

      Performs a bet, meaning that the amount specified by amount is credited from player's account
      Parameters:
        `amount` - Amount to bet
      Returns:
        boolean true in success or false otherwise

    - #### deal

          public java.lang.String deal()

      Performs the deal, which means that the amount bet is sent to the game and five cards are retrieved from it
      Returns:
        String Actual hand of player

    - #### hold

          public java.lang.String hold(int[] positions)

      Holds the cards at the specified positions, discards those that are not to hold, retrieves more from the game to replace them, retrieves and evaluates the final hand and gives the player its prize (even if zero) and finally, gives back to game all the cards. After this the round is over
      Parameters:
        `positions` - Positions of the cards that are to maintain
      Returns:
        String Final hand of the player in this round

    - #### credit

          public int credit()

      Shows the player's actual credit
      Returns:
        int Player's actual credit

    - #### advice

          public int[] advice()

      Advises the user about the cards he should hold according to the implemented strategy
      Returns:
        int[] Positions of the cards that the user should hold

    - #### getStats

          public java.lang.String getStats()

      Retrieves the statistics of the actual game until the moment
      Returns:
        String Statistics of the game until now