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