Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

64 rindas
1.4 KiB

  1. package utils;
  2. import java.io.File;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import structures.basic.Card;
  6. /**
  7. * This is a utility class that provides methods for loading the decks for each
  8. * player, as the deck ordering is fixed.
  9. * @author Richard
  10. *
  11. */
  12. public class OrderedCardLoader {
  13. public static String cardsDIR = "conf/gameconfs/cards/";
  14. /**
  15. * Returns all of the cards in the human player's deck in order
  16. * @return
  17. */
  18. public static List<Card> getPlayer1Cards(int copies) {
  19. List<Card> cardsInDeck = new ArrayList<Card>(20);
  20. int cardID = 1;
  21. for (int i =0; i<copies; i++) {
  22. for (String filename : new File(cardsDIR).list()) {
  23. if (filename.startsWith("1_")) {
  24. // this is a deck 1 card
  25. cardsInDeck.add(BasicObjectBuilders.loadCard(cardsDIR+filename, cardID, Card.class));
  26. }
  27. }
  28. }
  29. return cardsInDeck;
  30. }
  31. /**
  32. * Returns all of the cards in the human player's deck in order
  33. * @return
  34. */
  35. public static List<Card> getPlayer2Cards(int copies) {
  36. List<Card> cardsInDeck = new ArrayList<Card>(20);
  37. int cardID = 1;
  38. for (int i =0; i<copies; i++) {
  39. for (String filename : new File(cardsDIR).list()) {
  40. if (filename.startsWith("2_")) {
  41. // this is a deck 2 card
  42. cardsInDeck.add(BasicObjectBuilders.loadCard(cardsDIR+filename, cardID, Card.class));
  43. }
  44. }
  45. }
  46. return cardsInDeck;
  47. }
  48. }