View Javadoc
1   /*
2    * Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
16   */
17  
18  package de.kaiserpfalzedv.rpg.torg.model.actors;
19  
20  import lombok.AllArgsConstructor;
21  
22  /**
23   * Clearance -- The security clearance levels for Delphi Council operatives.
24   *
25   * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
26   * @since 1.2.0  2021-03-26
27   */
28  @SuppressWarnings("ALL")
29  @AllArgsConstructor
30  public enum Clearance {
31      ANY(-1),
32      ALPHA(0),
33      BETA(50),
34      GAMMA(200),
35      DELTA(500),
36      OMEGA(1000);
37  
38      private final int xp;
39  
40      /**
41       * Calculates the clearance for the given amount of XP.
42       *
43       * @param xp The xp to match the security clearance level.
44       * @return The Delphi Council Security Clearance level.
45       */
46      public static Clearance valueOf(int xp) {
47          if (xp >= Clearance.OMEGA.getMinXP()) {
48              return Clearance.OMEGA;
49          } else if (xp >= Clearance.DELTA.getMinXP()) {
50              return Clearance.DELTA;
51          } else if (xp >= Clearance.GAMMA.getMinXP()) {
52              return Clearance.GAMMA;
53          } else if (xp >= Clearance.BETA.getMinXP()) {
54              return Clearance.BETA;
55          } else if (xp >= Clearance.ALPHA.getMinXP()) {
56              return Clearance.ALPHA;
57          } else {
58              return Clearance.ANY;
59          }
60      }
61  
62      public int getMinXP() {
63          return xp;
64      }
65  }