Blame view
__public/js/dist/predictor.a71fadc8a724f2d98ffc.js
11.1 KB
e77200db5 Initial commit |
1 |
(window.webpackJsonp=window.webpackJsonp||[]).push([["a0b7"],{"1Lmz":function(e,t,r){"use strict";r.r(t);r("VHuo"),r("F2a/"),r("3iea");var o=r("8AMB"),n=r.n(o),a=r("7M+Q"),c=r.n(a),i=r("ijpo"),u=r.n(i);angular.module("footyroom").component("predictorMatch",{templateUrl:"/views/ng/predictor/predict/match.html?72",bindings:{match:"<"},controller:["$interval","predictService",function(e,t){var r,o=this;function a(){r=new n.a,o.match.bets.forEach(function(e){r.addStake(new c.a(e.homeScore||0,e.awayScore||0),e.stake)}),o.pool={1:S(r.getOutcomeStake(new c.a(1,0))/1e3),x:S(r.getOutcomeStake(new c.a(1,1))/1e3),2:S(r.getOutcomeStake(new c.a(0,1))/1e3),total:S(r.getTotalStake()/1e3)},o.match.prediction&&m()}function i(){o.projections={},o.projectionGroups={},s("1","Home Win"),s("x","Draw"),s("2","Away Win"),o.match.bets.forEach(function(e){if(e.stake>0){var t=new c.a(e.homeScore||0,e.awayScore||0);d(t.toString(),!0,t)}}),d("1-other",!1,new c.a(9999,1)),d("x-other",!1,new c.a(9999,9999)),d("2-other",!1,new c.a(1,9999)),d("1",!1,new c.a(1,0),new c.a(2,0)),d("x",!1,new c.a(0,0),new c.a(1,1)),d("2",!1,new c.a(0,1),new c.a(0,2))}function s(e,t){o.projectionGroups[e]=o.projectionGroups[e]||{key:e,title:t,projections:[]}}function d(e,t,n,a){o.projections[e]||(o.projections[e]={predictedScore:n,correctScore:a||n,stake:S(r.getScoreStake(n)/1e3)},t&&o.projectionGroups[n.outcome].projections.push(o.projections[e]),l(e))}function l(e){r.addStake(o.projections[e].predictedScore,o.raise),o.projections[e].win=u.a.calculate(o.projections[e].correctScore,o.projections[e].predictedScore,o.raise+(o.match.prediction?o.match.prediction.stake:0),r),r.addStake(o.projections[e].predictedScore,-o.raise)}function p(e){!o.saving&&o.predictionForm.$valid&&(m(),o.error=null,o.saving=!0,o.match.prediction.stake=o.match.prediction.stake||0,t.predict({matchId:o.match.matchId,homeScore:o.match.prediction.homeScore,awayScore:o.match.prediction.awayScore,stake:o.match.prediction.stake,raise:e?o.raise:0}).then(function(){e&&(o.match.bets.push({homeScore:o.match.prediction.homeScore,awayScore:o.match.prediction.awayScore,stake:o.raise}),o.match.prediction.stake+=o.raise,o.raise=0,a(),o.projections&&i(),o.betting=!1,o.betted=!0)}).catch(function(e){o.error=e.data.errors}).finally(function(){o.saving=!1}))}function h(){o.error=null;var e=o.raise;o.activeStake<=o.match.prediction.stake||isNaN(o.activeStake)?o.raise=0:o.raise=o.activeStake-o.match.prediction.stake,e!==o.raise&&(o.projections&&Object.keys(o.projections).forEach(l),m()),function(){o.overRaised=!1,t.getPlayer().then(function(e){o.raise>e.points&&(o.error="You do not have enough points",o.overRaised=!0)});var e=t.getGameState().MAX_STAKE_PER_ROUND;t.getGameState().rounds.selected.player.stake+o.raise>e&&(o.error="You are not allowed to stake over ".concat(e," per round"),o.overRaised=!0)}()}function m(){var e=new c.a(o.match.prediction.homeScore,o.match.prediction.awayScore),t=e;"finished"===o.match.statusType&&(t=new c.a(parseInt(o.match.homeScore,10),parseInt(o.match.awayScore,10))),r.addStake(e,o.raise),o.outcomeWin=u.a.calculateOutcomeReturn(t,e,o.raise+o.match.prediction.stake,r),o.scoreWin=u.a.calculateScoreReturn(t,e,o.raise+o.match.prediction.stake,r),o.refund=u.a.calculateRefund(t,e,o.raise+o.match.prediction.stake,r),r.addStake(e,-o.raise),o.toWin=o.scoreWin+o.outcomeWin+o.refund}function f(){o.timeLeft=new Date(o.match.datetime).getTime()-(new Date).getTime(),o.timeLeft=o.timeLeft>0?o.timeLeft:0}function S(e){var t=0;return t=0===e||e>=100?0:e>=10?1:2,e.toFixed(t)}o.predict=p,o.changeStake=function(e){o.raise+e<0?o.activeStake+=-o.raise:o.activeStake+=e;h(),o.betting=!0},o.onStakeInput=function(){o.activeStake=parseInt(o.activeStake,10),o.activeStake=isNaN(o.activeStake)?null:o.activeStake,h()},o.cancelBet=function(){o.activeStake=o.match.prediction.stake,h(),o.betting=!1},o.toggleTote=function(){o.isToteOpen=!o.isToteOpen,o.projections||i()},o.raise=0,o.activeStake=0,o.isBreakdownOpen=!1,o.isToteOpen=!1,o.changeScore=function(e){o.match.prediction=o.match.prediction||{},o.match.prediction.homeScore=e.homeScore,o.match.prediction.awayScore=e.awayScore,setTimeout(p,0)},o.viewAs=t.getViewAs(),o.overRaised=!1,function(){o.match.prediction&&(o.match.prediction.stake>0&&(o.betted=!0),o.activeStake=o.match.prediction.stake);a(),f(),e(f,6e4)}()}]});r("NjKu"),r("c1MJ");angular.module("footyroom").requires.push("ngRoute"),angular.module("footyroom").factory("leaderboardService",["$http",function(e){return{getLeaderboard:function(t){return e.get("/predictor/leaderboard.json",{params:{phase:t}}).then(function(e){return e.data})}}}]).factory("predictService",["$http",function(e){var t={};return{loadViewAs:function(e){return e?t.viewAs&&t.viewAs.userId===e?Promise.resolve():r(e).then(function(e){t.viewAs=e}):(t.viewAs=null,Promise.resolve())},getViewAs:function(){return t.viewAs},getPlayer:function(){return t.player?Promise.resolve(t.player):r().then(function(e){return t.player=e,e})},getMatches:function(t){return e.get("/predictor/matches.json",{params:{round:t}}).then(function(e){return e.data})},getRounds:function(r,o){return e.get("/predictor/rounds.json",{params:{round:r,userId:o}}).then(function(e){return t.game=e.data,t.game})},predict:function(r){return r.stake+=r.raise,e.post("/predictor/predict",r).then(function(){t.player.points-=r.raise,t.game.rounds.selected.player.stake+=r.raise})},getGameState:function(){return t.game}};function r(t){return e.get("/predictor/player.json",{params:{userId:t}}).then(function(e){return e.data})}}]).config(["$routeProvider","$locationProvider",function(e,t){var r={templateUrl:"/views/ng/predictor/predict/index.html?7",controller:"PredictController",selectedTab:"predict",resolve:{rounds:["predictService","$route",function(e,t){return e.getRounds(t.current.params.id,t.current.params.viewAs)}]}};e.when("/",r).when("/predictor",r).when("/predictor/round/:id",r).when("/predictor/leaderboard/:phase?",{templateUrl:"/views/ng/predictor/leaderboard/index.html?9",controller:"LeaderboardController",selectedTab:"leaderboard",resolve:{leaderboard:["leaderboardService","$route",function(e,t){return e.getLeaderboard(t.current.params.phase)}]}}).when("/predictor/help",{templateUrl:"/views/ng/predictor/help.html?1",selectedTab:"help"}).when("/predictor/prizes",{templateUrl:"/views/ng/predictor/prizes.html?8",selectedTab:"prizes"}),t.html5Mode({enabled:!0,requireBase:!1})}]).run(["$rootScope","$window",function(e,t){e.$on("$locationChangeStart",function(e,r,o){r.match(/\/predictor(\/.*)?/)||r===o||(e.preventDefault(),t.location.href=r)}),e.$on("$routeChangeStart",function(){e.predictorLoading=!0}),e.$on("$routeChangeSuccess",function(){e.predictorLoading=!1})}])},"3iea":function(e,t){angular.module("footyroom").controller("PredictorController",["$scope","$route","$sce","predictService","$location",function(e,t,r,o,n){e.$route=t,e.predictor=DataStore.predictor,e.predictor.prizeHtml=r.trustAsHtml(e.predictor.prizeHtml),e.loadPlayer=function(){o.getPlayer().then(function(t){e.player=t})},DataStore.isGuest||e.loadPlayer(),DataStore.isGuest&&(e.showSignUp=!0),e.$on("$routeChangeStart",function(t,r){r&&o.loadViewAs(parseInt(n.search().viewAs,10)).then(function(){e.viewAs=o.getViewAs()}).catch(function(){n.url("/predictor")})})}])},"7M+Q":function(e,t,r){function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var n=function(){function e(t,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!Number.isInteger(t)||!Number.isInteger(r))throw new Error("Scores must be numbers.");if(t<0||r<0)throw new Error("Scores must be positive.");this.homeScore=t,this.awayScore=r,this.homeScore>this.awayScore&&(this.outcome=e.HOME_WIN),this.awayScore>this.homeScore&&(this.outcome=e.AWAY_WIN),this.homeScore===this.awayScore&&(this.outcome=e.DRAW)}var t,r,n;return t=e,n=[{key:"HOME_WIN",get:function(){return"1"}},{key:"AWAY_WIN",get:function(){return"2"}},{key:"DRAW",get:function(){return"x"}}],(r=[{key:"toString",value:function(){return"".concat(this.homeScore,"-").concat(this.awayScore)}},{key:"equals",value:function(e){return this.homeScore===e.homeScore&&this.awayScore===e.awayScore}}])&&o(t.prototype,r),n&&o(t,n),e}();e.exports=n},"8AMB":function(e,t,r){function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var n=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.stakes={},this.totalStake=0,r.forEach(function(e){t.addStake(e.score,e.stake)})}var t,r,n;return t=e,(r=[{key:"addStake",value:function(e,t){this.stakes[e.toString()]=(this.stakes[e.toString()]||0)+t,this.stakes[e.outcome]=(this.stakes[e.outcome]||0)+t,this.totalStake+=t}},{key:"getOdds",value:function(e){return(this.getOutcomeOdds(e)+this.getScoreOdds(e))/2}},{key:"getOutcomeOdds",value:function(e){return(this.totalStake-(this.stakes[e.outcome]||0))/(this.stakes[e.outcome]||1)+1}},{key:"getScoreOdds",value:function(e){return(this.totalStake-(this.stakes[e.outcome]||0))/(this.stakes[e.toString()]||1)+1}},{key:"getScoreStake",value:function(e){return this.stakes[e.toString()]||0}},{key:"getOutcomeStake",value:function(e){return this.stakes[e.outcome]||0}},{key:"getTotalStake",value:function(){return this.totalStake}}])&&o(t.prototype,r),n&&o(t,n),e}();e.exports=n},"F2a/":function(e,t){angular.module("footyroom").controller("PredictController",["$scope","rounds",function(e,t){e.rounds=t.rounds,e.matches=t.matches}])},NjKu:function(e,t){angular.module("footyroom").component("roundSummary",{templateUrl:"/views/ng/predictor/predict/summary.html?7",bindings:{round:"<"},controller:["$route","predictService",function(e,t){this.viewAs=t.getViewAs(),this.refresh=function(){e.current.params.id===this.round.id&&e.reload()}}]})},VHuo:function(e,t){angular.module("footyroom").controller("LeaderboardController",["$scope","leaderboard","$location",function(e,t,r){e.sort="rank",e.leaderboard=t,e.changeLeaderboardPhase=function(e){r.path("/predictor/leaderboard"+(e?"/".concat(e):""))}}])},ijpo:function(e,t,r){function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,n;return t=e,n=[{key:"calculate",value:function(t,r,o,n){if(0===o)return 0;var a=e.calculateRefund(t,r,o,n);return a===o?a:e.calculateOutcomeReturn(t,r,o,n)+e.calculateScoreReturn(t,r,o,n)+a}},{key:"correctCount",value:function(e,t){return e.equals(t)?2:e.outcome===t.outcome?1:0}},{key:"calculateOutcomeReturn",value:function(e,t,r,o){return e.outcome===t.outcome?o.getOutcomeOdds(t)*r/2+r/2:0}},{key:"calculateScoreReturn",value:function(e,t,r,o){return e.equals(t)?o.getScoreOdds(t)*r/2-r/2:0}},{key:"calculateRefund",value:function(e,t,r,o){return e.outcome===t.outcome?0:0===o.getOutcomeStake(e)?r:o.getScoreStake(e)?0:r/2}}],(r=null)&&o(t.prototype,r),n&&o(t,n),e}();e.exports=n}},[["1Lmz","d41d","df9e"]]]); |