Merge pull request 'Added force tracker' (#10) from feature/battle-ready-mobile into master
Reviewed-on: mitch/crusade-tracker#10
This commit is contained in:
commit
e98f62aa55
2
Vagrantfile
vendored
2
Vagrantfile
vendored
@ -1,6 +1,6 @@
|
|||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.provider "docker" do |d|
|
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"
|
config.vm.synced_folder "~/mysql", "/var/lib/mysql", docker_consistancy: "delegated"
|
||||||
d.privileged = "true"
|
d.privileged = "true"
|
||||||
d.ports = ["3306:3306"]
|
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)
|
@ManyToOne(optional = false)
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonIgnoreProperties(value = "unitArmies", allowSetters = true)
|
@JsonIgnoreProperties(value = "unitArmies", allowSetters = true, allowGetters = true)
|
||||||
private Army army;
|
private Army army;
|
||||||
|
|
||||||
// jhipster-needle-entity-add-field - JHipster will add fields here
|
// jhipster-needle-entity-add-field - JHipster will add fields here
|
||||||
@ -394,6 +394,7 @@ public class UnitArmy implements Serializable {
|
|||||||
", battleHonours='" + getBattleHonours() + "'" +
|
", battleHonours='" + getBattleHonours() + "'" +
|
||||||
", battleScars='" + getBattleScars() + "'" +
|
", battleScars='" + getBattleScars() + "'" +
|
||||||
", battlefieldRole='" + getBattlefieldRole() + "'" +
|
", battlefieldRole='" + getBattlefieldRole() + "'" +
|
||||||
|
// ", army='" + getArmy() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package com.warhammer.repository;
|
package com.warhammer.repository;
|
||||||
|
|
||||||
import com.warhammer.domain.UnitArmy;
|
import com.warhammer.domain.UnitArmy;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.*;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Data repository for the UnitArmy entity.
|
* Spring Data repository for the UnitArmy entity.
|
||||||
@ -15,4 +16,7 @@ import java.util.List;
|
|||||||
public interface UnitArmyRepository extends JpaRepository<UnitArmy, Long> {
|
public interface UnitArmyRepository extends JpaRepository<UnitArmy, Long> {
|
||||||
|
|
||||||
List<UnitArmy> findByArmyId(Long id);
|
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);
|
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
|
* @param id the id of the army
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package com.warhammer.service.impl;
|
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.domain.UnitArmy;
|
||||||
|
import com.warhammer.repository.ArmyRepository;
|
||||||
import com.warhammer.repository.UnitArmyRepository;
|
import com.warhammer.repository.UnitArmyRepository;
|
||||||
|
import com.warhammer.service.UnitArmyService;
|
||||||
import com.warhammer.service.dto.ArmyDTO;
|
import com.warhammer.service.dto.ArmyDTO;
|
||||||
import com.warhammer.service.mapper.ArmyMapper;
|
import com.warhammer.service.mapper.ArmyMapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -58,6 +56,11 @@ public class UnitArmyServiceImpl implements UnitArmyService {
|
|||||||
return unitArmyRepository.findById(id);
|
return unitArmyRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Long> findArmyById(Long id) {
|
||||||
|
return unitArmyRepository.findArmyById(id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<UnitArmy> findByUser(Optional ownerLoginOptional) {
|
public List<UnitArmy> findByUser(Optional ownerLoginOptional) {
|
||||||
|
@ -103,6 +103,13 @@ public class UnitArmyResource {
|
|||||||
return ResponseUtil.wrapOrNotFound(unitArmy);
|
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")
|
@GetMapping("/unit-armies/ranks")
|
||||||
public ResponseEntity<UnitArmy> getRanks() {
|
public ResponseEntity<UnitArmy> getRanks() {
|
||||||
log.debug("REST request to get ranks");
|
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 {IUnitArmy, UnitArmy} from '../../shared/model/unit-army.model';
|
||||||
import {DomSanitizer} from "@angular/platform-browser";
|
import {DomSanitizer} from "@angular/platform-browser";
|
||||||
import {ResponsiveService} from "../../responsive.service";
|
import {ResponsiveService} from "../../responsive.service";
|
||||||
|
import {ForceUnit} from "app/shared/model/force-unit.model";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'jhi-army-detail',
|
selector: 'jhi-army-detail',
|
||||||
@ -17,7 +18,8 @@ export class ArmyDetailComponent implements OnInit {
|
|||||||
units: IArmy['units'] | null = null;
|
units: IArmy['units'] | null = null;
|
||||||
private forcePoints: number;
|
private forcePoints: number;
|
||||||
@LocalStorage('forceAddedListStored')
|
@LocalStorage('forceAddedListStored')
|
||||||
public forceAddedList: number[];
|
// @LocalStorage('ArmyStored')
|
||||||
|
public forceUnitList: ForceUnit[];
|
||||||
private responsiveService: ResponsiveService = new ResponsiveService();
|
private responsiveService: ResponsiveService = new ResponsiveService();
|
||||||
public isMobileResolution: boolean;
|
public isMobileResolution: boolean;
|
||||||
|
|
||||||
@ -25,8 +27,8 @@ export class ArmyDetailComponent implements OnInit {
|
|||||||
protected activatedRoute: ActivatedRoute) {
|
protected activatedRoute: ActivatedRoute) {
|
||||||
this.forcePoints = 0;
|
this.forcePoints = 0;
|
||||||
const localStorageList = localStorage.getItem('forceAddedListStored');
|
const localStorageList = localStorage.getItem('forceAddedListStored');
|
||||||
this.forceAddedList = localStorageList ? JSON.parse(localStorageList) : [];
|
this.forceUnitList = localStorageList ? JSON.parse(localStorageList) : [];
|
||||||
// this.isMobileResolution = ResponsiveService.getMobileStatus();
|
// localStorage.setItem('armyStored', JSON.stringify(this.army));
|
||||||
this.isMobileResolution = this.responsiveService.getMobileStatus();
|
this.isMobileResolution = this.responsiveService.getMobileStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +70,7 @@ export class ArmyDetailComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleForceUnit(unit: UnitArmy): number {
|
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);
|
return this.removeForceUnit(unit);
|
||||||
} else {
|
} else {
|
||||||
return this.addForceUnit(unit)
|
return this.addForceUnit(unit)
|
||||||
@ -76,11 +78,18 @@ export class ArmyDetailComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addForceUnit(unit: UnitArmy): number {
|
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.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;
|
return this.forcePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,12 +98,14 @@ export class ArmyDetailComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeForceUnit(unit: UnitArmy): number {
|
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;
|
this.forcePoints = this.forcePoints - unit.unitPowerLevel;
|
||||||
const index = this.forceAddedList.indexOf(unit.id);
|
const index = this.getForceUnitIndex(unit);
|
||||||
this.forceAddedList.splice(index, 1);
|
if (index) {
|
||||||
|
this.forceUnitList.splice(index, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
localStorage.setItem('forceAddedListStored', JSON.stringify(this.forceAddedList));
|
localStorage.setItem('forceAddedListStored', JSON.stringify(this.forceUnitList));
|
||||||
return this.forcePoints;
|
return this.forcePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,16 +113,27 @@ export class ArmyDetailComponent implements OnInit {
|
|||||||
window.history.back();
|
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 {
|
forceAddedOrNot(unitId: number): boolean {
|
||||||
if (this.forceAddedList.includes(unitId)) {
|
for (const fu of this.forceUnitList) {
|
||||||
return true;
|
if (fu.unit.id === unitId) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearForce(): void {
|
clearForce(): void {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
this.forceAddedList = [];
|
this.forceUnitList = [];
|
||||||
this.forcePoints = 0;
|
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="unit">
|
||||||
<div class="row">
|
<div class="col-md-6-mobile" style="width: 100%; justify-content: center">{{ unitLocal.unit.unitName }}</div>
|
||||||
<div class="col-md-3">
|
<br>
|
||||||
UNIT NAME:
|
<div class="powers" *ngIf="unitLocal.unit.warlordTraits">
|
||||||
</div>
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.warlordTraits }}</div>
|
||||||
<div class="col-md-6">
|
|
||||||
<span>{{ unitLocal.unitName }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="powers" *ngIf="unitLocal.unit.psychicPowersTaken">
|
||||||
<div class="col-md-3">
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.psychicPowersTaken }}</div>
|
||||||
BATTLEFIELD ROLE:
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
{{unitLocal.battlefieldRole}}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="powers" *ngIf="unitLocal.unit.relics">
|
||||||
<div class="col-md-3">
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.relics }}</div>
|
||||||
CRUSADE FACTION:
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
more information
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="powers" *ngIf="unitLocal.unit.battleHonours">
|
||||||
<div class="col-md-3">
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.battleHonours }}</div>
|
||||||
SELECTABLE KEYWORDS:
|
</div>
|
||||||
</div>
|
<div class="powers" *ngIf="unitLocal.unit.battleScars">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.battleScars }}</div>
|
||||||
some more information
|
</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>
|
</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>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
(click)="previousState()"
|
(click)="previousState()"
|
||||||
class="btn btn-info">
|
class="btn btn-info">
|
||||||
<fa-icon icon="arrow-left"></fa-icon> <span>Back</span>
|
<fa-icon icon="arrow-left"></fa-icon>Back
|
||||||
</button>
|
</button>
|
||||||
<div class="row">
|
|
||||||
<button type="clear"
|
<button type="clear"
|
||||||
(click)="clearList()"
|
(click)="clearList()"
|
||||||
class="btn btn-danger">Clear</button>
|
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>
|
</div>
|
||||||
|
@ -3,13 +3,17 @@ import {ForceComponent} from "./force.component";
|
|||||||
import {JhiDataUtils} from "ng-jhipster";
|
import {JhiDataUtils} from "ng-jhipster";
|
||||||
import {ActivatedRoute} from "@angular/router";
|
import {ActivatedRoute} from "@angular/router";
|
||||||
import {UnitArmyService} from "../unit-army/unit-army.service";
|
import {UnitArmyService} from "../unit-army/unit-army.service";
|
||||||
|
import {ArmyService} from "../army/army.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'jhi-force-desktop',
|
selector: 'jhi-force-desktop',
|
||||||
templateUrl: './force-desktop.component.html'
|
templateUrl: './force-desktop.component.html'
|
||||||
})
|
})
|
||||||
export class ForceDesktopComponent extends ForceComponent {
|
export class ForceDesktopComponent extends ForceComponent {
|
||||||
constructor(protected dataUtils: JhiDataUtils, protected activatedRoute: ActivatedRoute, protected unitArmyService: UnitArmyService) {
|
constructor(protected dataUtils: JhiDataUtils,
|
||||||
super(dataUtils, activatedRoute, unitArmyService);
|
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="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>
|
<br>
|
||||||
<div class="powers" *ngIf="unitLocal.warlordTraits"></div>
|
<div class="powers" *ngIf="unitLocal.unit.warlordTraits">
|
||||||
<!-- todo do I want this?-->
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.warlordTraits }}</div>
|
||||||
<div class="powers" *ngIf="unitLocal.psychicPowersTaken"></div>
|
</div>
|
||||||
<!-- todo do I want this?-->
|
<div class="powers" *ngIf="unitLocal.unit.psychicPowersTaken">
|
||||||
<div class="powers" *ngIf="unitLocal.relics"></div>
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.psychicPowersTaken }}</div>
|
||||||
<!-- todo do I want this?-->
|
</div>
|
||||||
<div class="powers" *ngIf="unitLocal.battleHonours"></div>
|
<div class="powers" *ngIf="unitLocal.unit.relics">
|
||||||
<!-- todo do I want this?-->
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.relics }}</div>
|
||||||
<div class="powers" *ngIf="unitLocal.battleScars"></div>
|
</div>
|
||||||
<!-- todo do I want this?-->
|
<div class="powers" *ngIf="unitLocal.unit.battleHonours">
|
||||||
<div class="col-md-3-mobile" style="width: 50%">Units Destroyed</div>
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.battleHonours }}</div>
|
||||||
<div class="col-md-3-mobile" style="width: 50%">With Psychic</div>
|
</div>
|
||||||
<div class="col-md-3-mobile" style="width: 50%">With Ranged</div>
|
<div class="powers" *ngIf="unitLocal.unit.battleScars">
|
||||||
<div class="col-md-3-mobile" style="width: 50%">With Melee</div>
|
<div class="col-md-6-mobile" style="width: 80%; justify-content: center">{{ unitLocal.unit.battleScars }}</div>
|
||||||
<div class="col-md-3-mobile" style="width: 50%">Agenda 1</div>
|
</div>
|
||||||
<div class="col-md-3-mobile" style="width: 50%">Agenda 2</div>
|
<div class="col-md-6-mobile" style="width: 80%; height: 45px">
|
||||||
<div class="col-md-3-mobile" style="width: 50%">Agenda 3</div>
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -26,11 +67,18 @@
|
|||||||
<button type="submit"
|
<button type="submit"
|
||||||
(click)="previousState()"
|
(click)="previousState()"
|
||||||
class="btn btn-info">
|
class="btn btn-info">
|
||||||
<fa-icon icon="arrow-left"></fa-icon> <span>Back</span>
|
<fa-icon icon="arrow-left"></fa-icon>Back
|
||||||
</button>
|
</button>
|
||||||
<div class="row">
|
|
||||||
<button type="clear"
|
<button type="clear"
|
||||||
(click)="clearList()"
|
(click)="clearList()"
|
||||||
class="btn btn-danger">Clear</button>
|
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>
|
</div>
|
||||||
|
@ -3,13 +3,17 @@ import {ForceComponent} from "./force.component";
|
|||||||
import {JhiDataUtils} from "ng-jhipster";
|
import {JhiDataUtils} from "ng-jhipster";
|
||||||
import {ActivatedRoute} from "@angular/router";
|
import {ActivatedRoute} from "@angular/router";
|
||||||
import {UnitArmyService} from "../unit-army/unit-army.service";
|
import {UnitArmyService} from "../unit-army/unit-army.service";
|
||||||
|
import {ArmyService} from "../army/army.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'jhi-force-mobile',
|
selector: 'jhi-force-mobile',
|
||||||
templateUrl: './force-mobile.component.html'
|
templateUrl: './force-mobile.component.html'
|
||||||
})
|
})
|
||||||
export class ForceMobileComponent extends ForceComponent {
|
export class ForceMobileComponent extends ForceComponent {
|
||||||
constructor(protected dataUtils: JhiDataUtils, protected activatedRoute: ActivatedRoute, protected unitArmyService: UnitArmyService) {
|
constructor(protected dataUtils: JhiDataUtils,
|
||||||
super(dataUtils, activatedRoute, unitArmyService);
|
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">
|
<div class="desktop-container" *ngIf="!isMobileResolution; else mobileContainer">
|
||||||
<jhi-force-desktop></jhi-force-desktop>
|
<jhi-force-desktop></jhi-force-desktop>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { HttpResponse } from '@angular/common/http';
|
import { HttpResponse } from '@angular/common/http';
|
||||||
import { JhiDataUtils } from 'ng-jhipster';
|
import { JhiDataUtils } from 'ng-jhipster';
|
||||||
import { LocalStorageService } from 'ngx-webstorage';
|
import { UnitArmy } from '../../shared/model/unit-army.model';
|
||||||
import { IUnitArmy, 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 { UnitArmyService } from '../unit-army/unit-army.service';
|
||||||
|
import { ArmyService } from '../army/army.service';
|
||||||
import {ResponsiveService} from "../../responsive.service";
|
import {ResponsiveService} from "../../responsive.service";
|
||||||
|
import {Observable} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'jhi-force',
|
selector: 'jhi-force',
|
||||||
@ -14,43 +16,82 @@ import {ResponsiveService} from "../../responsive.service";
|
|||||||
styleUrls: ['./force.component.scss'],
|
styleUrls: ['./force.component.scss'],
|
||||||
})
|
})
|
||||||
export class ForceComponent implements OnInit {
|
export class ForceComponent implements OnInit {
|
||||||
public forceList: number[];
|
public forceList: ForceUnit[];
|
||||||
Iunits?: IUnitArmy[];
|
units: UnitArmy[] = [];
|
||||||
units?: UnitArmy[] | null;
|
army: Army | null = null;
|
||||||
|
armyId = 0;
|
||||||
public isMobileResolution: boolean;
|
public isMobileResolution: boolean;
|
||||||
responsiveService: ResponsiveService = new ResponsiveService();
|
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');
|
const localStorageList = localStorage.getItem('forceAddedListStored');
|
||||||
this.forceList = localStorageList ? JSON.parse(localStorageList) : [];
|
this.forceList = localStorageList ? JSON.parse(localStorageList) : [];
|
||||||
this.isMobileResolution = this.responsiveService.getMobileStatus();
|
this.isMobileResolution = this.responsiveService.getMobileStatus();
|
||||||
this.localUnits = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.loadAll();
|
this.getArmyId();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAll(): void {
|
getArmyId(): void {
|
||||||
for (let lookupUnitId of this.forceList) {
|
if (this.forceList[0] && this.forceList[0].unit.id) {
|
||||||
// @ts-ignore
|
const armyIdOrNull: Observable<HttpResponse<number>> = this.unitArmyService.getArmy(this.forceList[0].unit.id);
|
||||||
this.unitArmyService.find(lookupUnitId).subscribe((res: HttpResponse<IUnitArmy>) => (this.localUnits?.push(res.body)));
|
armyIdOrNull.toPromise().then(
|
||||||
// this.unitArmyService.query(lookupUnitId).subscribe((res: HttpResponse<UnitArmy[]>) => (this.units = res.body));
|
res => {
|
||||||
// console.log(this.units.))
|
Promise.resolve(res.body);
|
||||||
// console.log(lookupUnitId)
|
this.armyId = res.body? res.body : 0;
|
||||||
// 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)
|
getArmyIdPromise(): Promise<number | void> | null {
|
||||||
// console.log(lookupUnitId)
|
if (this.forceList[0] && this.forceList[0].unit.id) {
|
||||||
// if (_unit.id === lookupUnitId) {
|
const armyIdOrNull: Observable<HttpResponse<number>> = this.unitArmyService.getArmy(this.forceList[0].unit.id);
|
||||||
// this.localUnits.push(_unit);
|
return armyIdOrNull.toPromise().then(
|
||||||
// }
|
res => {
|
||||||
// }
|
Promise.resolve(res.body);
|
||||||
lookupUnitId = 1;
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
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 {
|
previousState(): void {
|
||||||
window.history.back();
|
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 { forceRoute } from './force.route';
|
||||||
import {ForceDesktopComponent} from "./force-desktop.component";
|
import {ForceDesktopComponent} from "./force-desktop.component";
|
||||||
import {ForceMobileComponent} from "./force-mobile.component";
|
import {ForceMobileComponent} from "./force-mobile.component";
|
||||||
|
import {UnitArmy} from "../../shared/model/unit-army.model";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [CrusadetrackerSharedModule, RouterModule.forChild(forceRoute)],
|
imports: [CrusadetrackerSharedModule, RouterModule.forChild(forceRoute)],
|
||||||
@ -14,4 +15,5 @@ import {ForceMobileComponent} from "./force-mobile.component";
|
|||||||
ForceMobileComponent
|
ForceMobileComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class CrusadetrackerForceModule {}
|
export class CrusadetrackerForceModule {}
|
||||||
|
@ -113,6 +113,7 @@ export class UnitArmyUpdateComponent implements OnInit {
|
|||||||
this.isSaving = true;
|
this.isSaving = true;
|
||||||
const unitArmy = this.createFromForm();
|
const unitArmy = this.createFromForm();
|
||||||
if (unitArmy.id !== undefined) {
|
if (unitArmy.id !== undefined) {
|
||||||
|
console.log(unitArmy);
|
||||||
this.subscribeToSaveResponse(this.unitArmyService.update(unitArmy));
|
this.subscribeToSaveResponse(this.unitArmyService.update(unitArmy));
|
||||||
} else {
|
} else {
|
||||||
this.subscribeToSaveResponse(this.unitArmyService.create(unitArmy));
|
this.subscribeToSaveResponse(this.unitArmyService.create(unitArmy));
|
||||||
|
@ -35,4 +35,8 @@ export class UnitArmyService {
|
|||||||
delete(id: number): Observable<HttpResponse<{}>> {
|
delete(id: number): Observable<HttpResponse<{}>> {
|
||||||
return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' });
|
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
|
// tslint:disable-next-line:typedef
|
||||||
public checkWidth() {
|
public checkWidth() {
|
||||||
console.log(window.innerWidth)
|
|
||||||
// tslint:disable-next-line:prefer-const
|
// tslint:disable-next-line:prefer-const
|
||||||
if (window.innerWidth <= 768) {
|
if (window.innerWidth <= 768) {
|
||||||
this.isMobile = true;
|
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