").appendTo($(t)).text("Pick"),e.forEach(function(e){var t=a.insertRow();$(t.insertCell()).text(e.team),$(t.insertCell()).text(e.record),$(t.insertCell()).text(e.odds),$(t.insertCell()).text("?")})}function toComboKey(e){return e[0]+"-"+e[1]+"-"+e[2]+"-"+e[3]}function l2d(e,t){var a={};return e.forEach(function(e){a[e]=t}),a}function makeBalls(){for(var e=[],t=1;t<15;t++)e.push(t);return e}function makeAllCombos(){for(var e=[],t=1;t<11;t++)for(var a=t+1;a<13;a++)for(var n=a+1;n<14;n++)for(var i=n+1;i<15;i++)e.push(t+"-"+a+"-"+n+"-"+i);return e}function removeOneRandom(e){var t=Math.floor(Math.random()*e.length),a=e[t];return e.splice(t,1),a}function assignAllCombos(e){var a=makeAllCombos(),n={};return e.forEach(function(e){for(var t=0;t div:nth-child("+(t+1)+") > p")).text(a),"slide",{direction:"up",mode:"show"},200)],e)}}}function liveDraw(t,a,n){return new function(){this.play=function(e){n.push(removeOneRandom(a)),animate([message("Drawing the "+["first","second","third","fourth"][t]+" ball..."),wait(750),showBall(t,n[n.length-1])],e)}}}function hideBalls(){return new function(){this.play=function(e){$("#balls p").hide(),e()}}}function evaluateCombo(n,i,o){return new function(){this.play=function(e){var t=o.slice();t.sort(function(e,t){return parseInt(e)-parseInt(t)});var a=toComboKey(t);"11-12-13-14"==a?(o.length=0,animate([message("This combination does not count. We must redraw."),wait(1500),hideBalls(),wait(500),liveDrawFour(n,i,o)],e)):null!=i[n[a]]?(o.length=0,animate([message("We redrew the "+n[a]+". We must redraw."),wait(1500),hideBalls(),wait(500),liveDrawFour(n,i,o)],e)):e()}}}function liveDrawFour(a,n,i){return new function(){this.play=function(e){var t=makeBalls();animate([liveDraw(i.length=0,t,i),wait(1e3),liveDraw(1,t,i),wait(1e3),liveDraw(2,t,i),wait(1e3),liveDraw(3,t,i),wait(250),evaluateCombo(a,n,i)],e)}}}function message(t){return new function(){this.play=function(e){console.log(t),$("#status").html(t),e()}}}function wait(t){return new function(){this.play=function(e){activeWaiter=setTimeout(e,speed*t)}}}function effect(t,a,n,i){return new function(){this.play=function(e){t.effect(a,n,speed*i,e)}}}function fadeTo(t,a,n){return new function(){this.play=function(e){t.fadeTo(speed*n,a,e)}}}function announcePick(n,i,o,r){return new function(){this.play=function(e){var t=toComboKey(i);i.sort(function(e,t){return parseInt(e)-parseInt(t)});var a=n[toComboKey(i)];setTeamPick(a,r[a]=o),animate([message("Looking up the team assigned "+t),wait(1e3),message("The "+a+" win the No. "+o+" pick!"),wait(2e3)],e)}}}function animate(e,t){stopped||(0!==e.length?e.shift().play(function(){animate(e,t)}):t&&t())}function awardPick(e,o,r){return new function(){this.play=function(e){var t=null,a=Object.keys(o).filter(function(e){return null==o[e]});if(1==a.length)t=a[0];else{var n=a[0],i=a[1];t=getTeamIndex(n)WNBA Draft Lottery Simulator!"),stopped=!0,buildPicksTable(e),a=l2d(e.map(function(e){return e.team}),null),n=[],$("#speed input").text(speed),$("#start").prop("disabled",!1),$("#speed, #reset").css("visibility","hidden")}),$("#slower").click(function(){1<(speed=1/speed)?speed-=.5:speed=Math.max(speed-.25,.25),$("#slower").prop("disabled",.25==speed),$("#faster").prop("disabled",3==speed),$("#speed input").val(speed),speed=1/speed}),$("#faster").click(function(){1<=(speed=1/speed)?speed=Math.min(speed+.5,3):speed+=.25,$("#slower").prop("disabled",.25==speed),$("#faster").prop("disabled",3==speed),$("#speed input").val(speed),speed=1/speed}),$("#start").click(function(){stopped=!1,$("#start").prop("disabled",!0),$("#speed, #reset").css("visibility","visible"),animate([message("Welcome to the 2021 WNBA Draft Lottery Simulator!"),wait(1500),message("Here are the odds for each team to get the No. 1 overall pick."),wait(500),fadeTo($("table"),1,250),wait(2500),message("Let's get started!"),wait(1500),message("We've already pre-assigned numeric combinations to each team in accordance with their odds."),wait(3e3),message("Now, let's draw for the No. 1 pick!"),wait(1500),liveDrawFour(t,a,n),wait(2e3),announcePick(t,n,1,a),wait(2e3),message("Next, we'll draw for the No. 2 pick!"),wait(1500),hideBalls(),liveDrawFour(t,a,n),wait(2e3),announcePick(t,n,2,a),wait(2e3),hideBalls(),message("The No. 3 pick is then awarded to the remaining team with the worse record."),wait(2e3),awardPick(e,a,3),wait(2e3),message("The remaining team will get the No. 4 pick."),wait(1500),awardPick(e,a,4),wait(1500),message("That concludes the 2021 WNBA Draft Lottery Simulation.")])})}WNBA Draft Lottery Simulator - Across the Timeline - Stats, facts, and memories from the storied history of women's basketball