public class Bank
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private int[] |
devCards |
private int[] |
newDevCards |
private int |
numberDevCardTypes |
private int |
numberPieceTypes |
private int |
numberResourceTypes |
private int[] |
pieces |
private int[] |
resources |
private static long |
serialVersionUID |
private int |
solidersInPlay |
Constructor and Description |
---|
Bank()
Creates a bank
|
Modifier and Type | Method and Description |
---|---|
boolean |
buildCity()
Removes resource cards, if allowed, needed to build a city (two wheat, three ore, one city)
|
void |
buildRoad()
Removes resource cards, if allowed, needed to build a road (one wood, one brick, one road)
|
void |
buildSettlement()
Removes resource cards, if allowed, needed to build a settlement (one wood, one brick, one sheep, one wheat, one settlement)
|
void |
buyDevCard()
Removes resource cards, if allowed, needed to buy a development card (one wheat, one sheep, one ore)
|
boolean |
canBuildCity()
Checks if has enough cards to build a city (two wheat, three ore, one city)
|
boolean |
canBuildRoad()
Checks if has enough cards to build a road (one wood, one brick, one road)
|
boolean |
canBuildSettlement()
Checks if has enough cards to build a settlement (one wood, one brick, one sheep, one wheat, one settlement)
|
boolean |
canBuyDevCard()
Checks if has enough cards to buy a development card (one wheat, one sheep, one ore)
|
boolean |
equals(java.lang.Object obj) |
int |
getArmyCount()
A little bit of a simple method but eh.
|
DevCardType |
getDevCard()
This gets a dev card which by default are shuffled when given.
|
void |
getDevCard(DevCardType type)
Gets a dev card of the specific type (taking it from the bank)
|
int |
getDevCardCount()
Gets the total number of dev cards held
|
int |
getDevCardCount(DevCardType type)
Gets the number of dev cards of a type held
|
int |
getNewDevCardCount(DevCardType type) |
int |
getNumberSolidersRecruited()
Returns the number of soliders you've played
|
void |
getPiece(PieceType type)
Attempts to get a piece (road, settlement, city).
|
int |
getPieceCount(PieceType type)
Gets the number of pieces available for a type held
|
void |
getResource(ResourceType type)
Attempts to get a resource from the bank
|
void |
getResource(ResourceType type,
int amount)
Gets a resource of the type requested at the amount requested
|
int |
getResourceCount()
Gets the current number of all held resources
|
int |
getResourceCount(ResourceType type)
returns the number of resources for a specified type
|
void |
giveDevCard(DevCardType type)
Gives the bank one dev card- it will be shuffled into pile
|
private void |
giveDevCard(DevCardType type,
int amount) |
void |
giveNewDevCard(DevCardType type) |
void |
givePiece(PieceType type)
Gives the bank one piece
|
void |
givePiece(PieceType type,
int amount) |
void |
giveResource(ResourceType type)
Give a single resource of type
|
void |
giveResource(ResourceType type,
int amount)
Gives the bank amount of type resource of type
|
void |
giveResourcesFor(PieceType piece)
Gives the bank the resources to buy this piece
|
void |
giveResourcesForDevCard()
Gives the bank the resources for a dev card
|
int |
hashCode() |
void |
newToOldDevs() |
void |
recruitSolider()
Adds one to the number of soliders you've played
|
void |
resetToBankDefaults() |
void |
resetToPlayerDefaults()
Resets the bank to the defaults of a player
|
java.lang.String |
resourcesToString() |
ResourceType |
takeRandomResource()
Gives a random resource from this player to the bank
|
java.lang.String |
toString() |
private static final long serialVersionUID
private int[] resources
private int[] devCards
private int[] pieces
private int numberResourceTypes
private int numberDevCardTypes
private int numberPieceTypes
private int solidersInPlay
private int[] newDevCards
public void resetToPlayerDefaults()
public void resetToBankDefaults()
public void getResource(ResourceType type) throws ModelException
type
- the type requestedif
- there don't have the resourceModelException
public void getResource(ResourceType type, int amount) throws ModelException
type
- amount
- ModelException
- if not enough of typepublic int getNumberSolidersRecruited()
public void recruitSolider()
public void getDevCard(DevCardType type) throws ModelException
type
- ModelException
public void getPiece(PieceType type) throws ModelException
type
- it can be anything but the robberif
- there don't have the resource or if type robberModelException
public DevCardType getDevCard() throws ModelException
if
- there don't have the resourceModelException
public void giveResource(ResourceType type) throws ModelException
type
- ModelException
public void giveResource(ResourceType type, int amount) throws ModelException
type
- the resource giventhe
- amount to giveModelException
public ResourceType takeRandomResource() throws ModelException
ModelException
public void givePiece(PieceType type) throws ModelException
type
- ModelException
- if type robber passed inpublic void givePiece(PieceType type, int amount) throws ModelException
type
- amount
- ModelException
- if type robber passed in or if try to give negative amountpublic void giveDevCard(DevCardType type)
type
- private void giveDevCard(DevCardType type, int amount)
type
- amount
- public int getResourceCount()
public int getResourceCount(ResourceType type)
type
- public int getPieceCount(PieceType type) throws ModelException
type
- ModelException
public int getDevCardCount(DevCardType type)
type
- public int getArmyCount()
public int getDevCardCount()
public boolean canBuildRoad()
public void buildRoad() throws ModelException
if
- they don't have the resourceModelException
public boolean canBuildSettlement()
public void buildSettlement() throws ModelException
if
- they don't have the resourceModelException
public boolean canBuildCity()
public boolean buildCity() throws ModelException
if
- they don't have the resourceModelException
public boolean canBuyDevCard()
public void buyDevCard() throws ModelException
if
- they don't have the resourceModelException
public int getNewDevCardCount(DevCardType type)
public void giveNewDevCard(DevCardType type)
public void newToOldDevs()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String resourcesToString()
public void giveResourcesFor(PieceType piece)
piece
- public void giveResourcesForDevCard()