Skip to content

Commit

Permalink
feat: ✨ add new nations in afc and ofc
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Arnold committed Dec 29, 2022
1 parent 7718a10 commit 8498210
Show file tree
Hide file tree
Showing 6 changed files with 410 additions and 171 deletions.
3 changes: 3 additions & 0 deletions src/app/models/nation.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ export interface Nation {
thirdLeagues: string[];
rareLeagues: string[];
excludeLeagues: string[];
ranking: string;
abbreviation: string;
}

export interface GroupTeam {
name: string;
logo: string;
abbreviation: string;
region: string;
matchesPlayed: number;
points: number;
Expand Down
28 changes: 11 additions & 17 deletions src/app/pages/simulation/simulation.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class SimulationComponent {
nationsList: GroupTeam[] = [];
hostNation: GroupTeam = {
name: 'qatar',
abbreviation: 'qat',
logo: 'https://fmdataba.com/images/n/QAT.svg',
region: 'afc',
points: 0,
Expand Down Expand Up @@ -443,6 +444,7 @@ export class SimulationComponent {
name: nation.name,
logo: nation.logo,
region: nation.region,
abbreviation: nation.abbreviation,
matchHistory: {
qualifiers: [],
group: [],
Expand Down Expand Up @@ -583,9 +585,7 @@ export class SimulationComponent {
);
console.log(
`didn't qualify automatically from ${regions[i]}`,
region
.slice(qualifyingSpots[i])
.map((t) => `${t.name} ${t.ranking} - ${t.rating}`)
region.slice(qualifyingSpots[i]).map((t) => `${t.name}-${t.ranking}`)
);
teamsQualified.push(...region.slice(0, qualifyingSpots[i]));
});
Expand Down Expand Up @@ -628,9 +628,7 @@ export class SimulationComponent {
console.log(
`didn't qualify from ${regions[2]}`,
cafTeams.slice(10).map((t) => `${t.name} ${t.ranking} - ${t.rating}`),
cafQualifiers.map(
(t) => `${t.loser.name} ${t.loser.ranking} - ${t.loser.rating}`
)
cafQualifiers.map((t) => `${t.loser.name}-${t.loser.ranking}`)
);
// ===== UEFA Qualifiers =====
const uefaFirstRound = [
Expand Down Expand Up @@ -685,13 +683,9 @@ export class SimulationComponent {
);
console.log(
`didn't qualify from ${regions[0]}`,
uefaTeams.slice(22).map((t) => `${t.name} ${t.ranking} - ${t.rating}`),
uefaFirstRound.map(
(t) => `${t.loser.name} ${t.loser.ranking} - ${t.loser.rating}`
),
uefaQualifiers.map(
(t) => `${t.loser.name} ${t.loser.ranking} - ${t.loser.rating}`
)
uefaTeams.slice(22).map((t) => `${t.name}-${t.ranking}`),
uefaFirstRound.map((t) => `${t.loser.name}-${t.loser.ranking}`),
uefaQualifiers.map((t) => `${t.loser.name}-${t.loser.ranking}`)
);
// ===== Other Qualifiers =====
const afcQualifier = this.matchScore(afcTeams[4], afcTeams[5]);
Expand Down Expand Up @@ -734,6 +728,10 @@ export class SimulationComponent {
: ''
}`
);
console.log(
'teams in OFC',
ofcTeams.map((t) => `${t.name}-${t.ranking}`)
);
// ===== Inter-confederation Qualifiers =====
const playoff1 = this.matchScore(afcQualifier.winner, conmebolTeams[4]);
playoff1.winner.matchHistory.qualifiers.push({
Expand Down Expand Up @@ -830,10 +828,6 @@ export class SimulationComponent {
}

matchScore(team: GroupTeam, otherTeam: GroupTeam): Match {
console.log(
[team.name, team.ranking, team.tier, team.rating],
[otherTeam.name, otherTeam.ranking, otherTeam.tier, otherTeam.rating]
);
const [goalsFor, goalsAg] = calcScore(
team.attRating,
team.defRating,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ <h3>Match History</h3>
[src]="item.match.winner.logo"
[alt]="item.match.winner.name"
(click)="changeNation(item.match.winner)"
[ngClass]="item.match.winner === nation ? 'disabled' : ''"
[ngClass]="
item.match.winner.name === nation.name ? 'disabled' : ''
"
/>
<span class="team-name"
>{{ item.match.winner.name }}
Expand All @@ -67,7 +69,9 @@ <h3>Match History</h3>
[src]="item.match.loser.logo"
[alt]="item.match.loser.name"
(click)="changeNation(item.match.loser)"
[ngClass]="item.match.loser === nation ? 'disabled' : ''"
[ngClass]="
item.match.loser.name === nation.name ? 'disabled' : ''
"
/>
<span class="team-name">{{ item.match.loser.name }}</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ export class NationDialogComponent implements OnChanges {
}

changeNation(nation: GroupTeam) {
this.onNationChange.emit(nation);
const updatedNation = this.tournament?.groups
?.flat()
.find((a) => a.name === nation.name);
if (updatedNation) {
this.onNationChange.emit(updatedNation);
} else {
this.onNationChange.emit(nation);
}
}
}
2 changes: 0 additions & 2 deletions src/app/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ export function calcScore(
let result = '';
let randIndex = getRandomInt(0, 9);

console.log(gF, gA, gD);

if (gD > 40) {
result = getResultArr(8, 1, 1)[randIndex];
} else if (gD > 20) {
Expand Down
Loading

0 comments on commit 8498210

Please sign in to comment.