CT-33: Added alert for units needing to rank up #16
@ -76,6 +76,9 @@
|
||||
<div class="col-md-3" style="border: 1px solid black;">
|
||||
Unit {{rowIndex + 1}}:
|
||||
<a [routerLink]="['/unit-army', unit.id, 'edit']"> {{ unit.unitName }}</a>
|
||||
<div *ngIf="needsUpdate(unit)" style="color: red">
|
||||
<b>This unit has ranked up</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1" style="border: 1px solid black; background: whitesmoke; color: #0f0f0f">
|
||||
{{ unit.rank }}
|
||||
|
@ -9,6 +9,10 @@
|
||||
<div class="col-md-3-mobile">Force:</div>
|
||||
<div class="col-md-6-mobile">{{ getForcePoints() }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3-mobile">CP: </div>
|
||||
<div class="col-md-6-mobile">{{ getForceCP() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@ -62,6 +66,11 @@
|
||||
>BTN</button>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="needsUpdate(unit)">
|
||||
<div class="row" style="justify-content: center;">
|
||||
<div class="col-md-6-mobile-header" style="width: 75%; color: darkred"><b>This unit has ranked up</b></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="justify-content: center;">
|
||||
<div class="col-md-6-mobile-header" style="width: 75%;"><b>Battle Honours </b></div>
|
||||
</div>
|
||||
|
@ -17,6 +17,7 @@ export class ArmyDetailComponent implements OnInit {
|
||||
army: IArmy | null = null;
|
||||
units: IArmy['units'] | null = null;
|
||||
private forcePoints: number;
|
||||
private forceCrusadePoints: number;
|
||||
@LocalStorage('forceAddedListStored')
|
||||
public forceUnitList: ForceUnit[];
|
||||
private responsiveService: ResponsiveService = new ResponsiveService();
|
||||
@ -25,6 +26,7 @@ export class ArmyDetailComponent implements OnInit {
|
||||
constructor(protected dataUtils: JhiDataUtils,
|
||||
protected activatedRoute: ActivatedRoute) {
|
||||
this.forcePoints = 0;
|
||||
this.forceCrusadePoints = 0;
|
||||
const localStorageList = localStorage.getItem('forceAddedListStored');
|
||||
this.forceUnitList = localStorageList ? JSON.parse(localStorageList) : [];
|
||||
// localStorage.setItem('armyStored', JSON.stringify(this.army));
|
||||
@ -79,9 +81,11 @@ export class ArmyDetailComponent implements OnInit {
|
||||
addForceUnit(unit: UnitArmy): number {
|
||||
if (unit && unit.id && unit.unitPowerLevel && !this.forceAddedOrNot(unit.id)) {
|
||||
this.forcePoints = this.forcePoints + unit.unitPowerLevel;
|
||||
// if (this.army) {
|
||||
// unit.army = this.army;
|
||||
// }
|
||||
if (unit.crusadePointsUnit) {
|
||||
console.log(this.forceCrusadePoints + " " + unit.crusadePointsUnit)
|
||||
this.forceCrusadePoints = this.forceCrusadePoints + unit.crusadePointsUnit;
|
||||
console.log(this.forceCrusadePoints + " " + unit.crusadePointsUnit)
|
||||
}
|
||||
const fu = new ForceUnit(
|
||||
unit, 0, 0, 0, 0, 1, false, false
|
||||
)
|
||||
@ -96,9 +100,45 @@ export class ArmyDetailComponent implements OnInit {
|
||||
return this.forcePoints;
|
||||
}
|
||||
|
||||
getForceCP(): number {
|
||||
return this.forceCrusadePoints;
|
||||
}
|
||||
|
||||
needsUpdate(unit: UnitArmy): boolean {
|
||||
let _rank: string;
|
||||
if (unit && unit.experiencePoints && unit.rank) {
|
||||
if (unit.experiencePoints > 0 && unit.experiencePoints <= 5) {
|
||||
_rank = "Battle-Ready";
|
||||
}
|
||||
else if (unit.experiencePoints > 5 && unit.experiencePoints <= 15) {
|
||||
_rank = "Bloodied";
|
||||
}
|
||||
else if (unit.experiencePoints > 16 && unit.experiencePoints <= 30) {
|
||||
_rank = "Battle-Hardened";
|
||||
}
|
||||
else if (unit.experiencePoints > 30 && unit.experiencePoints <= 50) {
|
||||
_rank = "Heroic";
|
||||
}
|
||||
else if (unit.experiencePoints > 50) {
|
||||
_rank = "Legendary";
|
||||
}
|
||||
else {
|
||||
_rank = "Unknown";
|
||||
}
|
||||
|
||||
if (_rank !== unit.rank) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
removeForceUnit(unit: UnitArmy): number {
|
||||
if (unit && unit.id && unit.unitPowerLevel && this.forceAddedOrNot(unit.id)) {
|
||||
this.forcePoints = this.forcePoints - unit.unitPowerLevel;
|
||||
if (unit.crusadePointsUnit) {
|
||||
this.forceCrusadePoints = this.forceCrusadePoints - unit.crusadePointsUnit;
|
||||
}
|
||||
const index = this.getForceUnitIndex(unit);
|
||||
if (index !== null) {
|
||||
this.forceUnitList.splice(index, 1);
|
||||
@ -134,6 +174,7 @@ export class ArmyDetailComponent implements OnInit {
|
||||
clearForce(): void {
|
||||
this.forceUnitList = [];
|
||||
this.forcePoints = 0;
|
||||
this.forceCrusadePoints = 0;
|
||||
localStorage.setItem('forceAddedListStored', JSON.stringify(this.forceUnitList));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user