Ver código fonte

Unified species, class and subclass presentation and data

Warafear 11 meses atrás
pai
commit
e04a2b958b

+ 3 - 3
src/app/journal/journal-character/class/class.component.scss

@@ -51,9 +51,9 @@
   margin-top: 1rem;
 }
 
-:host ::ng-deep p {
-  margin: 0;
-}
+// :host ::ng-deep p {
+//   margin: 0;
+// }
 
 :host ::ng-deep h3,
 :host ::ng-deep h4 {

+ 0 - 1
src/app/journal/journal-character/class/class.component.ts

@@ -24,7 +24,6 @@ export class ClassComponent {
   public ngOnInit(): void {
     this.className = this.dataAccessor.characterData.class;
     this.class = this.classAccessor.getClassDetails(this.className);
-    console.log(this.class);
   }
 
   public addFeature(feature: any) {

+ 7 - 6
src/app/journal/journal-character/species/species.component.html

@@ -1,19 +1,20 @@
 <div class="species-container">
-  <div class="title">{{ "species." + species.title | translate }}</div>
+  <div class="title">{{ "species." + speciesName | translate }}</div>
 
-  <!-- <markdown [data]="species.description"></markdown> -->
   <div [innerHTML]="species.description"></div>
 
   <div class="abilities">
     @for (ability of species.abilities; track ability) {
       <div class="ability">
+        <hr />
         <div class="ability-name">{{ ability.name }}</div>
         <div class="ability-level">{{ ability.level }}</div>
+        <icon-button
+          [icon]="'add'"
+          class="feature-button"
+          (click)="addFeature(ability)"
+        ></icon-button>
         <div [innerHTML]="ability.description"></div>
-        <!-- <markdown
-          class="ability-description"
-          [data]="ability.description"
-        ></markdown> -->
       </div>
     }
   </div>

+ 19 - 7
src/app/journal/journal-character/species/species.component.scss

@@ -20,12 +20,8 @@
   font-weight: bold;
   margin: 0 0 2rem 0;
 }
-
-.description {
-}
-
 .abilities {
-  margin-top: 2rem;
+  margin-top: 1.5rem;
   position: relative;
 }
 
@@ -33,16 +29,32 @@
   font-size: 1.5rem;
   font-weight: 600;
   margin-bottom: 1rem;
+  margin-left: 1rem;
 }
 
 .ability-level {
   position: absolute;
-  left: -1.75rem;
-  top: 0;
+  left: -1.5rem;
+  top: 1rem;
   font-size: 1.5rem;
   font-weight: 600;
 }
 
+.feature-button {
+  position: absolute;
+  right: 0;
+  top: 1.5rem;
+}
+
 .ability-description {
   margin-top: 1rem;
 }
+
+// :host ::ng-deep p {
+//   margin: 0;
+// }
+
+:host ::ng-deep h3,
+:host ::ng-deep h4 {
+  margin-top: 1rem;
+}

+ 72 - 0
src/app/journal/journal-character/species/species.component.ts

@@ -1,6 +1,11 @@
 import { Component } from '@angular/core';
+import { Trait } from 'src/interfaces/traits';
 import { DataService } from 'src/services/data/data.service';
 import { SpeciesService } from 'src/services/species/species.service';
+import { ModalService } from 'src/services/modal/modal.service';
+import { Ability } from 'src/interfaces/ability';
+import { AbilityModalComponent } from '../../journal-stats/ability-panel/ability-table/ability-modal/ability-modal.component';
+import { TraitModalComponent } from '../../journal-stats/ability-panel/trait-table/trait-modal/trait-modal.component';
 
 @Component({
   selector: 'species',
@@ -14,8 +19,75 @@ export class SpeciesComponent {
   public constructor(
     public speciesAccessor: SpeciesService,
     public dataAccessor: DataService,
+    public modalAccessor: ModalService,
   ) {
     this.speciesName = this.dataAccessor.characterData.race;
     this.species = speciesAccessor.getSpeciesDetails(this.speciesName);
   }
+
+  public addFeature(feature: any) {
+    if ('ability' in feature) {
+      this.addAbility(feature);
+    } else {
+      this.addTrait(feature);
+    }
+  }
+
+  private addAbility(feature: any) {
+    let index = feature.name.indexOf('Optional');
+    if (index > -1) {
+      feature.name = feature.name.slice(index, 8);
+    }
+    let ability: Ability = {
+      name: feature.name,
+      shortDescription: '',
+      longDescription: feature.description,
+      cost: '',
+      charges: 0,
+      currentlyUsedCharges: 0,
+    };
+    this.modalAccessor.openModal(AbilityModalComponent, {
+      ability: ability,
+      isUpdate: true,
+      isAddedFromCharacter: true,
+    });
+    const resultSubscription = this.modalAccessor.result$.subscribe(
+      (result) => {
+        if (result.state === 'update' || result.state === 'add') {
+          let ability = this.dataAccessor.abilities;
+          ability.push(result.data);
+          this.dataAccessor.abilities = ability;
+        }
+        resultSubscription.unsubscribe();
+      },
+    );
+  }
+
+  private addTrait(feature: any) {
+    let index = feature.name.indexOf('Optional');
+    if (index > -1) {
+      feature.name = feature.name.slice(index, 8);
+    }
+    let trait: Trait = {
+      name: feature.name,
+      shortDescription: '',
+      longDescription: feature.description,
+      origin: 'Class',
+    };
+    this.modalAccessor.openModal(TraitModalComponent, {
+      trait: trait,
+      isUpdate: true,
+      isAddedFromCharacter: true,
+    });
+    const resultSubscription = this.modalAccessor.result$.subscribe(
+      (result) => {
+        if (result.state === 'update' || result.state === 'add') {
+          let traits = this.dataAccessor.traits;
+          traits.push(result.data);
+          this.dataAccessor.traits = traits;
+        }
+        resultSubscription.unsubscribe();
+      },
+    );
+  }
 }

+ 1 - 0
src/assets/i18n/de.json

@@ -151,6 +151,7 @@
     "changeling": "Wechselbalg",
     "duergar": "Duergar",
     "drow": "Drow",
+    "eladrin": "Eladrin",
     "halfElfDetection": "Halbelf (Zeichen der Erkenntnis)",
     "fairy": "Feenwesen",
     "firbolg": "Firbolg",

+ 74 - 80
src/services/species/species.service.ts

@@ -8,9 +8,9 @@ export class SpeciesService {
 
   public getSpeciesDetails(name: string): any {
     switch (name) {
-      case 'Eladrin':
+      case 'eladrin':
         return this.eladrin;
-      case 'HalfElfDetection':
+      case 'halfElfDetection':
         return this.halfElfDetection;
       default:
         return this.notImplementedYet;
@@ -18,98 +18,92 @@ export class SpeciesService {
   }
 
   private eladrin: any = {
-    title: 'Eladrin',
+    title: 'eladrin',
     description: `
-    Eladrin are elves of the Feywild, a realm of perilous beauty and boundless magic. Using that magic, eladrin can step from one place to another in the blink of an eye, and each eladrin resonates with emotions captured in the Feywild in the form of seasons — affinities that affect the eladrin’s mood and appearance. An eladrin’s season can change, though some remain in one season forever. Like other elves, eladrin can live to be over 750 years old.
-
-    #### Eladrin Seasons
-
-    1. **Autumn:** peace and goodwill, when summer's harvest is shared with all.
-    2. **Winter:** contemplation and dolor, when the vibrant energy of the world slumbers.
-    3. **Spring:** cheerfulness and celebration, marked by merriment and hope as winter's sorrow passes.
-    4. **Summer:** boldness and aggression, a time of unfettered energy and calls to action.
-
-    **Ability Score Increase:** When determining your character’s ability scores, increase one score by 2 and increase a different score by 1, or increase three different scores by 1. You can't raise any of your scores above 20.
-    
-    **Creature Type:** You are a Humanoid. You are also considered an elf for any prerequisite or effect that requires you to be an elf.
-    
-    **Size:** You are Medium.
-    
-    **Speed:** Your walking speed is 30 feet.
-    
-    **Darkvision:** You can see in dim light within 60 feet of you as if it were bright light and in darkness as if it were dim light. You discern colors in that darkness only as shades of gray.
-    
-    **Fey Ancestry:** You have advantage on saving throws you make to avoid or end the charmed condition on yourself.
-    
-    **Fey Step:** As a bonus action, you can magically teleport up to 30 feet to an unoccupied space you can see. You can use this trait a number of times equal to your proficiency bonus, and you regain all expended uses when you finish a long rest.
-    When you reach 3rd level, your Fey Step gains an additional effect based on your season; if the effect requires a saving throw, the DC equals 8 + your proficiency bonus + your Intelligence, Wisdom, or Charisma modifier (choose when you select this race):
-    - **Autumn** Immediately after you use your Fey Step, up to two creatures of your choice that you can see within 10 feet of you must succeed on a Wisdom saving throw or be charmed by you for 1 minute, or until you or your companions deal any damage to the creatures.
-    - **Winter** When you use your Fey Step, one creature of your choice that you can see within 5 feet of you before you teleport must succeed on a Wisdom saving throw or be frightened of you until the end of your next turn.
-    - **Spring** When you use your Fey Step, you can touch one willing creature within 5 feet of you. That creature then teleports instead of you, appearing in an unoccupied space of your choice that you can see within 30 feet of you.
-    - **Summer** Immediately after you use your Fey Step, each creature of your choice that you can see within 5 feet of you takes fire damage equal to your proficiency bonus.
-   
-    **Keen Senses** You have proficiency in the Perception skill.
-   
-    **Trance** You don’t need to sleep, and magic can’t put you to sleep. You can finish a long rest in 4 hours if you spend those hours in a trancelike meditation, during which you retain consciousness.
-    - Whenever you finish this trance, you can change your season, and you can gain two proficiencies that you don’t have, each one with a weapon or a tool of your choice selected from the Player’s Handbook. You mystically acquire these proficiencies by drawing them from shared elven memory, and you retain them until you finish your next long rest.
-   
-    **Languages** Your character can speak, read, and write Common and one other language that you and your DM agree is appropriate for the character. The Player’s Handbook offers a list of languages to choose from. The DM is free to modify that list for a campaign.
-    
+      <p>Eladrin are elves of the Feywild, a realm of perilous beauty and boundless magic. Using that magic, eladrin can step from one place to another in the blink of an eye, and each eladrin resonates with emotions captured in the Feywild in the form of seasons — affinities that affect the eladrin’s mood and appearance. An eladrin’s season can change, though some remain in one season forever. Like other elves, eladrin can live to be over 750 years old.</p>
+      <h4>Eladrin Seasons</h4>
+      <ul>
+        <li><strong>Autumn:</strong> peace and goodwill, when summer's harvest is shared with all.</li>
+        <li><strong>Winter:</strong> contemplation and dolor, when the vibrant energy of the world slumbers.</li>
+        <li><strong>Spring:</strong> cheerfulness and celebration, marked by merriment and hope as winter's sorrow passes.</li>
+        <li><strong>Summer:</strong> boldness and aggression, a time of unfettered energy and calls to action.</li>
+      </ul>
+      <h4>Eladrin Characteristics</h4>
+      <p><b>Ability Score Increase:</b> When determining your character’s ability scores, increase one score by 2 and increase a different score by 1, or increase three different scores by 1. You can't raise any of your scores above 20.</p>    
+      <p><b>Creature Type:</b> You are a Humanoid. You are also considered an elf for any prerequisite or effect that requires you to be an elf.</p>
+      <p><b>Size:</b> You are Medium.</p>
+      <p><b>Speed:</b> Your walking speed is 30 feet.</p>
+      <p><b>Darkvision:</b> You can see in dim light within 60 feet of you as if it were bright light and in darkness as if it were dim light. You discern colors in that darkness only as shades of gray.</p>
+      <p><b>Fey Ancestry:</b> You have advantage on saving throws you make to avoid or end the charmed condition on yourself.</p>
+      <p><b>Keen Senses:</b> You have proficiency in the Perception skill.</p>
+      <p><b>Trance:</b> You don’t need to sleep, and magic can’t put you to sleep. You can finish a long rest in 4 hours if you spend those hours in a trancelike meditation, during which you retain consciousness.</p>
+      <ul>
+        <li>Whenever you finish this trance, you can change your season, and you can gain two proficiencies that you don’t have, each one with a weapon or a tool of your choice selected from the Player’s Handbook. You mystically acquire these proficiencies by drawing them from shared elven memory, and you retain them until you finish your next long rest.
+      </li>
+      </ul>
+      <p><b>Languages:</b> Your character can speak, read, and write Common and one other language that you and your DM agree is appropriate for the character. The Player’s Handbook offers a list of languages to choose from. The DM is free to modify that list for a campaign.</p>
     `,
     abilities: [
       {
         name: 'Fey Step',
         level: 0,
         description: `
-        **Fey Step:** As a bonus action, you can magically teleport up to 30 feet to an unoccupied space you can see. You can use this trait a number of times equal to your proficiency bonus, and you regain all expended uses when you finish a long rest.
-        When you reach 3rd level, your Fey Step gains an additional effect based on your season; if the effect requires a saving throw, the DC equals 8 + your proficiency bonus + your Intelligence, Wisdom, or Charisma modifier (choose when you select this race):
-        - **Autumn** Immediately after you use your Fey Step, up to two creatures of your choice that you can see within 10 feet of you must succeed on a Wisdom saving throw or be charmed by you for 1 minute, or until you or your companions deal any damage to the creatures.
-        - **Winter** When you use your Fey Step, one creature of your choice that you can see within 5 feet of you before you teleport must succeed on a Wisdom saving throw or be frightened of you until the end of your next turn.
-        - **Spring** When you use your Fey Step, you can touch one willing creature within 5 feet of you. That creature then teleports instead of you, appearing in an unoccupied space of your choice that you can see within 30 feet of you.
-        - **Summer** Immediately after you use your Fey Step, each creature of your choice that you can see within 5 feet of you takes fire damage equal to your proficiency bonus.
-   
+          <p>As a bonus action, you can magically teleport up to 30 feet to an unoccupied space you can see. You can use this trait a number of times equal to your proficiency bonus, and you regain all expended uses when you finish a long rest. When you reach 3rd level, your Fey Step gains an additional effect based on your season; if the effect requires a saving throw, the DC equals 8 + your proficiency bonus + your Intelligence, Wisdom, or Charisma modifier (choose when you select
+          <p>When you reach 3rd level, your Fey Step gains an additional effect based on your season; if the effect requires a saving throw, the DC equals 8 + your proficiency bonus + your Intelligence, Wisdom, or Charisma modifier (choose when you select this race):</p>
+          <ul>
+            <li><strong>Autumn:</strong> Immediately after you use your Fey Step, up to two creatures of your choice that you can see within 10 feet of you must succeed on a Wisdom saving throw or be charmed by you for 1 minute, or until you or your companions deal any damage to the creatures.</li>
+            <li><strong>Winter:</strong> When you use your Fey Step, one creature of your choice that you can see within 5 feet of you before you teleport must succeed on a Wisdom saving throw or be frightened of you until the end of your next turn.</li>
+            <li><strong>Spring:</strong> When you use your Fey Step, you can touch one willing creature within 5 feet of you. That creature then teleports instead of you, appearing in an unoccupied space of your choice that you can see within 30 feet of you.</li>
+            <li><strong>Summer:</strong> Immediately after you use your Fey Step, each creature of your choice that you can see within 5 feet of you takes fire damage equal to your proficiency bonus.</li>
+          </ul>
         `,
+        ability: '',
       },
     ],
   };
 
   private halfElfDetection: any = {
-    title: 'Half-Elf (Mark of Detection)',
+    title: 'halfElfDetection',
     description: `
-    Walking in two worlds but truly belonging to neither, half-elves combine what some say are the best qualities of their elf and human parents: human curiosity, inventiveness, and ambition tempered by the refined senses, love of nature, and artistic tastes of the elves.
-
-    **Ability Score Increase:** Your Wisdom score increases by 2, and one other Ability Score of your choice increases by 1.
-    
-    **Creature Type:** You are a Humanoid. You are also considered an elf for any prerequisite or effect that requires you to be an elf.
-    
-    **Size:** You are Medium.
-    
-    **Speed:** Your walking speed is 35 feet.
-    
-    **Darkvision:** You can see in dim light within 60 feet of you as if it were bright light and in darkness as if it were dim light. You discern colors in that darkness only as shades of gray.
-    
-    **Fey Ancestry:** You have advantage on saving throws you make to avoid or end the charmed condition on yourself.
-    
-    **Skill Versatility:** You gain proficiency in two skills of your choice.
-    
-    **Languages:** Your character can speak, read, and write Common, Elvish, and one extra language of your choice.
-    
-    **Deductive Intuition:** Whenever you make a Intelligence (Investigation) or a Wisdom (Insight) check, you can roll a d4 and add the number rolled to the total ability check.
-
-    **Magical Detection:** You can cast the Detect Magic and the Detect Poison and Disease spells with this trait. Starting at 3rd level, you can also cast the See Invisibility spell with it. Once you cast either spell with this trait, you can't cast that spell again until you finish a Long Rest. Intelligence is your Spellcasting Ability for these spells, and you don't require material components for them.
-
-    **Spells of the Mark:** If you have the Spellcasting or Pact Magic class feature, the spells on the Mark of Detection Spells table are added to the spell list of your Spellcasting class.
-
-    **Mark of Detection Spells**
-
-    | Spell Level | Spells |
-    | ----------- | ------ |
-    | 1st | Detect Magic, Detect Poison and Disease |
-    | 2nd | See Invisibility |
-    | 3rd | Clairvoyance, Tongues |
-    | 4th | Arcane Eye, Locate Creature |
-    | 5th | Legend Lore, Rary's Telepathic Bond |
-    
+    <p>Walking in two worlds but truly belonging to neither, half-elves combine what some say are the best qualities of their elf and human parents: human curiosity, inventiveness, and ambition tempered by the refined senses, love of nature, and artistic tastes of the elves.</p>
+    <p><b>Ability Score Increase:</b> Your Charisma score increases by 2, and two other ability scores of your choice increase by 1.</p>
+    <p><b>Creature Type:</b> You are a Humanoid. You are also considered an elf for any prerequisite or effect that requires you to be an elf.</p>
+    <p><b>Size:</b> You are Medium.</p>
+    <p><b>Speed:</b> Your walking speed is 30 feet.</p>
+    <p><b>Darkvision:</b> You can see in dim light within 60 feet of you as if it were bright light and in darkness as if it were dim light. You discern colors in that darkness only as shades of gray.</p>
+    <p><b>Fey Ancestry:</b> You have advantage on saving throws you make to avoid or end the charmed condition on yourself.</p>
+    <p><b>Skill Versatility:</b> You gain proficiency in two skills of your choice.</p>
+    <p><b>Languages:</b> Your character can speak, read, and write Common, Elvish, and one extra language of your choice.</p>
+    <p><b>Deductive Intuition:</b> Whenever you make a Intelligence (Investigation) or a Wisdom (Insight) check, you can roll a d4 and add the number rolled to the total ability check.</p>
+    <p><b>Magical Detection:</b> You can cast the Detect Magic and the Detect Poison and Disease spells with this trait. Starting at 3rd level, you can also cast the See Invisibility spell with it. Once you cast either spell with this trait, you can't cast that spell again until you finish a Long Rest. Intelligence is your Spellcasting Ability for these spells, and you don't require material components for them.</p>
+    <p><b>Spells of the Mark:</b> If you have the Spellcasting or Pact Magic class feature, the spells on the Mark of Detection Spells table are added to the spell list of your Spellcasting class.</p>
+    <p><b>Mark of Detection Spells</b></p>
+    <table>
+      <tr>
+        <th>Spell Level</th>
+        <th>Spells</th>
+      </tr>
+      <tr>
+        <td>1st</td>
+        <td>Detect Magic, Detect Poison and Disease</td>
+      </tr>
+      <tr>
+        <td>2nd</td>
+        <td>See Invisibility</td>
+      </tr>
+      <tr>
+        <td>3rd</td>
+        <td>Clairvoyance, Tongues</td>
+      </tr>
+      <tr>
+        <td>4th</td>
+        <td>Arcane Eye, Locate Creature</td>
+      </tr>
+      <tr>
+        <td>5th</td>
+        <td>Legend Lore, Rary's Telepathic Bond</td>
+      </tr>
+    </table>
     `,
     abilities: [],
   };