So I'm creating a Fantasy Football draft helper, and it's a 12-team snake draft format, which proceeds 1 through 12 LTR, then 13 through 24 RTL, then 25 through 36 LTR
----->
<-----
------>
So, the person with the #1
overall position (Team A) also finds themselves in the #24
and #25
position.
The #12
position also has the #13
position, as the order "wraps around" a grid.
Here is what I have come up with to flag any team's overall orders dynamically, based on draft position, but I'm no math whiz, and it seems wonky to have a special case for position=1 that doesn't apply to any of the other cases. This works, but I want to know what the real math is for this, if anyone knows.
Here is a fiddle I created with some sample code, based on my current solution.
var TEAMS = 12;
var ROUNDS = 4;
var POS = 1;
var $overallOrder = $('#overallOrder');
var total = TEAMS * ROUNDS;
if (POS > TEAMS) { alert("only " + TEAMS + " teams"); return false; }
for (var i=1; i<=total; i++) {
var isMyTurn = false;
if ((i % (2*TEAMS)) == ((2*TEAMS) - (POS-1))) {
isMyTurn = true;
}
if ((i % (2*TEAMS)) == POS) {
isMyTurn = true;
}
//special case for first position ?
if (POS==1 && (i % (2*TEAMS)) == 0) {
isMyTurn = true;
}
var turnText = (isMyTurn) ? i + " My Turn!" : i ;
$overallOrder.append('<li>'+turnText+'</li>');
}
Try changing the POS var from 1-12 and you can see the results. Again, I'm looking for the mathematical function that would encapsulate the above logic, if anyone knows. Thanks!
http://jsfiddle.net/3oy1w71c/1/
Thanks!