-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(inventory): add item compare modal pre-equip. closes #76
- Loading branch information
Showing
6 changed files
with
253 additions
and
25 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
client/src/app/components/modals/compare-items/compare-items.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"></ion-buttons> | ||
|
||
<ion-title>Compare Items</ion-title> | ||
|
||
<ion-buttons slot="end"> | ||
<ion-button (click)="dismiss(true)" [strong]="true">Equip</ion-button> | ||
<ion-button color="medium" (click)="dismiss()">Close</ion-button> | ||
</ion-buttons> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content class="ion-padding"> | ||
<ion-card> | ||
<ion-card-content> | ||
<ion-row> | ||
<ion-col> | ||
<ion-row> | ||
<ion-col> | ||
<ion-row class="name-row"> | ||
<ion-col class="icon"> | ||
<app-item-icon [item]="item1" size="small"></app-item-icon> | ||
</ion-col> | ||
<ion-col class="name"> | ||
{{ item1.name }} | ||
<br /> | ||
Lv.{{ item1.levelRequirement }} | ||
</ion-col> | ||
</ion-row> | ||
</ion-col> | ||
</ion-row> | ||
|
||
<ion-row | ||
*ngFor="let stat of commonStats" | ||
class="stat-row" | ||
[ngClass]="getStatClassBetweenItems(stat, item1, item2)" | ||
> | ||
<ion-col> | ||
<ion-row> | ||
<ion-col class="stat"> | ||
{{ stat }} | ||
</ion-col> | ||
|
||
<ion-col class="value"> | ||
{{ item1.stats[stat] > 0 ? '+' : '' }} | ||
{{ item1.stats[stat] || 0 | number }} | ||
</ion-col> | ||
</ion-row> | ||
</ion-col> | ||
</ion-row> | ||
</ion-col> | ||
|
||
<ion-col *ngIf="!item2"> | ||
<ion-row> | ||
<ion-col>(nothing)</ion-col> | ||
</ion-row> | ||
</ion-col> | ||
|
||
<ion-col *ngIf="item2"> | ||
<ion-row> | ||
<ion-col> | ||
<ion-row class="name-row"> | ||
<ion-col class="icon"> | ||
<app-item-icon [item]="item2" size="small"></app-item-icon> | ||
</ion-col> | ||
<ion-col class="name"> | ||
{{ item2.name }} | ||
<br /> | ||
Lv.{{ item2.levelRequirement }} | ||
</ion-col> | ||
</ion-row> | ||
</ion-col> | ||
</ion-row> | ||
|
||
<ion-row | ||
*ngFor="let stat of commonStats" | ||
class="stat-row" | ||
[ngClass]="getStatClassBetweenItems(stat, item2, item1)" | ||
> | ||
<ion-col> | ||
<ion-row> | ||
<ion-col class="stat"> | ||
{{ stat }} | ||
</ion-col> | ||
|
||
<ion-col class="value"> | ||
{{ item2.stats[stat] > 0 ? '+' : '' }} | ||
{{ item2.stats[stat] || 0 | number }} | ||
</ion-col> | ||
</ion-row> | ||
</ion-col> | ||
</ion-row> | ||
</ion-col> | ||
</ion-row> | ||
</ion-card-content> | ||
</ion-card> | ||
</ion-content> |
35 changes: 35 additions & 0 deletions
35
client/src/app/components/modals/compare-items/compare-items.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
.name-row { | ||
|
||
.icon { | ||
max-width: 80px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.name { | ||
display: flex; | ||
align-items: center; | ||
font-weight: bold; | ||
} | ||
} | ||
|
||
.stat-row { | ||
|
||
&.higher { | ||
color: var(--ion-color-success); | ||
} | ||
|
||
&.lower { | ||
color: var(--ion-color-danger); | ||
} | ||
|
||
.stat { | ||
|
||
} | ||
|
||
.value { | ||
font-weight: bold; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
client/src/app/components/modals/compare-items/compare-items.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { IEquipment, Stat } from '@interfaces'; | ||
import { ModalController } from '@ionic/angular'; | ||
|
||
@Component({ | ||
selector: 'app-compare-items', | ||
templateUrl: './compare-items.component.html', | ||
styleUrls: ['./compare-items.component.scss'], | ||
}) | ||
export class CompareItemsModalComponent implements OnInit { | ||
@Input() item1!: IEquipment; | ||
@Input() item2!: IEquipment | undefined; | ||
|
||
public commonStats: Stat[] = []; | ||
|
||
constructor(private modalCtrl: ModalController) {} | ||
|
||
ngOnInit() { | ||
const stats = new Set<string>(); | ||
Object.keys(this.item1.stats).forEach((stat) => stats.add(stat)); | ||
|
||
if (this.item2) { | ||
Object.keys(this.item2.stats).forEach((stat) => stats.add(stat)); | ||
} | ||
|
||
this.commonStats = Array.from(stats).sort() as Stat[]; | ||
} | ||
|
||
dismiss(value?: any) { | ||
this.modalCtrl.dismiss(value); | ||
} | ||
|
||
getStatClassBetweenItems( | ||
stat: Stat, | ||
item1: IEquipment, | ||
item2?: IEquipment, | ||
): string { | ||
if (!item2) return 'higher'; | ||
|
||
if (item1.stats[stat] > (item2.stats[stat] ?? 0)) return 'higher'; | ||
if (item1.stats[stat] < item2.stats[stat]) return 'lower'; | ||
|
||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters