Provide highscore fraction colors depending on latest war
parent
4cfa642228
commit
5d94be1c09
|
@ -26,6 +26,7 @@ campaignPlayer.route('/ranking/:campaignId')
|
|||
const warIds = wars.map((obj) => {
|
||||
return obj._id;
|
||||
});
|
||||
WarModel.findOne({campaign: req.params.campaignId}, {}, {sort: {'date': -1}}, (err, latestWar) => {
|
||||
PlayerModel.find({warId: {'$in': warIds}}, (err, items) => {
|
||||
if (err) return next(err);
|
||||
if (!items || items.length === 0) {
|
||||
|
@ -76,7 +77,13 @@ campaignPlayer.route('/ranking/:campaignId')
|
|||
}
|
||||
}
|
||||
resItem.warCount = playerInstances.length;
|
||||
resItem.fraction = playerInstances[playerInstances.length - 1].fraction;
|
||||
|
||||
const latestPlayerFraction = playerInstances[playerInstances.length - 1].fraction;
|
||||
resItem.fraction =
|
||||
(latestPlayerFraction === 'OPFOR') ?
|
||||
latestWar.fractionMappingOpfor :
|
||||
latestWar.fractionMappingBlufor;
|
||||
|
||||
rankingItems.push(resItem);
|
||||
});
|
||||
|
||||
|
@ -114,6 +121,7 @@ campaignPlayer.route('/ranking/:campaignId')
|
|||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
.all(
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef>{{'stats.highscore.header.name' | translate}}</th>
|
||||
<td mat-cell *matCellDef="let element"
|
||||
[style.color]="element['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
|
||||
[style.color]="fractionHelpers.getFractionColor(element['fraction'])">
|
||||
{{element.name}}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {Component, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {PlayerService} from '../../../services/logs/player.service';
|
||||
import {Fraction} from '../../../utils/fraction.enum';
|
||||
import {FormControl} from '@angular/forms';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Player} from '../../../models/model-interfaces';
|
||||
import {PlayerUtils} from '../../../utils/player-utils';
|
||||
import {FractionHelpers} from '../../../utils/global.helpers';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -25,7 +25,7 @@ export class StatisticHighScoreComponent implements OnInit {
|
|||
|
||||
playerAttributeDisplayNames = PlayerUtils.attributeDisplayNames.slice(2, PlayerUtils.attributeDisplayNames.length);
|
||||
|
||||
readonly fraction = Fraction;
|
||||
readonly fractionHelpers = FractionHelpers;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private playerService: PlayerService) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core';
|
||||
import {ChartUtils} from '../../../utils/chart-utils';
|
||||
import {Fraction} from '../../../utils/fraction.enum';
|
||||
import {War} from '../../../models/model-interfaces';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {FractionHelpers} from '../../../utils/global.helpers';
|
||||
|
@ -79,14 +78,14 @@ export class FractionStatsComponent implements OnInit, OnChanges {
|
|||
this.fractionNameOpfor = FractionHelpers.getFractionName(this.war, 'OPFOR');
|
||||
this.colorScheme = {
|
||||
domain: [
|
||||
FractionHelpers.getFractionColor(this.war, 'BLUFOR'),
|
||||
FractionHelpers.getFractionColor(this.war, 'OPFOR'),
|
||||
FractionHelpers.getFractionColor(this.war, 'BLUFOR', 'LIGHT'),
|
||||
FractionHelpers.getFractionColor(this.war, 'OPFOR', 'LIGHT'),
|
||||
FractionHelpers.getFractionColor(this.war, 'BLUFOR', 'DARK'),
|
||||
FractionHelpers.getFractionColor(this.war, 'OPFOR', 'DARK'),
|
||||
FractionHelpers.getFractionColor(this.war, 'BLUFOR', 'GREY'),
|
||||
FractionHelpers.getFractionColor(this.war, 'OPFOR', 'GREY'),
|
||||
FractionHelpers.getFractionColor('BLUFOR', this.war),
|
||||
FractionHelpers.getFractionColor('OPFOR', this.war),
|
||||
FractionHelpers.getFractionColor('BLUFOR', this.war, 'LIGHT'),
|
||||
FractionHelpers.getFractionColor('OPFOR', this.war, 'LIGHT'),
|
||||
FractionHelpers.getFractionColor('BLUFOR', this.war, 'DARK'),
|
||||
FractionHelpers.getFractionColor('OPFOR', this.war, 'DARK'),
|
||||
FractionHelpers.getFractionColor('BLUFOR', this.war, 'GREY'),
|
||||
FractionHelpers.getFractionColor('OPFOR', this.war, 'GREY'),
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<mat-header-cell *matHeaderCellDef
|
||||
mat-sort-header="{{tableHead[0].prop}}">{{tableHead[0].head | translate}}</mat-header-cell>
|
||||
<mat-cell *matCellDef="let element"
|
||||
[style.color]="fractionHelpers.getFractionColor(war, element['fraction'])">
|
||||
[style.color]="fractionHelpers.getFractionColor(element['fraction'],war)">
|
||||
{{element.name}}
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<div class="war-header-container">
|
||||
<div class="pull-left head-field">
|
||||
<h4>{{'stats.scoreboard.standings' | translate}}</h4>
|
||||
<span [style.color]="fractionHelpers.getFractionColor(war, 'BLUFOR')"
|
||||
<span [style.color]="fractionHelpers.getFractionColor('BLUFOR',war)"
|
||||
style="font-weight: bold; margin-right: 10px">
|
||||
{{fractionHelpers.getFractionName(war, 'BLUFOR')}} {{war.ptBlufor}}
|
||||
</span>
|
||||
<span style="font-size: x-large">|</span>
|
||||
<span [style.color]="fractionHelpers.getFractionColor(war, 'OPFOR')"
|
||||
<span [style.color]="fractionHelpers.getFractionColor('OPFOR',war)"
|
||||
style="font-weight: bold; margin-left: 10px;">
|
||||
{{war.ptOpfor}} {{fractionHelpers.getFractionName(war, 'OPFOR')}}
|
||||
</span>
|
||||
|
@ -15,12 +15,12 @@
|
|||
|
||||
<div class="pull-left head-field" style="margin-top:0" *ngIf="isSmallLayout">
|
||||
<h4>{{'stats.scoreboard.participants' | translate}}</h4>
|
||||
<span [style.color]="fractionHelpers.getFractionColor(war, 'BLUFOR')"
|
||||
<span [style.color]="fractionHelpers.getFractionColor('BLUFOR',war)"
|
||||
style="font-weight: bold; margin-right: 10px">
|
||||
{{fractionHelpers.getFractionName(war, 'BLUFOR')}} {{war.playersBlufor}}
|
||||
</span>
|
||||
<span style="font-size: 13px;font-weight: bold;">vs</span>
|
||||
<span [style.color]="fractionHelpers.getFractionColor(war, 'OPFOR')"
|
||||
<span [style.color]="fractionHelpers.getFractionColor('OPFOR',war)"
|
||||
style="font-weight: bold; margin-left: 10px;">
|
||||
{{war.playersOpfor}} {{fractionHelpers.getFractionName(war, 'OPFOR')}}
|
||||
</span>
|
||||
|
|
|
@ -67,8 +67,8 @@ export class WarHeaderComponent implements OnInit {
|
|||
|
||||
this.colorScheme = {
|
||||
domain: [
|
||||
FractionHelpers.getFractionColor(war, 'OPFOR'),
|
||||
FractionHelpers.getFractionColor(war, 'BLUFOR')
|
||||
FractionHelpers.getFractionColor('OPFOR', war),
|
||||
FractionHelpers.getFractionColor('BLUFOR', war)
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
@ -13,8 +13,15 @@ export const CSSHelpers = {
|
|||
};
|
||||
|
||||
export const FractionHelpers = {
|
||||
getFractionColor: (war: War, fraction, style?) => {
|
||||
switch (fraction === 'BLUFOR' ? war.fractionMappingBlufor : war.fractionMappingOpfor) {
|
||||
getFractionColor: (fraction, war?: War, style?) => {
|
||||
let switchInput;
|
||||
if (war) {
|
||||
switchInput = (fraction === 'BLUFOR' ? war.fractionMappingBlufor : war.fractionMappingOpfor);
|
||||
} else {
|
||||
switchInput = fraction;
|
||||
}
|
||||
|
||||
switch (switchInput) {
|
||||
case Fraction.ARF:
|
||||
switch (style) {
|
||||
case 'LIGHT':
|
||||
|
|
Loading…
Reference in New Issue