Created
June 14, 2012 10:42
-
-
Save lukecameron/2929540 to your computer and use it in GitHub Desktop.
Roma Acceptance Utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package acceptance; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class AcceptanceUtils { | |
| public static List<framework.cards.Card> reverseCards( | |
| List<framework.cards.Card> pile) { | |
| List<framework.cards.Card> reversed = new ArrayList<framework.cards.Card>(); | |
| for (framework.cards.Card c : pile) { | |
| reversed.add(0, c); | |
| } | |
| return reversed; | |
| } | |
| public static void printStateFromAcceptance( | |
| framework.interfaces.GameState gameState) { | |
| p("--------------------------------------------------------------------"); | |
| pf("\nState Summary: "); | |
| pf("Player %d's turn\n", gameState.getWhoseTurn()); | |
| pf("Dice:"); | |
| for (int d : gameState.getActionDice()) { | |
| pf(" %d", d); | |
| } | |
| p(""); | |
| p("\nVictory points:"); | |
| pf("\tPlayer 0:\t%d\n", gameState.getPlayerVictoryPoints(0)); | |
| pf("\tPlayer 1:\t%d\n", gameState.getPlayerVictoryPoints(1)); | |
| pf("\tPool:\t\t%d\n", gameState.getPoolVictoryPoints()); | |
| p("\nSestertii:"); | |
| pf("\tPlayer 0:\t%d\n", gameState.getPlayerSestertii(0)); | |
| pf("\tPlayer 1:\t%d\n", gameState.getPlayerSestertii(1)); | |
| p("\nHands"); | |
| p("Player 0:"); | |
| printCardList(new ArrayList(gameState.getPlayerHand(0))); | |
| p("\nPlayer 1:"); | |
| printCardList(new ArrayList(gameState.getPlayerHand(1))); | |
| p("\nFields:"); | |
| framework.cards.Card[] a = gameState.getPlayerCardsOnDiscs(0); | |
| pf("Player 0: <%s>,<%s>,<%s>,<%s>,<%s>,<%s>,<%s>\n", a[0], a[1], a[2], | |
| a[3], a[4], a[5], a[6]); | |
| a = gameState.getPlayerCardsOnDiscs(1); | |
| pf("Player 1: <%s>,<%s>,<%s>,<%s>,<%s>,<%s>,<%s>\n", a[0], a[1], a[2], | |
| a[3], a[4], a[5], a[6]); | |
| p("--------------------------------------------------------------------"); | |
| p(""); | |
| } | |
| public static void printPilesFromAcceptance( | |
| framework.interfaces.GameState gameState) { | |
| p("Deck\t\t\t\t\tDiscard pile:"); | |
| List<framework.cards.Card> deck = gameState.getDeck(); | |
| List<framework.cards.Card> discard = gameState.getDiscard(); | |
| int maxSize = deck.size(); | |
| if (maxSize < discard.size()) { | |
| maxSize = discard.size(); | |
| } | |
| for (int i = 0; i < maxSize; i++) { | |
| String card = ""; | |
| String dcard = ""; | |
| if (i < deck.size()) { | |
| card = deck.get(i).name(); | |
| } | |
| if (i < discard.size()) { | |
| dcard = discard.get(i).name(); | |
| } | |
| pf("%s\t\t\t\t\t%s\n", card, dcard); | |
| } | |
| } | |
| public static void printCardList(List<framework.cards.Card> l) { | |
| for (framework.cards.Card c : l) { | |
| System.out.println(c.name()); | |
| } | |
| } | |
| public static void printCardArray(framework.cards.Card[] l) { | |
| for (framework.cards.Card c : l) { | |
| System.out.println(c.name()); | |
| } | |
| } | |
| // I like to put these in tests when I'm tearing them apart. | |
| public static void p(String s) { | |
| System.out.println(s); | |
| } | |
| public static void pf(String format, Object... args) { | |
| System.out.printf(format, args); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment