Compare commits
12 Commits
feat/prolo
...
feat/rotat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
563116331f | ||
|
|
1946c599be | ||
|
|
7c7762515b | ||
|
|
aaa0ab0638 | ||
|
|
4082932095 | ||
|
|
b6d34ce262 | ||
|
|
764ce43138 | ||
|
|
1bc97df0da | ||
|
|
5408a8d9b6 | ||
|
|
665cb25d34 | ||
|
|
3b8e5145c3 | ||
|
|
51414f5a99 |
19
package-lock.json
generated
19
package-lock.json
generated
@@ -27,7 +27,6 @@
|
||||
"express": "^4.18.2",
|
||||
"rxjs": "~7.8.0",
|
||||
"sonarqube-scanner": "^4.3.0",
|
||||
"swipl-wasm": "^7.0.5",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.15.0"
|
||||
},
|
||||
@@ -5316,12 +5315,6 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/emscripten": {
|
||||
"version": "1.41.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/emscripten/-/emscripten-1.41.5.tgz",
|
||||
"integrity": "sha512-cMQm7pxu6BxtHyqJ7mQZ2kXWV5SLmugybFdHCBbJ5eHzOo6VhBckEgAT3//rP5FwPHNPeEiq4SmQ5ucBwsOo4Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/eslint": {
|
||||
"version": "9.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz",
|
||||
@@ -13635,18 +13628,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/swipl-wasm": {
|
||||
"version": "7.0.5",
|
||||
"resolved": "https://registry.npmjs.org/swipl-wasm/-/swipl-wasm-7.0.5.tgz",
|
||||
"integrity": "sha512-3J6NYJq+G5xepS4zCTh15fdS9An0D/zqOLpF9l6y20nPEZcOagZ0v8Vt2IclPn4njFFL1LmgsBfHqjxZjkFYPA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"@types/emscripten": "^1.41.5"
|
||||
},
|
||||
"bin": {
|
||||
"swipl-generate": "dist/bin/index.js"
|
||||
}
|
||||
},
|
||||
"node_modules/symbol-observable": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz",
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
"express": "^4.18.2",
|
||||
"rxjs": "~7.8.0",
|
||||
"sonarqube-scanner": "^4.3.0",
|
||||
"swipl-wasm": "^7.0.5",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.15.0"
|
||||
},
|
||||
|
||||
@@ -2,15 +2,9 @@
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
<nav>
|
||||
<ul ngbNav [activeId]="activeId" class="nav-tabs custom-navbar bg-body-secondary">
|
||||
<li ngbNavItem="/" class="custom-navitem"><a ngbNavLink routerLink="" routerLinkActive="active">
|
||||
<i class="bi bi-pencil-square"></i>{{ data.getPlayers().length }}</a>
|
||||
</li>
|
||||
<li ngbNavItem="/basic.t" class="custom-navitem"><a ngbNavLink routerLink="/basic.t" routerLinkActive="active">
|
||||
<i class="bi bi-shuffle"></i></a>
|
||||
</li>
|
||||
<li ngbNavItem="/rotations.t" class="custom-navitem"><a ngbNavLink routerLink="/rotations.t" routerLinkActive="active">
|
||||
<i class="bi bi-arrow-repeat"></i></a>
|
||||
</li>
|
||||
<ul ngbNav [activeId]="route.fragment | async" class="nav-tabs custom-navbar bg-body-secondary">
|
||||
<li ngbNavItem="/edit" class="custom-navitem"><a ngbNavLink routerLink="/edit" routerLinkActive="active"><i class="bi bi-pencil-square"></i>{{ data.getPlayers().length }}</a></li>
|
||||
<li ngbNavItem="/basic" class="custom-navitem"><a ngbNavLink routerLink="/basic" routerLinkActive="active"><i class="bi bi-shuffle"></i></a></li>
|
||||
<li ngbNavItem="/rotations" class="custom-navitem"><a ngbNavLink routerLink="/rotations" routerLinkActive="active"><i class="bi bi-arrow-repeat"></i></a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -22,6 +22,7 @@ tr{
|
||||
overflow-y: auto;
|
||||
}
|
||||
.custom-navbar{
|
||||
height: 3rem;
|
||||
width: 100vw;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
@@ -33,3 +34,5 @@ tr{
|
||||
text-align: center; /* Center the content of each item */
|
||||
flex: 1;
|
||||
}
|
||||
.nav-link.active{
|
||||
}
|
||||
@@ -1,39 +1,31 @@
|
||||
import { Component, inject, OnInit} from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterOutlet, ActivatedRoute, RouterLink, Router, NavigationEnd } from '@angular/router';
|
||||
import { RouterOutlet, ActivatedRoute, RouterLink } from '@angular/router';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { filter, take } from 'rxjs';
|
||||
import { Player } from './util/model';
|
||||
import { ScreenBasicComponent } from "./screen-basic/screen-basic.component";
|
||||
import { ScreenRotationsComponent } from './screen-rotations/screen-rotations.component';
|
||||
import { Player } from './model';
|
||||
import { ScreenEditComponent } from './screen-edit/screen-edit.component';
|
||||
import { DataService } from './data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, RouterLink],
|
||||
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, ScreenBasicComponent, ScreenRotationsComponent, ScreenEditComponent, RouterLink],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.less'
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'vb';
|
||||
data = inject(DataService);
|
||||
activeId = '/';
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router
|
||||
){}
|
||||
constructor(public route: ActivatedRoute){}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.router.events
|
||||
.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe(() => {
|
||||
this.activeId = this.router.url;
|
||||
});
|
||||
// process query params
|
||||
this.route.queryParams.pipe(
|
||||
// Only proceed if params are not empty
|
||||
filter(params => Object.keys(params).length > 0),
|
||||
filter(params => Object.keys(params).length > 0), // Only proceed if params are not empty
|
||||
take(1)
|
||||
).subscribe(params => {
|
||||
if (params['names']){
|
||||
|
||||
@@ -2,18 +2,16 @@ import { Routes } from '@angular/router';
|
||||
import { ScreenBasicComponent } from './screen-basic/screen-basic.component';
|
||||
import { ScreenEditComponent } from './screen-edit/screen-edit.component';
|
||||
import { ScreenRotationsComponent } from './screen-rotations/screen-rotations.component';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
children: [
|
||||
{ path: '', component: ScreenEditComponent },
|
||||
/* IMPORTANT: all routes have to include a `.` (dot)
|
||||
this is a workaround used in `sw.js`
|
||||
to allow hosting services on the same subdomain as this PWA
|
||||
*/
|
||||
{ path: 'basic.t', component: ScreenBasicComponent },
|
||||
{ path: 'rotations.t', component: ScreenRotationsComponent }
|
||||
{ path: '', redirectTo: 'edit', pathMatch: 'full' },
|
||||
{ path: 'edit', component: ScreenEditComponent },
|
||||
{ path: 'basic', component: ScreenBasicComponent },
|
||||
{ path: 'rotations', component: ScreenRotationsComponent }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Player } from './util/model';
|
||||
import { Player } from './model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DataService {
|
||||
private players: Player[] = [];
|
||||
teams: Player[][] = [];
|
||||
|
||||
setPlayers(players: Player[]){
|
||||
for (let player of players){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Player} from '../util/model';
|
||||
import { Player} from '../model';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -21,17 +21,12 @@ export class Player{
|
||||
this.setter = setter;
|
||||
this.libero = libero;
|
||||
}
|
||||
getRoles(): string[] {
|
||||
const roles = [];
|
||||
if (this.outside){roles.push('OH')}
|
||||
if (this.middle){roles.push('M')}
|
||||
if (this.opposite){roles.push('OPP')}
|
||||
if (this.setter){roles.push('S')}
|
||||
if (this.libero){roles.push('L')}
|
||||
return roles;
|
||||
serialize(): string[] {
|
||||
const values = 'OOOO'
|
||||
return [this.name, values];
|
||||
}
|
||||
|
||||
toString(): string{
|
||||
valueOf(): string{
|
||||
return this.name;
|
||||
}
|
||||
static deSerialize(name: string, values: string): Player{
|
||||
@@ -30,7 +30,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (team of data.teams; track $index) {
|
||||
@for (team of teamsArray; track $index) {
|
||||
<tr>
|
||||
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
||||
<td class="wrap-cell">{{ team }}</td>
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Original Team Generation Screen for arbitrary size and number of teams
|
||||
import { Component, inject} from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterOutlet, ActivatedRoute } from '@angular/router';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Player } from '../util/model';
|
||||
import { assignPlayersRandomly, iter } from '../util/util';
|
||||
import { Player } from '../model';
|
||||
import { iter } from '../util';
|
||||
import { DataService } from '../data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-screen-basic',
|
||||
imports: [NgbModule, CommonModule, FormsModule],
|
||||
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule],
|
||||
templateUrl: './screen-basic.component.html',
|
||||
styleUrl: './screen-basic.component.less'
|
||||
})
|
||||
@@ -18,6 +19,7 @@ export class ScreenBasicComponent {
|
||||
numTeamsSelectorValue = "2";
|
||||
numTeamsSelected = 2;
|
||||
nTeamsValue = "4";
|
||||
teamsArray: string[][] = [];
|
||||
|
||||
onButtonGenerate(): void{
|
||||
if(this.numTeamsSelectorValue === 'n'){
|
||||
@@ -27,8 +29,21 @@ export class ScreenBasicComponent {
|
||||
this.numTeamsSelected = Number(this.numTeamsSelectorValue);
|
||||
}
|
||||
|
||||
let teams: Player[][]= Array.from({ length: this.numTeamsSelected }, () => []);
|
||||
this.data.teams = assignPlayersRandomly(this.data.getPlayers(),teams);
|
||||
let teams = Array.from({ length: this.numTeamsSelected }, () => []);
|
||||
// clone array here
|
||||
let localPlayers: Player[] = this.data.getPlayers();
|
||||
|
||||
let nameslen = localPlayers.length;
|
||||
let iterator = iter(teams);
|
||||
for(let i =0; i < nameslen; i++){
|
||||
let index = Math.floor(Math.random()* localPlayers.length);
|
||||
let n = localPlayers[index];
|
||||
localPlayers.splice(index,1);
|
||||
let team = iterator.next().value;
|
||||
team.push(n.name);
|
||||
|
||||
}
|
||||
this.teamsArray = teams;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,10 +19,7 @@
|
||||
<ul class="list-group mb-3">
|
||||
@for (player of data.getPlayers(); track $index) {
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div (click)="openPlayerModal(player)" class="player-content">
|
||||
<div class="text-start">{{ player.name }}</div>
|
||||
<div class="text-end">{{ player.getRoles() }}</div>
|
||||
</div>
|
||||
<a (click)="openPlayerModal(player)" style="display: block; cursor: pointer; flex-grow: 1; text-align: left;">{{ player.name }}</a>
|
||||
<button (click)="removeItem(player)" class="btn btn-secondary btn-sm p-0 ms-2" style="width: 24px; height: 24px" >
|
||||
<i class="bi bi-x"></i>
|
||||
</button>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
.player-content{
|
||||
cursor: pointer;
|
||||
flex-grow: 1;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, inject, Input, ViewChild } from '@angular/core';
|
||||
import { NgbAlert, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Player } from '../util/model';
|
||||
import { Player } from '../model';
|
||||
import { ModalRotationsComponent } from '../modal-rotations/modal-rotations.component';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { Subject } from 'rxjs/internal/Subject';
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
<div class="justify-content-md-center">
|
||||
<h1>Rotations</h1>
|
||||
<form>
|
||||
<button type="button" (click)="generateTeams()" class="btn btn-primary mb-3">Generate</button>
|
||||
</form>
|
||||
|
||||
<div ngbAccordion>
|
||||
<div ngbAccordionItem [collapsed]="false">
|
||||
<h2 ngbAccordionHeader>
|
||||
@@ -75,19 +71,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ngbAccordionItem>
|
||||
<h2 ngbAccordionHeader>
|
||||
<button ngbAccordionButton>No Role: {{ NoRolePlayers.length }}</button>
|
||||
</h2>
|
||||
<div ngbAccordionCollapse>
|
||||
<div ngbAccordionBody>
|
||||
<ng-template>
|
||||
@for (player of NoRolePlayers; track $index) {
|
||||
{{ player.name }}
|
||||
}
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,10 +1,9 @@
|
||||
// Team Generation Screen respecting volleyball roles as defined by `../model/Player`
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { Player } from '../util/model';
|
||||
import { Player } from '../model';
|
||||
import { NgbAccordionBody, NgbAccordionCollapse, NgbAccordionHeader, NgbAccordionItem, NgbAccordionButton, NgbAccordionDirective, NgbAccordionToggle } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { DataService } from '../data.service';
|
||||
import { solveRotations } from '../util/solver';
|
||||
|
||||
@Component({
|
||||
selector: 'app-screen-rotations',
|
||||
@@ -12,15 +11,9 @@ import { solveRotations } from '../util/solver';
|
||||
templateUrl: './screen-rotations.component.html',
|
||||
styleUrl: './screen-rotations.component.less'
|
||||
})
|
||||
export class ScreenRotationsComponent{
|
||||
export class ScreenRotationsComponent {
|
||||
data = inject(DataService);
|
||||
|
||||
async generateTeams(){
|
||||
const teamCount = Math.floor(this.data.getPlayers().length / 6);
|
||||
solveRotations();
|
||||
|
||||
}
|
||||
|
||||
get OutsidePlayers(): Player[] {
|
||||
return this.data.getPlayers().filter(player => player.outside);
|
||||
}
|
||||
@@ -36,9 +29,4 @@ export class ScreenRotationsComponent{
|
||||
get LiberoPlayers(): Player[] {
|
||||
return this.data.getPlayers().filter(player => player.libero);
|
||||
}
|
||||
get NoRolePlayers(): Player[] {
|
||||
return this.data.getPlayers().filter(
|
||||
player => !player.outside && !player.middle && !player.opposite && !player.setter && !player.libero
|
||||
);
|
||||
}
|
||||
}
|
||||
7
src/app/util.ts
Normal file
7
src/app/util.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function* iter(list: any[]){
|
||||
let index = 0;
|
||||
while(true){
|
||||
yield list[index % list.length];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
% https://de.wikipedia.org/wiki/Volleyball#Spielpositionen
|
||||
% we want 2 outside, 1 opp, 1 set and either 2*middle or middle + libero
|
||||
teams(0).
|
||||
number_of_teams(X,Result):- Result is floor(X/6).
|
||||
libero(tom).
|
||||
libero(anh).
|
||||
|
||||
:-style_check(-discontiguous).
|
||||
|
||||
players(_/X):- X=:=1.
|
||||
% introduce abbreviations used for s(etter), oh (outside hitter), opp(osite), l(ibero), m(iddle)
|
||||
s(_) :- member(1, [0]).
|
||||
oh(_) :- member(1, [0]).
|
||||
opp(_) :- member(1, [0]).
|
||||
l(_) :- member(1, [0]).
|
||||
m(_) :- member(1, [0]).
|
||||
|
||||
team(List):-
|
||||
findall(X, (member(X, List),s(X)),Setters),
|
||||
length(Setters,1),
|
||||
findall(X, (member(X, List),oh(X)),Outsides),
|
||||
length(Outsides,2),
|
||||
findall(X, (member(X, List),opp(X)),Opposites),
|
||||
length(Opposites,1),
|
||||
% require either 2 middles or 1+1 libero.
|
||||
(findall(X, (member(X, List),m(X)),Middles),
|
||||
length(Middles, 2)
|
||||
;
|
||||
(findall(X, (member(X, List),m(X)),Middles),
|
||||
length(Middles,1),
|
||||
findall(X, (member(X,List), l(X)),Liberos),
|
||||
length(Liberos,1)
|
||||
)
|
||||
).
|
||||
% TODO require all sets to be A∩B = ∅
|
||||
|
||||
|
||||
|
||||
s(s).
|
||||
oh(oh).
|
||||
oh(oh2).
|
||||
opp(opp).
|
||||
l(l).
|
||||
m(m).
|
||||
@@ -1,11 +0,0 @@
|
||||
import SWIPL from 'swipl-wasm';
|
||||
|
||||
export async function solveRotations(){
|
||||
const swipl = await SWIPL({ arguments: ["-q"] });
|
||||
const q = swipl.prolog.query("member(X, [a, b, c]).").once() as PrologResult;
|
||||
console.log(q.X);
|
||||
}
|
||||
|
||||
interface PrologResult {
|
||||
X: string;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { Player } from "./model";
|
||||
|
||||
export function* iter(list: any[]){
|
||||
let index = 0;
|
||||
while(true){
|
||||
yield list[index % list.length];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
export function assignPlayersRandomly(players: Player[], teams: Player[][]){
|
||||
let nameslen = players.length;
|
||||
let iterator = iter(teams);
|
||||
for(let i =0; i < nameslen; i++){
|
||||
let index = Math.floor(Math.random()* players.length);
|
||||
let n = players[index];
|
||||
players.splice(index,1);
|
||||
let team = iterator.next().value;
|
||||
team.push(n);
|
||||
}
|
||||
return teams;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ html, body {
|
||||
body {
|
||||
margin:3em auto;
|
||||
font-family: Roboto, "Helvetica Neue", sans-serif;
|
||||
padding:.5em auto;
|
||||
padding:0 .5em;
|
||||
}
|
||||
h1,h2,h3{
|
||||
line-height:1.2;
|
||||
|
||||
Reference in New Issue
Block a user