Skip to content

Commit

Permalink
Completed #519
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGuancheDarias committed Feb 17, 2024
1 parent 139f77b commit de452ce
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion game-frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# OWGE changelog

v0.11.5 (latest)
====================
* [class=Developer] __Improvement:__ Migrate to Spring Boot 3.2
Expand All @@ -14,7 +15,8 @@ v0.11.5 (latest)
* __Fix:__ [Selected planet is not preserved after f5 #542](https://github.com/KevinGuancheDarias/owge/issues/542)
* __Improvement:__ [Add browser tracking to be able to detect frontend bugs #513](https://github.com/KevinGuancheDarias/owge/issues/513)
* __Improvement:__ Allow to clear all the game data when cache panic

* __Improvement:__ [The select all units, when selecting units to carry should select up to the max capacity #519](https://github.com/KevinGuancheDarias/owge/issues/519)

v0.11.4 (2024-02-08 05:39)
==================
* __Fix:__ Fix the random bug forever! :)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<img *ngIf="currentSelection.obtainedUnit.unit" [src]="currentSelection.obtainedUnit.unit.imageUrl" />
</div>
<div class="card-block input-count" *ngIf="selectable">
<span (click)="clickSelectAllOfUnit(currentSelection)"
<span (click)="clickSelectedAllMaxCapacity(currentSelection)"
class="owge-theme-hover-background-color-alt">
<i class="fa fa-globe"></i>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ export class DeployedUnitsListComponent implements OnInit, OnChanges {
return this.selectionChanged();
}

clickSelectedAllMaxCapacity(selection: UnitSelection): Promise<void> {
selection.selectedCount = 0;
this.recomputeUsedWeight();
// TODO as this math to compute storageCapacity is also used in the view, in the future change with an angular signal
const storageCapacity: number =
this.currentSelectionForStoring.selectedCount * this.currentSelectionForStoring.obtainedUnit.unit.storageCapacity;
const freeWeight: number = storageCapacity - this.currentSelectionForStoring.usedWeight;
const maxAllowedCount = freeWeight / selection.obtainedUnit.unit.storedWeight;
selection.selectedCount = maxAllowedCount > selection.obtainedUnit.count ? selection.obtainedUnit.count : maxAllowedCount;
return this.selectionChanged();
}

clickUnselectAll(): void {
this.selectionStructure.forEach(currentSelection => {
delete currentSelection.selectedCount;
Expand Down

0 comments on commit de452ce

Please sign in to comment.