Răsfoiți Sursa

Merge branch 'release/0.9.5'

Warafear 11 luni în urmă
părinte
comite
c2b5661edf
22 a modificat fișierele cu 144 adăugiri și 73 ștergeri
  1. 1 1
      package.json
  2. 7 7
      src/app/app-routing.module.ts
  3. 11 1
      src/app/app.module.ts
  4. 24 24
      src/app/character/character-creator/character-creator.component.ts
  5. 2 4
      src/app/character/character-picker/character-card/character-card.component.ts
  6. 2 2
      src/app/journal/journal-home/journal-home.component.ts
  7. 7 3
      src/app/journal/journal-stats/ability-panel/ability-table/ability-modal/ability-modal.component.html
  8. 1 0
      src/app/journal/journal-stats/ability-panel/ability-table/ability-modal/ability-modal.component.ts
  9. 34 14
      src/app/journal/journal-stats/ability-panel/ability-table/ability-table.component.html
  10. 16 0
      src/app/journal/journal-stats/ability-panel/ability-table/ability-table.component.scss
  11. 17 0
      src/app/journal/journal-stats/ability-panel/ability-table/ability-table.component.ts
  12. 2 0
      src/app/journal/journal-stats/attribute-skill-container/save-throw-panel/save-throw-details/save-throw-details.component.html
  13. 1 1
      src/app/journal/journal-stats/life-container/hit-dice/hit-dice.component.html
  14. 1 1
      src/app/journal/journal-stats/weapons-container/weapon-table/weapon-modal/weapon-modal.component.html
  15. 0 3
      src/app/journal/journal-stats/weapons-container/weapon-table/weapon-modal/weapon-modal.component.ts
  16. 5 1
      src/app/journal/journal-stats/weapons-container/weapon-table/weapon-table.component.ts
  17. 1 1
      src/app/shared-components/icon-button/icon-button.component.html
  18. 6 3
      src/app/shared-components/icon-button/icon-button.component.scss
  19. 1 0
      src/app/shared-components/icon-button/icon-button.component.ts
  20. 3 3
      src/assets/i18n/de.json
  21. 0 2
      src/services/data/data.service.ts
  22. 2 2
      src/services/subclass/subclass.service.ts

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "dndtools",
-  "version": "0.9.4",
+  "version": "0.9.5",
   "scripts": {
     "ng": "ng",
     "start": "nx serve",

+ 7 - 7
src/app/app-routing.module.ts

@@ -3,14 +3,14 @@ import { RouterModule, Routes } from '@angular/router';
 import { CharacterModule } from './character/character.module';
 import { JournalModule } from './journal/journal.module';
 
-const routes: Routes = [
-  { path: 'character', loadChildren: () => CharacterModule },
-  { path: 'journal', loadChildren: () => JournalModule },
-  { path: '**', redirectTo: 'character', pathMatch: 'full' },
-];
+// const routes: Routes = [
+//   { path: 'character', loadChildren: () => CharacterModule },
+//   { path: 'journal', loadChildren: () => JournalModule },
+//   { path: '**', redirectTo: 'character', pathMatch: 'full' },
+// ];
 
 @NgModule({
-  imports: [RouterModule.forRoot(routes)],
-  exports: [RouterModule],
+  // imports: [RouterModule.forRoot(routes)],
+  // exports: [RouterModule],
 })
 export class AppRoutingModule {}

+ 11 - 1
src/app/app.module.ts

@@ -8,16 +8,25 @@ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
 import { HttpClient, HttpClientModule } from '@angular/common/http';
 import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
 import { TranslateHttpLoader } from '@ngx-translate/http-loader';
+import { RouterModule, Routes } from '@angular/router';
+import { CharacterModule } from './character/character.module';
+import { JournalModule } from './journal/journal.module';
 
 export function HttpLoaderFactory(httpClient: HttpClient) {
   return new TranslateHttpLoader(httpClient);
 }
 
+const routes: Routes = [
+  { path: 'character', loadChildren: () => CharacterModule },
+  { path: 'journal', loadChildren: () => JournalModule },
+  { path: '**', redirectTo: 'character', pathMatch: 'full' },
+];
+
 @NgModule({
   declarations: [AppComponent],
   imports: [
     BrowserModule,
-    AppRoutingModule,
+    RouterModule.forRoot(routes, { useHash: true }),
     NgbModule,
     BrowserAnimationsModule,
     MatSlideToggleModule,
@@ -31,6 +40,7 @@ export function HttpLoaderFactory(httpClient: HttpClient) {
     }),
   ],
   providers: [],
+  exports: [RouterModule],
   bootstrap: [AppComponent],
 })
 export class AppModule {}

