Example #1
0
  @Test
  public void testBuildDeck() {
    Game g = new spGame();
    g.buildDeck();

    assertEquals(40, g.deck.size());
  }
Example #2
0
 @Test
 public void testGameInit() {
   Game g = new Game();
   g.buildDeck();
   g.shuffle();
   assertNotEquals(2, g.deck.get(0).getValue());
 }
 protected static Game getGameScheduled() {
   Game game = new Game();
   game.setDate(new DateTime(2013, 7, 4, 0, 0, 0));
   game.setStatus(Status.scheduled);
   game.setSeasonType(SeasonType.pre);
   return game;
 }
 protected static Game getGameCompleted() {
   Game game = new Game();
   game.setDate(new DateTime(2013, 7, 5, 0, 0, 0));
   game.setStatus(Status.completed);
   game.setSeasonType(SeasonType.pre);
   return game;
 }
Example #5
0
 @Test
 public void testSpRemoveFunction() {
   Game g = new spGame();
   g.buildDeck();
   g.customDeal(0, 3, 6, 9);
   g.remove(2);
   assertEquals(0, g.cols.get(2).size());
 }
Example #6
0
  @Before
  public void setup() {
    Fixtures.deleteAll();

    Fixtures.load("data.yml");

    duckRunnerGame = Game.find("byName", "Duck Runner").first();
    parkingLotGame = Game.find("byName", "Parking Lot").first();
  }
Example #7
0
 @Test
 public void testSpCustomDeal() {
   Game g = new spGame();
   g.buildDeck();
   g.customDeal(0, 3, 6, 9);
   assertEquals("1Clubs", g.cols.get(0).get(0).toString());
   assertEquals("2Clubs", g.cols.get(1).get(0).toString());
   assertEquals("3Clubs", g.cols.get(2).get(0).toString());
   assertEquals("4Clubs", g.cols.get(3).get(0).toString());
 }
Example #8
0
 @Test
 public void testSpGameStart() {
   Game g = new spGame();
   g.buildDeck();
   g.shuffle();
   g.dealFour();
   assertEquals(1, g.cols.get(0).size());
   assertEquals(1, g.cols.get(1).size());
   assertEquals(1, g.cols.get(2).size());
   assertEquals(1, g.cols.get(3).size());
 }
Example #9
0
 @Test
 public void testRemoveFunction() {
   Game g = new Game();
   g.buildDeck();
   g.customDeal(0, 3, 6, 9);
   g.remove(2);
   assertEquals(0, g.cols.get(2).size());
   // make sure that we did not remove from an empty column
   g.remove(2);
   assertEquals(0, g.cols.get(2).size());
 }
Example #10
0
  public static void storeresults() {
    if (ValidationUtils.verifyAuthenticity()) {
      checkAuthenticity();
    }

    final Map<String, String> map = params.allSimple();
    final Set<String> keys = new HashSet<String>();
    for (final Entry<String, String> entry : map.entrySet()) {
      String key = entry.getKey();
      if (StringUtils.isNotBlank(key)
          && key.contains("game_")
          && (key.contains("_homeScore") || key.contains("_awayScore"))) {
        key =
            key.replace("game_", "")
                .replace("_homeScore", "")
                .replace("_awayScore", "")
                .replace("_homeScore_et", "")
                .replace("_awayScore_et", "")
                .trim();
        keys.add(key);
      }
    }

    String gamekey = null;
    for (final String key : keys) {
      gamekey = key;
      final String homeScore = map.get("game_" + key + "_homeScore");
      final String awayScore = map.get("game_" + key + "_awayScore");
      final String extratime = map.get("extratime_" + key);
      final String homeScoreExtratime = map.get("game_" + key + "_homeScore_et");
      final String awayScoreExtratime = map.get("game_" + key + "_awayScore_et");
      AppUtils.setGameScore(
          key, homeScore, awayScore, extratime, homeScoreExtratime, awayScoreExtratime);
    }

    AppUtils.calculations();

    flash.put("infomessage", Messages.get("controller.games.tippsstored"));
    flash.keep();

    int playday = 1;
    if ((keys != null) && (keys.size() >= 1)) {
      if (StringUtils.isNotBlank(gamekey)) {
        gamekey = gamekey.replace("_et", "");
        final Game game = Game.findById(new Long(gamekey));
        if ((game != null) && (game.getPlayday() != null)) {
          playday = game.getPlayday().getNumber();
        }
      }
    }

    redirect("/admin/results/" + playday);
  }
Example #11
0
  @Test
  public void evenlyRandomlySelectsGame() {
    boolean duckRunnerGameFetched = false;
    boolean parkingLotGameFetched = false;

    // two games should be fetched by random chance

    for (int i = 0; i < 25; i++) {
      String aRandomGameName = Game.random().name;
      assertNotNull(aRandomGameName);

      if (aRandomGameName == duckRunnerGame.name) {
        duckRunnerGameFetched = true;
      } else if (aRandomGameName == parkingLotGame.name) {
        parkingLotGameFetched = true;
      } else {
        fail("should select existing games only...");
      }
    }

    if (!duckRunnerGameFetched) {
      fail("duck runner game should've been selected...");
    }

    if (!parkingLotGameFetched) {
      fail("parking lot game should've been selected...");
    }
  }
Example #12
0
  @Transactional(readOnly = true)
  public static void tournament() {
    List<Bracket> brackets = Bracket.findAll();
    List<Game> games = Game.findAll();

    render(brackets, games);
  }
Example #13
0
 @Test
 public void evenlyRandomlySelectGameButTheSelectedGame() {
   String selectedGameName = Game.randomBut(parkingLotGame.name).name;
   assertEquals("duck runner game should've been selected...", "Duck Runner", selectedGameName);
 }
Example #14
0
 @Test
 public void testGameBuildDeck() {
   Game g = new Game();
   g.buildDeck();
   assertEquals(52, g.deck.size());
 }