Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
feat(tournaments): Added seed functions (Shuffle, descending-score, s…
Browse files Browse the repository at this point in the history
…tagger)

closes #47
  • Loading branch information
seiyria committed Oct 10, 2015
1 parent e16adb4 commit e5029ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/jade/partials/tournaments/not-started.jade
Expand Up @@ -39,9 +39,16 @@ script(type="text/ng-template", id="/tournaments/not-started")
.auto-vert-margin(style="width: 25px")
ng-md-icon.pointer(size="24", icon="delete", ng-show="player._isDeleteVisible", ng-click="removeFromBucket(player)")


md-card(flex, layout-align="start start")
md-list(layout="column")
md-subheader Options
md-subheader Seed Functions
md-list-item(layout="row")
md-button.md-accent.md-raised(flex, ng-click="sort.descending()") Descending Score
md-button.md-accent.md-raised(flex, ng-click="sort.shuffle()") Shuffle
md-button.md-accent.md-raised(flex, ng-click="sort.stagger()") Stagger

md-subheader Tournament Options

md-list-item
md-radio-group.margin-left-20(ng-model="tournamentOptions.type", layout="row")
Expand Down
16 changes: 16 additions & 0 deletions src/js/controllers/tournaments/notStartedCtrl.js
Expand Up @@ -38,6 +38,22 @@ site.controller('notStartedController', ($scope, EnsureLoggedIn, UserStatus, Sha
return true;
};

$scope.sort = {
descending: () => $scope.bucket = _.sortByOrder($scope.bucket, ['points', 'wins'], ['desc', 'desc']),
shuffle: () => $scope.bucket = _.shuffle($scope.bucket),
stagger: () => {
$scope.sort.descending();

const newOrder = [];
for(let i = $scope.bucket.length-1; i >= 0; i--) {
const item = $scope.bucket[i];
const func = i % 2 === 0 ? 'unshift' : 'push';
newOrder[func](item);
}
$scope.bucket = newOrder;
}
};

$scope.removeFromBucket = CurrentPlayerBucket.remove;

$scope.baseGroupSize = () => ~~Math.sqrt($scope.bucket.length);
Expand Down

0 comments on commit e5029ab

Please sign in to comment.