Added force tracker
This commit is contained in:
parent
f954180b1d
commit
7b4c1d6f5e
2
Vagrantfile
vendored
2
Vagrantfile
vendored
@ -1,6 +1,6 @@
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.provider "docker" do |d|
|
||||
d.image = "mysql:8.0.20"
|
||||
d.image = "mysql:8.0.28"
|
||||
config.vm.synced_folder "~/mysql", "/var/lib/mysql", docker_consistancy: "delegated"
|
||||
d.privileged = "true"
|
||||
d.ports = ["3306:3306"]
|
||||
|
28106
package-lock.json
generated
28106
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -80,7 +80,7 @@ public class UnitArmy implements Serializable {
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@NotNull
|
||||
@JsonIgnoreProperties(value = "unitArmies", allowSetters = true)
|
||||
@JsonIgnoreProperties(value = "unitArmies", allowSetters = true, allowGetters = true)
|
||||
private Army army;
|
||||
|
||||
// jhipster-needle-entity-add-field - JHipster will add fields here
|
||||
@ -394,6 +394,7 @@ public class UnitArmy implements Serializable {
|
||||
", battleHonours='" + getBattleHonours() + "'" +
|
||||
", battleScars='" + getBattleScars() + "'" +
|
||||
", battlefieldRole='" + getBattlefieldRole() + "'" +
|
||||
// ", army='" + getArmy() + "'" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.warhammer.repository;
|
||||
|
||||
import com.warhammer.domain.UnitArmy;
|
||||
|
||||
import org.springframework.data.jpa.repository.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Spring Data repository for the UnitArmy entity.
|
||||
@ -15,4 +16,7 @@ import java.util.List;
|
||||
public interface UnitArmyRepository extends JpaRepository<UnitArmy, Long> {
|
||||
|
||||
List<UnitArmy> findByArmyId(Long id);
|
||||
|
||||
@Query("select unitArmy.army.id from UnitArmy unitArmy where unitArmy.id = ?1")
|
||||
Optional<Long> findArmyById(Long id);
|
||||
}
|
||||
|
@ -34,6 +34,13 @@ public interface UnitArmyService {
|
||||
*/
|
||||
Optional<UnitArmy> findOne(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id the id of the entity
|
||||
* @return the id of the army
|
||||
*/
|
||||
Optional<Long> findArmyById(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id the id of the army
|
||||
|
@ -1,15 +1,13 @@
|
||||
package com.warhammer.service.impl;
|
||||
|
||||
import com.warhammer.domain.Army;
|
||||
import com.warhammer.repository.ArmyRepository;
|
||||
import com.warhammer.service.UnitArmyService;
|
||||
import com.warhammer.domain.UnitArmy;
|
||||
import com.warhammer.repository.ArmyRepository;
|
||||
import com.warhammer.repository.UnitArmyRepository;
|
||||
import com.warhammer.service.UnitArmyService;
|
||||
import com.warhammer.service.dto.ArmyDTO;
|
||||
import com.warhammer.service.mapper.ArmyMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -58,6 +56,11 @@ public class UnitArmyServiceImpl implements UnitArmyService {
|
||||
return unitArmyRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Long> findArmyById(Long id) {
|
||||
return unitArmyRepository.findArmyById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<UnitArmy> findByUser(Optional ownerLoginOptional) {
|
||||
|
@ -103,6 +103,13 @@ public class UnitArmyResource {
|
||||
return ResponseUtil.wrapOrNotFound(unitArmy);
|
||||
}
|
||||
|
||||
@GetMapping("/unit-armies/get-army/{id}")
|
||||
public ResponseEntity<Long> getArmyId(@PathVariable Long id) {
|
||||
log.debug("REST request to get Army for UnitArmy : {}", id);
|
||||
Optional<Long> unitArmy = unitArmyService.findArmyById(id);
|
||||
return ResponseUtil.wrapOrNotFound(unitArmy);
|
||||
}
|
||||
|
||||
@GetMapping("/unit-armies/ranks")
|
||||
public ResponseEntity<UnitArmy> getRanks() {
|
||||
log.debug("REST request to get ranks");
|
||||
|
@ -7,6 +7,7 @@ import { IArmy } from 'app/shared/model/army.model';
|
||||
import {IUnitArmy, UnitArmy} from '../../shared/model/unit-army.model';
|
||||
import {DomSanitizer} from "@angular/platform-browser";
|
||||
import {ResponsiveService} from "../../responsive.service";
|
||||
import {ForceUnit} from "app/shared/model/force-unit.model";
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-army-detail',
|
||||
@ -17,7 +18,8 @@ export class ArmyDetailComponent implements OnInit {
|
||||
units: IArmy['units'] | null = null;
|
||||
private forcePoints: number;
|
||||
@LocalStorage('forceAddedListStored')
|
||||
public forceAddedList: number[];
|
||||
// @LocalStorage('ArmyStored')
|
||||
public forceUnitList: ForceUnit[];
|
||||
private responsiveService: ResponsiveService = new ResponsiveService();
|
||||
public isMobileResolution: boolean;
|
||||
|
||||
@ -25,8 +27,8 @@ export class ArmyDetailComponent implements OnInit {
|
||||
protected activatedRoute: ActivatedRoute) {
|
||||
this.forcePoints = 0;
|
||||
const localStorageList = localStorage.getItem('forceAddedListStored');
|
||||
this.forceAddedList = localStorageList ? JSON.parse(localStorageList) : [];
|
||||
// this.isMobileResolution = ResponsiveService.getMobileStatus();
|
||||
this.forceUnitList = localStorageList ? JSON.parse(localStorageList) : [];
|
||||
// localStorage.setItem('armyStored', JSON.stringify(this.army));
|
||||
this.isMobileResolution = this.responsiveService.getMobileStatus();
|
||||
}
|
||||
|
||||
@ -68,7 +70,7 @@ export class ArmyDetailComponent implements OnInit {
|
||||
}
|
||||
|
||||
toggleForceUnit(unit: UnitArmy): number {
|
||||
if ( unit?.id && unit?.unitPowerLevel && this.forceAddedList.includes(unit.id)) {
|
||||
if ( unit?.id && unit?.unitPowerLevel && this.forceAddedOrNot(unit.id)) {
|
||||
return this.removeForceUnit(unit);
|
||||
} else {
|
||||
return this.addForceUnit(unit)
|
||||
@ -76,11 +78,18 @@ export class ArmyDetailComponent implements OnInit {
|
||||
}
|
||||
|
||||
addForceUnit(unit: UnitArmy): number {
|
||||
if (unit && unit.id && unit.unitPowerLevel && !this.forceAddedList.includes(unit.id)) {
|
||||
if (unit && unit.id && unit.unitPowerLevel && !this.forceAddedOrNot(unit.id)) {
|
||||
this.forcePoints = this.forcePoints + unit.unitPowerLevel;
|
||||
this.forceAddedList.push(unit.id);
|
||||
// if (this.army) {
|
||||
// unit.army = this.army;
|
||||
// }
|
||||
const fu = new ForceUnit(
|
||||
unit, 0, 0, 0, 0, 1, false, false
|
||||
)
|
||||
console.log(fu)
|
||||
this.forceUnitList.push(fu);
|
||||
}
|
||||
localStorage.setItem('forceAddedListStored', JSON.stringify(this.forceAddedList));
|
||||
localStorage.setItem('forceAddedListStored', JSON.stringify(this.forceUnitList));
|
||||
return this.forcePoints;
|
||||
}
|
||||
|
||||
@ -89,12 +98,14 @@ export class ArmyDetailComponent implements OnInit {
|
||||
}
|
||||
|
||||
removeForceUnit(unit: UnitArmy): number {
|
||||
if (unit && unit.id && unit.unitPowerLevel && this.forceAddedList.includes(unit.id)) {
|
||||
if (unit && unit.id && unit.unitPowerLevel && this.forceAddedOrNot(unit.id)) {
|
||||
this.forcePoints = this.forcePoints - unit.unitPowerLevel;
|
||||
const index = this.forceAddedList.indexOf(unit.id);
|
||||
this.forceAddedList.splice(index, 1);
|
||||
const index = this.getForceUnitIndex(unit);
|
||||
if (index) {
|
||||
this.forceUnitList.splice(index, 1);
|
||||
}
|
||||
localStorage.setItem('forceAddedListStored', JSON.stringify(this.forceAddedList));
|
||||
}
|
||||
localStorage.setItem('forceAddedListStored', JSON.stringify(this.forceUnitList));
|
||||
return this.forcePoints;
|
||||
}
|
||||
|
||||
@ -102,16 +113,27 @@ export class ArmyDetailComponent implements OnInit {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
getForceUnitIndex(unit: UnitArmy): number | null {
|
||||
for (const fu of this.forceUnitList) {
|
||||
if (unit.id === fu.unit.id) {
|
||||
return this.forceUnitList.indexOf(fu)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
forceAddedOrNot(unitId: number): boolean {
|
||||
if (this.forceAddedList.includes(unitId)) {
|
||||
return true;
|
||||
for (const fu of this.forceUnitList) {
|
||||
if (fu.unit.id === unitId) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
clearForce(): void {
|
||||
localStorage.clear();
|
||||
this.forceAddedList = [];
|
||||
this.forceUnitList = [];
|
||||
this.forcePoints = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,189 +1,84 @@
|
||||
<div class="someMoreStuff" *ngFor="let unitLocal of units">
|
||||
<div class="unit-list" *ngFor="let unitLocal of forceList">
|
||||
<div class="unit">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
UNIT NAME:
|
||||
<div class="col-md-6-mobile" style="width: 100%; justify-content: center">{{ unitLocal.unit.unitName }}</div>
|
||||
<br>
|
||||
<div class="powers" *ngIf="unitLocal.unit.warlordTraits">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.warlordTraits }}</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span>{{ unitLocal.unitName }}</span>
|
||||
<div class="powers" *ngIf="unitLocal.unit.psychicPowersTaken">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.psychicPowersTaken }}</div>
|
||||
</div>
|
||||
<div class="powers" *ngIf="unitLocal.unit.relics">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.relics }}</div>
|
||||
</div>
|
||||
<div class="powers" *ngIf="unitLocal.unit.battleHonours">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.battleHonours }}</div>
|
||||
</div>
|
||||
<div class="powers" *ngIf="unitLocal.unit.battleScars">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.battleScars }}</div>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
Units Destroyed: {{unitLocal.unitsDestroyed}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'unitsDestroyed')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'unitsDestroyed')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
Agenda 1: {{unitLocal.agendaOneTally}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'agendaOneTally')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'agendaOneTally')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
Agenda 2: {{unitLocal.agendaTwoTally}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'agendaTwoTally')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'agendaTwoTally')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
Agenda 3: {{unitLocal.agendaThreeTally}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'agendaThreeTally')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'agendaThreeTally')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
EXP: {{unitLocal.experience}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'experience')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'experience')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">Is Dead:
|
||||
<input [(ngModel)]="unitLocal.isDead" type="checkbox" name="isDead" class="float-right">
|
||||
<label>{{unitLocal.isDead}}</label>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">Marked for Greatness:
|
||||
<input [(ngModel)]="unitLocal.isMarked" type="checkbox" name="isDead" class="float-right">
|
||||
<label>{{unitLocal.isMarked}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
BATTLEFIELD ROLE:
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{{unitLocal.battlefieldRole}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
CRUSADE FACTION:
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
more information
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
SELECTABLE KEYWORDS:
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
some more information
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="unit" padding-top="20px">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
UNIT TYPE:
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span>{{unitLocal.unitBookName}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
EQUIPMENT:
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span>{{ unitLocal.equipment }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
PSYCHIC POWERS:
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span>{{ unitLocal.psychicPowersTaken }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
WARLORD TRAITS:
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span>{{ unitLocal.warlordTraits }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
RELICS:
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span>{{ unitLocal.relics }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> Entries below should remain blank when the unit is first added to your Order of Battle. Fill these entries out as you play with the unit and when it has earned any Battle Honours or Battle Scars.</p>
|
||||
<div class="unit-header" align="center">
|
||||
COMBAT TALLIES
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<strong>BATTLES PLAYED:</strong>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<span>{{ unitLocal.battlesPlayed }}</span>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<strong>BATTLES SURVIVED:</strong>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<span>{{ unitLocal.battlesSurvived }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="unit">
|
||||
<div class="row">
|
||||
<div class="col-md-2" style="border: 1px solid black"></div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
<strong>...During this battle:</strong>
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
<strong>...In total:</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2" style="border: 1px solid black">
|
||||
Enemy units destroyed:
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
<!-- <input type="number" class="form-control" name="enemyUnitsDestroyed"-->
|
||||
<!-- formControlName="enemyUnitsDestroyed"/>-->
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
{{ unitLocal.enemyUnitsDestroyed }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2" style="border: 1px solid black">
|
||||
Enemy units destroyed with psychic powers:
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
<!-- <input type="number" class="form-control" name="enemyPsychicDestroyed"-->
|
||||
<!-- formControlName="enemyPsychicDestroyed"/>-->
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
{{ unitLocal.enemyPsychicDestroyed }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2" style="border: 1px solid black">
|
||||
Enemy units destroyed with ranged weapons:
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
<!-- <input type="number" class="form-control" name="enemyRangedDestroyed"-->
|
||||
<!-- formControlName="enemyRangedDestroyed"/>-->
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
{{ unitLocal.enemyRangedDestroyed }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2" style="border: 1px solid black">
|
||||
Enemy units destroyed with melee weapons:
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
<!-- <input type="number" class="form-control" name="enemyMeleeDestroyed"-->
|
||||
<!-- formControlName="enemyMeleeDestroyed"/>-->
|
||||
</div>
|
||||
<div class="col-md-4" style="border: 1px solid black">
|
||||
{{ unitLocal.enemyMeleeDestroyed }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="unit-header" align="center" >
|
||||
RANK
|
||||
</div>
|
||||
<div class="unit-information" align="center">
|
||||
<span style="color:#ff2b31; font-size: 150%">{{ unitLocal.rank }}</span>
|
||||
</div>
|
||||
<div class="row" style="border: 1px solid black" align="center">
|
||||
Unit background and other information
|
||||
</div>
|
||||
<div class="row" style="border: 1px solid black">
|
||||
<span>{{ unitLocal.unitDescription }}</span>
|
||||
</div>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<button type="submit"
|
||||
(click)="previousState()"
|
||||
class="btn btn-info">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span>Back</span>
|
||||
<fa-icon icon="arrow-left"></fa-icon>Back
|
||||
</button>
|
||||
<div class="row">
|
||||
|
||||
<button type="clear"
|
||||
(click)="clearList()"
|
||||
class="btn btn-danger">Clear</button>
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
(click)="battleWon = false; saveList()"
|
||||
class="btn btn-danger float-right">DEFEAT</button>
|
||||
|
||||
<button type="submit"
|
||||
(click)="battleWon = true; saveList()"
|
||||
class="btn btn-success float-right">VICTORY</button>
|
||||
</div>
|
||||
|
@ -3,13 +3,17 @@ import {ForceComponent} from "./force.component";
|
||||
import {JhiDataUtils} from "ng-jhipster";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {UnitArmyService} from "../unit-army/unit-army.service";
|
||||
import {ArmyService} from "../army/army.service";
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-force-desktop',
|
||||
templateUrl: './force-desktop.component.html'
|
||||
})
|
||||
export class ForceDesktopComponent extends ForceComponent {
|
||||
constructor(protected dataUtils: JhiDataUtils, protected activatedRoute: ActivatedRoute, protected unitArmyService: UnitArmyService) {
|
||||
super(dataUtils, activatedRoute, unitArmyService);
|
||||
constructor(protected dataUtils: JhiDataUtils,
|
||||
protected activatedRoute: ActivatedRoute,
|
||||
protected unitArmyService: UnitArmyService,
|
||||
protected armyService: ArmyService) {
|
||||
super(dataUtils, activatedRoute, unitArmyService, armyService);
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,65 @@
|
||||
<div class="unit-list" *ngFor="let unitLocal of units">
|
||||
<div class="unit-list" *ngFor="let unitLocal of forceList">
|
||||
<div class="unit">
|
||||
<div class="col-md-6-mobile" style="width: 100%; justify-content: center">{{ unitLocal.unitName }}</div>
|
||||
<div class="col-md-6-mobile" style="width: 100%; justify-content: center">{{ unitLocal.unit.unitName }}</div>
|
||||
<br>
|
||||
<div class="powers" *ngIf="unitLocal.warlordTraits"></div>
|
||||
<!-- todo do I want this?-->
|
||||
<div class="powers" *ngIf="unitLocal.psychicPowersTaken"></div>
|
||||
<!-- todo do I want this?-->
|
||||
<div class="powers" *ngIf="unitLocal.relics"></div>
|
||||
<!-- todo do I want this?-->
|
||||
<div class="powers" *ngIf="unitLocal.battleHonours"></div>
|
||||
<!-- todo do I want this?-->
|
||||
<div class="powers" *ngIf="unitLocal.battleScars"></div>
|
||||
<!-- todo do I want this?-->
|
||||
<div class="col-md-3-mobile" style="width: 50%">Units Destroyed</div>
|
||||
<div class="col-md-3-mobile" style="width: 50%">With Psychic</div>
|
||||
<div class="col-md-3-mobile" style="width: 50%">With Ranged</div>
|
||||
<div class="col-md-3-mobile" style="width: 50%">With Melee</div>
|
||||
<div class="col-md-3-mobile" style="width: 50%">Agenda 1</div>
|
||||
<div class="col-md-3-mobile" style="width: 50%">Agenda 2</div>
|
||||
<div class="col-md-3-mobile" style="width: 50%">Agenda 3</div>
|
||||
<div class="powers" *ngIf="unitLocal.unit.warlordTraits">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.warlordTraits }}</div>
|
||||
</div>
|
||||
<div class="powers" *ngIf="unitLocal.unit.psychicPowersTaken">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.psychicPowersTaken }}</div>
|
||||
</div>
|
||||
<div class="powers" *ngIf="unitLocal.unit.relics">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.relics }}</div>
|
||||
</div>
|
||||
<div class="powers" *ngIf="unitLocal.unit.battleHonours">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.battleHonours }}</div>
|
||||
</div>
|
||||
<div class="powers" *ngIf="unitLocal.unit.battleScars">
|
||||
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.battleScars }}</div>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
Units Destroyed: {{unitLocal.unitsDestroyed}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'unitsDestroyed')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'unitsDestroyed')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
Agenda 1: {{unitLocal.agendaOneTally}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'agendaOneTally')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'agendaOneTally')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
Agenda 2: {{unitLocal.agendaTwoTally}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'agendaTwoTally')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'agendaTwoTally')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
Agenda 3: {{unitLocal.agendaThreeTally}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'agendaThreeTally')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'agendaThreeTally')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||
EXP: {{unitLocal.experience}}
|
||||
<button style="text-align: right" type="#" (click)="adjustCounter(unitLocal, 1, 'experience')"
|
||||
class="btn btn-primary float-right">+</button>
|
||||
<button type="#" (click)="adjustCounter(unitLocal, -1, 'experience')"
|
||||
class="btn btn-primary float-right">-</button>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">Is Dead:
|
||||
<input [(ngModel)]="unitLocal.isDead" type="checkbox" name="isDead" class="float-right">
|
||||
<label>{{unitLocal.isDead}}</label>
|
||||
</div>
|
||||
<div class="col-md-6-mobile" style="width: 80%; height: 45px">Marked for Greatness:
|
||||
<input [(ngModel)]="unitLocal.isMarked" type="checkbox" name="isDead" class="float-right">
|
||||
<label>{{unitLocal.isMarked}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -26,11 +67,18 @@
|
||||
<button type="submit"
|
||||
(click)="previousState()"
|
||||
class="btn btn-info">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span>Back</span>
|
||||
<fa-icon icon="arrow-left"></fa-icon>Back
|
||||
</button>
|
||||
<div class="row">
|
||||
|
||||
<button type="clear"
|
||||
(click)="clearList()"
|
||||
class="btn btn-danger">Clear</button>
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
(click)="battleWon = false; saveList()"
|
||||
class="btn btn-danger float-right">DEFEAT</button>
|
||||
|
||||
<button type="submit"
|
||||
(click)="battleWon = true; saveList()"
|
||||
class="btn btn-success float-right">VICTORY</button>
|
||||
</div>
|
||||
|
@ -3,13 +3,17 @@ import {ForceComponent} from "./force.component";
|
||||
import {JhiDataUtils} from "ng-jhipster";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {UnitArmyService} from "../unit-army/unit-army.service";
|
||||
import {ArmyService} from "../army/army.service";
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-force-mobile',
|
||||
templateUrl: './force-mobile.component.html'
|
||||
})
|
||||
export class ForceMobileComponent extends ForceComponent {
|
||||
constructor(protected dataUtils: JhiDataUtils, protected activatedRoute: ActivatedRoute, protected unitArmyService: UnitArmyService) {
|
||||
super(dataUtils, activatedRoute, unitArmyService);
|
||||
constructor(protected dataUtils: JhiDataUtils,
|
||||
protected activatedRoute: ActivatedRoute,
|
||||
protected unitArmyService: UnitArmyService,
|
||||
protected armyService: ArmyService) {
|
||||
super(dataUtils, activatedRoute, unitArmyService, armyService);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
<div class="text-danger">
|
||||
<h1>RELOADING WILL RESET DATA</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="desktop-container" *ngIf="!isMobileResolution; else mobileContainer">
|
||||
<jhi-force-desktop></jhi-force-desktop>
|
||||
</div>
|
||||
|
@ -1,12 +1,14 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
import { JhiDataUtils } from 'ng-jhipster';
|
||||
import { LocalStorageService } from 'ngx-webstorage';
|
||||
import { IUnitArmy, UnitArmy } from '../../shared/model/unit-army.model';
|
||||
import { UnitArmy } from '../../shared/model/unit-army.model';
|
||||
import { Army } from '../../shared/model/army.model';
|
||||
import { ForceUnit } from '../../shared/model/force-unit.model';
|
||||
import { UnitArmyService } from '../unit-army/unit-army.service';
|
||||
import { ArmyService } from '../army/army.service';
|
||||
import {ResponsiveService} from "../../responsive.service";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'jhi-force',
|
||||
@ -14,43 +16,82 @@ import {ResponsiveService} from "../../responsive.service";
|
||||
styleUrls: ['./force.component.scss'],
|
||||
})
|
||||
export class ForceComponent implements OnInit {
|
||||
public forceList: number[];
|
||||
Iunits?: IUnitArmy[];
|
||||
units?: UnitArmy[] | null;
|
||||
public forceList: ForceUnit[];
|
||||
units: UnitArmy[] = [];
|
||||
army: Army | null = null;
|
||||
armyId = 0;
|
||||
public isMobileResolution: boolean;
|
||||
responsiveService: ResponsiveService = new ResponsiveService();
|
||||
localUnits: IUnitArmy[] | [];
|
||||
battleWon = false;
|
||||
|
||||
constructor(protected dataUtils: JhiDataUtils, protected activatedRoute: ActivatedRoute, protected unitArmyService: UnitArmyService) {
|
||||
constructor(protected dataUtils: JhiDataUtils,
|
||||
protected activatedRoute: ActivatedRoute,
|
||||
protected unitArmyService: UnitArmyService,
|
||||
protected armyService: ArmyService) {
|
||||
const localStorageList = localStorage.getItem('forceAddedListStored');
|
||||
this.forceList = localStorageList ? JSON.parse(localStorageList) : [];
|
||||
this.isMobileResolution = this.responsiveService.getMobileStatus();
|
||||
this.localUnits = [];
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadAll();
|
||||
this.getArmyId();
|
||||
}
|
||||
|
||||
loadAll(): void {
|
||||
for (let lookupUnitId of this.forceList) {
|
||||
// @ts-ignore
|
||||
this.unitArmyService.find(lookupUnitId).subscribe((res: HttpResponse<IUnitArmy>) => (this.localUnits?.push(res.body)));
|
||||
// this.unitArmyService.query(lookupUnitId).subscribe((res: HttpResponse<UnitArmy[]>) => (this.units = res.body));
|
||||
// console.log(this.units.))
|
||||
// console.log(lookupUnitId)
|
||||
// console.log(this.units)
|
||||
// this.unitArmyService.query(lookupUnitId).subscribe((res: HttpResponse<UnitArmy[]>) => (console.log(res.body)));
|
||||
//this.units is full list of units
|
||||
// @ts-ignore
|
||||
// for (const _unit of this.units) {
|
||||
// console.log(_unit.id)
|
||||
// console.log(lookupUnitId)
|
||||
// if (_unit.id === lookupUnitId) {
|
||||
// this.localUnits.push(_unit);
|
||||
// }
|
||||
// }
|
||||
lookupUnitId = 1;
|
||||
getArmyId(): void {
|
||||
if (this.forceList[0] && this.forceList[0].unit.id) {
|
||||
const armyIdOrNull: Observable<HttpResponse<number>> = this.unitArmyService.getArmy(this.forceList[0].unit.id);
|
||||
armyIdOrNull.toPromise().then(
|
||||
res => {
|
||||
Promise.resolve(res.body);
|
||||
this.armyId = res.body? res.body : 0;
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
getArmyIdPromise(): Promise<number | void> | null {
|
||||
if (this.forceList[0] && this.forceList[0].unit.id) {
|
||||
const armyIdOrNull: Observable<HttpResponse<number>> = this.unitArmyService.getArmy(this.forceList[0].unit.id);
|
||||
return armyIdOrNull.toPromise().then(
|
||||
res => {
|
||||
Promise.resolve(res.body);
|
||||
}
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getArmyPromise(): Promise<HttpResponse<Army>> {
|
||||
this.getArmyId();
|
||||
const armyObs: Observable<HttpResponse<Army>> = this.armyService.find(this.armyId);
|
||||
const armyPromise: Promise<HttpResponse<Army>> = armyObs.toPromise().then(
|
||||
res => {
|
||||
Promise.resolve(res.body);
|
||||
return res;
|
||||
}
|
||||
)
|
||||
return armyPromise;
|
||||
}
|
||||
|
||||
loadArmy(): void {
|
||||
this.getArmyId();
|
||||
const armyObs: Observable<HttpResponse<Army>> = this.armyService.find(this.armyId);
|
||||
armyObs.toPromise().then(
|
||||
res => {
|
||||
Promise.resolve(res.body);
|
||||
this.army = res.body;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
resetAll(): void {
|
||||
for (const fu of this.forceList) {
|
||||
fu.unitsDestroyed = 0;
|
||||
fu.agendaOneTally = 0;
|
||||
fu.agendaTwoTally = 0;
|
||||
fu.agendaThreeTally = 0;
|
||||
fu.experience = 1;
|
||||
fu.isDead = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,4 +111,113 @@ export class ForceComponent implements OnInit {
|
||||
previousState(): void {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
adjustCounter(u: ForceUnit, adjust: number, field: string): void {
|
||||
switch(field) {
|
||||
case "unitsDestroyed": {
|
||||
u.unitsDestroyed += adjust;
|
||||
break;
|
||||
}
|
||||
case "agendaOneTally": {
|
||||
u.agendaOneTally += adjust;
|
||||
break;
|
||||
}
|
||||
case "agendaTwoTally": {
|
||||
u.agendaTwoTally += adjust;
|
||||
break;
|
||||
}
|
||||
case "agendaThreeTally": {
|
||||
u.agendaThreeTally += adjust;
|
||||
break;
|
||||
}
|
||||
case "experience": {
|
||||
u.experience += adjust;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async saveList(): Promise<void> {
|
||||
const armyPromise: Promise<HttpResponse<Army>> = this.getArmyPromise();
|
||||
|
||||
await armyPromise.then(
|
||||
res => {
|
||||
Promise.resolve(res.body);
|
||||
this.army = res.body;
|
||||
return this.army;
|
||||
}
|
||||
)
|
||||
|
||||
for (const fu of this.forceList) {
|
||||
let newExperience: number
|
||||
let newUnitsDestroyed: number
|
||||
|
||||
if (this.army) {
|
||||
fu.unit.army = this.army;
|
||||
}
|
||||
|
||||
if (fu.unit.enemyUnitsDestroyed) {
|
||||
newUnitsDestroyed = fu.unitsDestroyed + fu.unit.enemyUnitsDestroyed;
|
||||
if (Math.floor(newUnitsDestroyed / 3) !== Math.floor(fu.unit.enemyUnitsDestroyed / 3)) {
|
||||
fu.experience += Math.floor(newUnitsDestroyed / 3) - Math.floor(fu.unit.enemyUnitsDestroyed / 3);
|
||||
}
|
||||
} else {
|
||||
newUnitsDestroyed = fu.unitsDestroyed;
|
||||
fu.experience += Math.floor(newUnitsDestroyed / 3);
|
||||
}
|
||||
|
||||
if (fu.unit.experiencePoints) {
|
||||
newExperience = fu.experience + fu.unit.experiencePoints;
|
||||
} else {
|
||||
newExperience = fu.experience;
|
||||
}
|
||||
|
||||
if (fu.isMarked) {
|
||||
newExperience += 3;
|
||||
}
|
||||
|
||||
if (fu.unit.battlesPlayed) {
|
||||
fu.unit.battlesPlayed++;
|
||||
} else {
|
||||
fu.unit.battlesPlayed = 1;
|
||||
}
|
||||
|
||||
if (!fu.isDead && fu.unit.battlesSurvived) {
|
||||
fu.unit.battlesSurvived++;
|
||||
} else if (!fu.isDead) {
|
||||
fu.unit.battlesSurvived = 1;
|
||||
}
|
||||
|
||||
fu.unit.enemyUnitsDestroyed = newUnitsDestroyed;
|
||||
fu.unit.experiencePoints = newExperience;
|
||||
this.unitArmyService.update(fu.unit).toPromise().then();
|
||||
}
|
||||
|
||||
if (this.army?.requisition) {
|
||||
this.army.requisition++;
|
||||
} else if (this.army) {
|
||||
this.army.requisition = 1;
|
||||
}
|
||||
|
||||
if (this.army?.battleTally) {
|
||||
this.army.battleTally++;
|
||||
} else if (this.army) {
|
||||
this.army.battleTally = 1;
|
||||
}
|
||||
|
||||
if (this.army?.battlesWon && this.battleWon) {
|
||||
this.army.battlesWon++;
|
||||
} else if (this.army && this.battleWon) {
|
||||
this.army.battlesWon = 1;
|
||||
}
|
||||
|
||||
if (this.army) {
|
||||
this.armyService.update(this.army).toPromise().then()
|
||||
}
|
||||
|
||||
this.resetAll();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import { ForceComponent } from './force.component';
|
||||
import { forceRoute } from './force.route';
|
||||
import {ForceDesktopComponent} from "./force-desktop.component";
|
||||
import {ForceMobileComponent} from "./force-mobile.component";
|
||||
import {UnitArmy} from "../../shared/model/unit-army.model";
|
||||
|
||||
@NgModule({
|
||||
imports: [CrusadetrackerSharedModule, RouterModule.forChild(forceRoute)],
|
||||
@ -14,4 +15,5 @@ import {ForceMobileComponent} from "./force-mobile.component";
|
||||
ForceMobileComponent
|
||||
]
|
||||
})
|
||||
|
||||
export class CrusadetrackerForceModule {}
|
||||
|
@ -113,6 +113,7 @@ export class UnitArmyUpdateComponent implements OnInit {
|
||||
this.isSaving = true;
|
||||
const unitArmy = this.createFromForm();
|
||||
if (unitArmy.id !== undefined) {
|
||||
console.log(unitArmy);
|
||||
this.subscribeToSaveResponse(this.unitArmyService.update(unitArmy));
|
||||
} else {
|
||||
this.subscribeToSaveResponse(this.unitArmyService.create(unitArmy));
|
||||
|
@ -35,4 +35,8 @@ export class UnitArmyService {
|
||||
delete(id: number): Observable<HttpResponse<{}>> {
|
||||
return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' });
|
||||
}
|
||||
|
||||
getArmy(id: number): Observable<HttpResponse<number>> {
|
||||
return this.http.get<number>(`${this.resourceUrl}/get-army/${id}`, { observe: 'response' });
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ export class ResponsiveService {
|
||||
|
||||
// tslint:disable-next-line:typedef
|
||||
public checkWidth() {
|
||||
console.log(window.innerWidth)
|
||||
// tslint:disable-next-line:prefer-const
|
||||
if (window.innerWidth <= 768) {
|
||||
this.isMobile = true;
|
||||
|
26
src/main/webapp/app/shared/model/force-unit.model.ts
Normal file
26
src/main/webapp/app/shared/model/force-unit.model.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import {UnitArmy} from "./unit-army.model";
|
||||
|
||||
|
||||
export interface IForceUnit {
|
||||
unit: UnitArmy;
|
||||
unitsDestroyed: number;
|
||||
agendaOneTally: number;
|
||||
agendaTwoTally: number;
|
||||
agendaThreeTally: number;
|
||||
experience: number;
|
||||
isDead: boolean;
|
||||
isMarked: boolean;
|
||||
}
|
||||
|
||||
export class ForceUnit implements IForceUnit {
|
||||
constructor(
|
||||
public unit: UnitArmy,
|
||||
public unitsDestroyed: number,
|
||||
public agendaOneTally: number,
|
||||
public agendaTwoTally: number,
|
||||
public agendaThreeTally: number,
|
||||
public experience: number,
|
||||
public isDead: boolean,
|
||||
public isMarked: boolean
|
||||
) {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user