View Javadoc
1   /*
2    * Copyright (c) &today.year Kaiserpfalz EDV-Service, Roland T. Lichti
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16   */
17  
18  package de.kaiserpfalzedv.rpg.torg.model.core;
19  
20  import lombok.AllArgsConstructor;
21  import lombok.Getter;
22  import org.eclipse.microprofile.openapi.annotations.media.Schema;
23  
24  import jakarta.validation.constraints.NotNull;
25  import java.util.List;
26  import java.util.Optional;
27  
28  /**
29   * PowerTarget -- The target for attack powers on the CharSheet.
30   *
31   * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
32   * @since 1.2.0  2021-05-23
33   */
34  @AllArgsConstructor
35  @Getter
36  @Schema(description = "A definition of attack DNs")
37  public enum AttackPowerTarget {
38      DefaultAttack("Default Attack", null, null, null),
39      DodgeOrDexterity("Dodge or Dexterity", null, null, "Target’s dodge or Dexterity"),
40      FaithOrSpirit("Faith Or Spirit", null, null, "Target’s faith or Spirit"),
41      WillpowerOrMind("Willpower or Mind", null, null, "Target’s willpower or Mind"),
42      WillpowerOrSpirit("Willpower or Spirit", null, null, "Target’s willpower or Spirit"),
43      TargetAttribute("Target Attribute", null, null, "Target’s attribute"),
44      VERY_EASY("Very Easy", 6, +4, "Very Easy (DN 6)"),
45      EASY("Easy", 8, +2, "Easy (DN 8)"),
46      STANDARD("Standard", 10, 0, "Standard (DN 10)"),
47      STANDARD_DodgeOrDexterity("Standard; or Dodge or Dexterity", 10, 0, "Standard (DN 10); or a target’s dodge or Dexterity"),
48      CHALLENGING("Challenging", 12, -2, "Challenging (DN 12)"),
49      HARD("Hard", 14, -4, "Hard (DN 14)"),
50      VERY_HARD("Very Hard", 16, -6, "Very Hard (DN 16)"),
51      HEROIC("Heroic", 18, -8, "Heroic (DN 18)"),
52      NEAR_IMPOSSIBLE("Near Impossible", 20, -10, "Near Impossible (DN 20)");
53  
54      @Schema(description = "Name of the attack type")
55      private final String name;
56  
57      @Schema(description = "DN value", nullable = true)
58      private final Integer dn;
59  
60      @Schema(description = "Modifier for the DN", nullable = true)
61      private final Integer modifier;
62  
63      @Schema(description = "Foundry VTTs definition text", nullable = true)
64      private final String foundry;
65  
66      public Optional<AttackPowerTarget> mapFromFoundry(@NotNull final String name) {
67          return allAttackPowerTargets().stream()
68                  .filter(e -> name.equalsIgnoreCase(e.foundry)).distinct()
69                  .findFirst();
70      }
71  
72      public List<AttackPowerTarget> allAttackPowerTargets() {
73          return List.of(
74                  DefaultAttack,
75                  DodgeOrDexterity, FaithOrSpirit, WillpowerOrSpirit, WillpowerOrMind,
76                  TargetAttribute,
77                  VERY_EASY, EASY,
78                  STANDARD, STANDARD_DodgeOrDexterity,
79                  CHALLENGING, HARD, VERY_HARD, HEROIC, NEAR_IMPOSSIBLE
80          );
81      }
82  }