Skip to content

Commit 3733950

Browse files
committed
style(dashboard): update ongeki rating show
1 parent 9ddcee0 commit 3733950

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/app/dashboard/dashboard.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,12 @@ <h3 class="m-0">
181181
</tr>
182182
<tr>
183183
<th>{{'DashboardPage.Rating' | translate}}</th>
184-
<td>{{ongekiProfile.playerRating / 100 | number: '1.2-2'}}</td>
184+
<ng-template [ngIf]="compareVersion(ongekiProfile.lastRomVersion, '1.50.00', '>=')">
185+
<td>{{ongekiProfile.newPlayerRating / 1000 | number: '0.2-2'}}</td>
186+
</ng-template>
187+
<ng-template [ngIf]="compareVersion(ongekiProfile.lastRomVersion, '1.50.00', '<')">
188+
<td>{{ongekiProfile.playerRating / 100 | number: '1.2-2'}}</td>
189+
</ng-template>
185190
</tr>
186191
<tr>
187192
<th>{{'DashboardPage.BattlePoint' | translate}}</th>

src/app/dashboard/dashboard.component.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {LanguageService} from '../language.service';
1414
import {HttpParams} from '@angular/common/http';
1515
import {TranslateService} from '@ngx-translate/core';
1616
import {Luid} from '../cards/cards.component';
17+
import {compareVersions} from 'compare-versions';
1718

1819
@Component({
1920
selector: 'app-dashboard',
@@ -237,5 +238,23 @@ export class DashboardComponent implements OnInit {
237238
getFormattedNumberByDigit(input: string, digit: number): string {
238239
return input.toString().padStart(digit, '0');
239240
}
241+
242+
compareVersion(version: string, target: string, operator: '>=' | '<') {
243+
const a = version.split('.').map(Number);
244+
const b = target.split('.').map(Number);
245+
const len = Math.max(a.length, b.length);
246+
247+
for (let i = 0; i < len; i++) {
248+
const n1 = a[i] || 0;
249+
const n2 = b[i] || 0;
250+
251+
if (n1 > n2) { return operator === '>='; }
252+
if (n1 < n2) { return operator === '<'; }
253+
}
254+
return operator === '>=';
255+
}
256+
257+
258+
protected readonly compareVersions = compareVersions;
240259
}
241260

0 commit comments

Comments
 (0)