Quote:
Originally Posted by Shaomai888
Background image + ul > li ??
ya ended up using ul and li with flex grow. used this guys code as a template.
http://codepen.io/aronduby/pen/qliuj
it had to be dynamic so I had to go back and add a round field to every game. then I iterated over the rounds then iterated over the games of each round.
it looks pretty decent, even for 128 teams
http://i.imgur.com/t3E2RP6.png
I am still working on an algorithm to figure out how to create the games for an amount of teams that isnt a power of 2. was able to derive an algorithm to figure out which game number the winner of the previous game number plays but it only works for tourneys with 2,4,8,16,32,64,128 teams.
Code:
int gameTrack=(int) (game.getGameNumber()-(teams-teams/Math.pow(2,(game.getRoundNumber()-1))));
if(gameTrack%2==0){
int nextGame=(int) (teams-teams/Math.pow(2,game.getRoundNumber()))+gameTrack/2;
String sqlUpdateQuery = "UPDATE game SET competitor_2 = ? WHERE game_number = ? AND tournament_id = ?";
jdbcTemplate.update(sqlUpdateQuery, game.getWinnerCompetitorId(), nextGame, tournamentId);
}
else{
gameTrack++;
int nextGame=(int) (teams-teams/Math.pow(2,game.getRoundNumber()))+gameTrack/2;
String sqlUpdateQuery = "UPDATE game SET competitor_1 = ? WHERE game_number = ? AND tournament_id = ?";
jdbcTemplate.update(sqlUpdateQuery, game.getWinnerCompetitorId(), nextGame, tournamentId);
}
so gameNumber 1 is the first game of the tourney. gameNumber 33 is the first game of the 2nd round of a 64 team tourney. I thought about that for 2 days and figured I would just have to brute force a bunch of if-statements, but then it hit me while I was driving and I pulled over and wrote it down on a napkin so I wouldnt forget.
anyway, decent project, was a ton of work due to large amount of data that needed to be recorded. way more than I thought it would be. Still could be modified to use javascript so its more interactive and I may do that if I cant find employment soon.