refactor: remove player list workaround
This commit is contained in:
@@ -6,6 +6,7 @@ import { Player } from './model';
|
|||||||
})
|
})
|
||||||
export class DataService {
|
export class DataService {
|
||||||
private players: Player[] = [];
|
private players: Player[] = [];
|
||||||
|
teams: Player[][] = [];
|
||||||
|
|
||||||
setPlayers(players: Player[]){
|
setPlayers(players: Player[]){
|
||||||
for (let player of players){
|
for (let player of players){
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class Player{
|
|||||||
return [this.name, values];
|
return [this.name, values];
|
||||||
}
|
}
|
||||||
|
|
||||||
valueOf(): string{
|
toString(): string{
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
static deSerialize(name: string, values: string): Player{
|
static deSerialize(name: string, values: string): Player{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@for (team of teamsArray; track $index) {
|
@for (team of data.teams; track $index) {
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
||||||
<td class="wrap-cell">{{ team }}</td>
|
<td class="wrap-cell">{{ team }}</td>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export class ScreenBasicComponent {
|
|||||||
numTeamsSelectorValue = "2";
|
numTeamsSelectorValue = "2";
|
||||||
numTeamsSelected = 2;
|
numTeamsSelected = 2;
|
||||||
nTeamsValue = "4";
|
nTeamsValue = "4";
|
||||||
teamsArray: string[][] = [];
|
|
||||||
|
|
||||||
onButtonGenerate(): void{
|
onButtonGenerate(): void{
|
||||||
if(this.numTeamsSelectorValue === 'n'){
|
if(this.numTeamsSelectorValue === 'n'){
|
||||||
@@ -40,10 +39,10 @@ export class ScreenBasicComponent {
|
|||||||
let n = localPlayers[index];
|
let n = localPlayers[index];
|
||||||
localPlayers.splice(index,1);
|
localPlayers.splice(index,1);
|
||||||
let team = iterator.next().value;
|
let team = iterator.next().value;
|
||||||
team.push(n.name);
|
team.push(n);
|
||||||
|
|
||||||
}
|
}
|
||||||
this.teamsArray = teams;
|
this.data.teams = teams;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user