+ 24 - 24
src/app/character/character-creator/character-creator.component.ts

@@ -20,33 +20,33 @@ export class CharacterCreatorComponent {
   // Predefined Data
 
   private hitDice: any = {
-    Barbarian: 12,
-    Bard: 8,
-    Cleric: 8,
-    Druid: 8,
-    Fighter: 10,
-    Monk: 8,
-    Paladin: 10,
-    Ranger: 10,
-    Rogue: 8,
-    Sorcerer: 6,
-    Warlock: 8,
-    Wizard: 6,
+    barbarian: 12,
+    bard: 8,
+    cleric: 8,
+    druid: 8,
+    fighter: 10,
+    monk: 8,
+    paladin: 10,
+    ranger: 10,
+    rogue: 8,
+    sorcerer: 6,
+    warlock: 8,
+    wizard: 6,
   };
 
   public spellcastingAttributes: any = {
-    Barbarian: null,
-    Bard: 'charisma',
-    Cleric: 'wisdom',
-    Druid: 'wisdom',
-    Fighter: null,
-    Monk: 'wisdom',
-    Paladin: 'charisma',
-    Ranger: 'wisdom',
-    Rogue: 'intelligence',
-    Sorcerer: 'charisma',
-    Warlock: 'charisma',
-    Wizard: 'intelligence',
+    barbarian: null,
+    bard: 'charisma',
+    cleric: 'wisdom',
+    druid: 'wisdom',
+    fighter: null,
+    monk: 'wisdom',
+    paladin: 'charisma',
+    ranger: 'wisdom',
+    rogue: 'intelligence',
+    sorcerer: 'charisma',
+    warlock: 'charisma',
+    wizard: 'intelligence',
   };
 
   public characterName: string = '';

+ 2 - 4
src/app/character/character-picker/character-card/character-card.component.ts

@@ -55,20 +55,18 @@ export class CharacterCardComponent {
 
   onTouchEnd(event: any) {
     const touchEndX = event.changedTouches[0].clientX;
-    if (touchEndX > this.touchStartX + 100) {
+    if (touchEndX > this.touchStartX + 50) {
       document.getElementById('delete-button')?.classList.add('show');
-    } else if (touchEndX < this.touchStartX - 100) {
+    } else if (touchEndX < this.touchStartX - 50) {
       document.getElementById('delete-button')?.classList.remove('show');
     }
   }
 
   public loadCharacterData(): void {
-    console.log(this.characterData);
     this.dataAccessor
       .getData(this.character, 'characterData')
       .then((characterData: any) => {
         this.characterData = characterData;
-        console.log(this.characterData);
       });
     this.dataAccessor.getData(this.character, 'image').then((image: any) => {
       this.image = image.value;

+ 2 - 2
src/app/journal/journal-home/journal-home.component.ts

@@ -51,9 +51,9 @@ export class JournalHomeComponent {
 
   onTouchEnd(event: any) {
     const touchEndX = event.changedTouches[0].clientX;
-    if (touchEndX > this.touchStartX + 100) {
+    if (touchEndX > this.touchStartX + 50) {
       this.navigation.openNavigation();
-    } else if (touchEndX < this.touchStartX - 100) {
+    } else if (touchEndX < this.touchStartX - 50) {
       this.navigation.closeNavigation();
     }
   }

+ 7 - 3
src/app/journal/journal-stats/ability-panel/ability-table/ability-modal/ability-modal.component.html

@@ -64,10 +64,14 @@
         <mat-form-field appearance="outline" class="w-100">
           <!-- <mat-label>Nutzungen</mat-label> -->
           <mat-select [(ngModel)]="charges">
-            @for (charge of [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; track charge) {
+            @for (charge of chargesArray; track charge) {
               <mat-option [value]="charge">
-                {{ "uses." + charge | translate }}</mat-option
-              >
+                @if (charge === 0) {
+                  {{ "uses." + charge | translate }}
+                } @else {
+                  {{ charge }}
+                }
+              </mat-option>
             }
           </mat-select>
         </mat-form-field>

+ 1 - 0
src/app/journal/journal-stats/ability-panel/ability-table/ability-modal/ability-modal.component.ts

@@ -30,6 +30,7 @@ export class AbilityModalComponent {
   public shortDescription: string = '';
   public longDescription: string = '';
   public costs: string[] = ['none', 'action', 'bonus', 'reaction'];
+  public chargesArray: number[] = Array.from({ length: 101 }, (_, i) => i);
 
   public constructor(private modalAccessor: ModalService) {}
 

+ 34 - 14
src/app/journal/journal-stats/ability-panel/ability-table/ability-table.component.html

@@ -22,20 +22,40 @@
 
         <div class="charges-box" *ngIf="ability.charges != 0">
           {{ "abilities.uses" | translate }}
-          @for (
-            _ of getArray(ability.charges);
-            let chargeIndex = $index;
-            track _
-          ) {
-            <input
-              [id]="'checkbox' + index + '-' + chargeIndex"
-              type="checkbox"
-              (click)="$event.stopPropagation()"
-              (change)="
-                $event.stopPropagation();
-                handleChangedCharges(index, $event.target)
-              "
-            />
+          @if (ability.charges > 9) {
+            <div class="usage-box">
+              <icon-button
+                [icon]="'remove'"
+                [disabled]="ability.currentlyUsedCharges === ability.charges"
+                (click)="addUsage(index); $event.stopPropagation()"
+              ></icon-button>
+              <div class="usage">
+                {{ ability.charges - ability.currentlyUsedCharges }}/{{
+                  ability.charges
+                }}
+              </div>
+              <icon-button
+                [icon]="'add'"
+                [disabled]="ability.currentlyUsedCharges === 0"
+                (click)="removeUsage(index); $event.stopPropagation()"
+              ></icon-button>
+            </div>
+          } @else {
+            @for (
+              _ of getArray(ability.charges);
+              let chargeIndex = $index;
+              track _
+            ) {
+              <input
+                [id]="'checkbox' + index + '-' + chargeIndex"
+                type="checkbox"
+                (click)="$event.stopPropagation()"
+                (change)="
+                  $event.stopPropagation();
+                  handleChangedCharges(index, $event.target)
+                "
+              />
+            }
           }
         </div>
       </div>

+ 16 - 0
src/app/journal/journal-stats/ability-panel/ability-table/ability-table.component.scss

@@ -32,6 +32,22 @@
   }
 }
 
+.usage-box {
+  display: flex;
+  align-items: center;
+}
+
+.usage {
+  background-color: white;
+  border: var(--border);
+  border-radius: 10px;
+  padding: 0.125rem 0.25rem;
+}
+
+.used {
+  opacity: 0.5;
+}
+
 .used {
   opacity: 0.5;
 }

+ 17 - 0
src/app/journal/journal-stats/ability-panel/ability-table/ability-table.component.ts

@@ -159,4 +159,21 @@ export class AbilityTableComponent {
     moveItemInArray(this.abilities, event.previousIndex, event.currentIndex);
     this.updateDatabase();
   }
+
+  public removeUsage(abilityIndex: number): void {
+    if (this.abilities[abilityIndex].currentlyUsedCharges > 0) {
+      this.abilities[abilityIndex].currentlyUsedCharges--;
+      this.updateDatabase();
+    }
+  }
+
+  public addUsage(abilityIndex: number): void {
+    if (
+      this.abilities[abilityIndex].currentlyUsedCharges <
+      this.abilities[abilityIndex].charges
+    ) {
+      this.abilities[abilityIndex].currentlyUsedCharges++;
+      this.updateDatabase();
+    }
+  }
 }

+ 2 - 0
src/app/journal/journal-stats/attribute-skill-container/save-throw-panel/save-throw-details/save-throw-details.component.html

@@ -9,6 +9,8 @@
 
 <value-box [value]="saveModifier" [label]="'general.modifier'"></value-box>
 
+<h4 class="t-2">{{ "skillDetails.title" | translate }}</h4>
+
 <mat-radio-group [(ngModel)]="advantage" (change)="showButtons()">
   <mat-radio-button class="example-radio-button" [value]="'none'">{{
     "skillDetails.none" | translate

+ 1 - 1
src/app/journal/journal-stats/life-container/hit-dice/hit-dice.component.html

@@ -8,7 +8,7 @@
 <div class="content">{{ "life.hitdiceDescription" | translate }}</div>
 <p>
   <b>{{ "general.diceType" | translate }}: </b>
-  {{ "general.dice" | translate }} {{ hitDice.diceType }}
+  {{ "general.dice" | translate }}{{ hitDice.diceType }}
 </p>
 
 <div class="hit-dice-container">

+ 1 - 1
src/app/journal/journal-stats/weapons-container/weapon-table/weapon-modal/weapon-modal.component.html

@@ -170,7 +170,7 @@
                       <mat-select [(ngModel)]="versatileDamage">
                         @for (die of dice; track die) {
                           <mat-option [value]="die">
-                            {{ die }}{{ "general.die" | translate }}
+                            {{ "general.dice" | translate }}{{ die }}
                           </mat-option>
                         }
                       </mat-select>

+ 0 - 3
src/app/journal/journal-stats/weapons-container/weapon-table/weapon-modal/weapon-modal.component.ts

@@ -133,7 +133,6 @@ export class WeaponModalComponent {
   }
 
   public add(): void {
-    console.log(this.createItem());
     this.modalAccessor.handleModalClosing('add', this.createItem());
     this.resetItem();
   }
@@ -194,8 +193,6 @@ export class WeaponModalComponent {
     this.description = '';
   }
 
-  // COMPONENT LOGIC
-
   public addDamage(): void {
     this.damage.push({ diceNumber: 0, diceType: 0, damageType: '' });
   }

+ 5 - 1
src/app/journal/journal-stats/weapons-container/weapon-table/weapon-table.component.ts

@@ -125,7 +125,8 @@ export class WeaponTableComponent {
           this.deleteWeapon(index);
         } else if (result.state === 'update') {
           this.openModal(true, index);
-        } else resultSubscription.unsubscribe();
+        }
+        resultSubscription.unsubscribe();
       },
     );
   }
@@ -151,6 +152,9 @@ export class WeaponTableComponent {
   }
 
   public updateWeapon(weapon: Weapon, index: number): void {
+    console.warn('updateWeapon: ', weapon);
+    console.warn('index: ', index);
+
     this.weapons[index] = weapon;
     this.calculateSingleDamageModifier(index);
     this.updateWeaponInDatabase();

+ 1 - 1
src/app/shared-components/icon-button/icon-button.component.html

@@ -1,3 +1,3 @@
-<button matRipple>
+<button matRipple [class]="!disabled ? 'hover-effect' : ''">
   <img [src]="'assets/icons/UIIcons/' + icon + '.svg'" [alt]="icon" />
 </button>

+ 6 - 3
src/app/shared-components/icon-button/icon-button.component.scss

@@ -9,7 +9,10 @@ button {
   background-color: transparent;
   transition: all 0.25s ease;
   border-radius: 10px !important;
-  &:hover {
-    background-color: rgba(211, 211, 211, 0.5);
-  }
+  cursor: default;
+}
+
+.hover-effect:hover {
+  background-color: rgba(211, 211, 211, 0.5);
+  cursor: pointer;
 }

+ 1 - 0
src/app/shared-components/icon-button/icon-button.component.ts

@@ -7,4 +7,5 @@ import { Component, Input } from '@angular/core';
 })
 export class IconButtonComponent {
   @Input() icon!: string;
+  @Input() disabled: boolean = false;
 }

+ 3 - 3
src/assets/i18n/de.json

@@ -219,8 +219,8 @@
       "echoKnight": "Echo Knight"
     },
     "monk": {
-      "openHand": "Weg des offenen Händen",
-      "wayOfShadows": "Weg des Schattens",
+      "openHand": "Weg der offenen Hände",
+      "wayOfShadows": "Weg der Schatten",
       "fourElements": "Weg der vier Elemente"
     },
     "paladin": {
@@ -767,6 +767,6 @@
     "hint": "Die App befindet sich immer noch in einem Entwicklungsstadium und es können Fehler auftreten",
     "issues": "<p>Fehler und Anmerkungen bitte auf dem <a href='https://gogs.koljastrohm-games.com/Warafear/DNDTools/issues'>Git-Server in Issues</a> vermerken.<p>",
     "okay": "Verstanden",
-    "version": "0.9.4"
+    "version": "0.9.5"
   }
 }

+ 0 - 2
src/services/data/data.service.ts

@@ -78,8 +78,6 @@ export class DataService {
       weaponsAndArmorData,
     ] = currentCharacterData.map((entry: any) => entry.data);
 
-    console.log(currentCharacterData);
-
     // Character Data
     this.characterData = characterData;
 

+ 2 - 2
src/services/subclass/subclass.service.ts

@@ -14,7 +14,7 @@ export class SubclassService {
       case 'peaceDomain':
         return this.peaceDomain;
       // PALADIN
-      case 'vengance':
+      case 'vengeance':
         return this.vengeance;
       // MONK
       case 'wayOfShadows':
@@ -42,7 +42,7 @@ export class SubclassService {
       case 'monk':
         return ['wayOfShadows'];
       case 'paladin':
-        return ['vengance'];
+        return ['vengeance'];
       case 'ranger':
         return ['beastMaster'];
       case 'rogue':