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.core.game;
19  
20  import com.fasterxml.jackson.annotation.JsonIgnore;
21  import com.fasterxml.jackson.annotation.JsonInclude;
22  
23  import de.kaiserpfalzedv.commons.api.resources.Pointer;
24  import de.kaiserpfalzedv.commons.core.resources.DefaultResourceSpecImpl;
25  import lombok.AllArgsConstructor;
26  import lombok.EqualsAndHashCode;
27  import lombok.Getter;
28  import lombok.ToString;
29  import lombok.experimental.SuperBuilder;
30  import lombok.extern.jackson.Jacksonized;
31  import org.eclipse.microprofile.openapi.annotations.media.Schema;
32  
33  import java.util.List;
34  import java.util.Optional;
35  
36  /**
37   * The game data. It stores everything in properties so if is basically build from convenience methods for the
38   * {@link DefaultResourceSpec}.
39   *
40   * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
41   * @since 1.2.0 2021-02-06
42   */
43  @Jacksonized
44  @SuperBuilder(toBuilder = true)
45  @AllArgsConstructor
46  @Getter
47  @ToString(callSuper = true)
48  @EqualsAndHashCode(callSuper = true)
49  @JsonInclude(JsonInclude.Include.NON_ABSENT)
50  @Schema(name = "GameData", description = "A game session data.")
51  public class GameData extends DefaultResourceSpecImpl {
52      public static String CAMPAIGN = "campaign";
53      public static String GAME_GM = "game.gm";
54      public static String GAME_PLAYERS = "game.players";
55      public static String DISCORD_GUILD = "discord.guild";
56      public static String DISCORD_CHANNEL = "discord.channel";
57  
58      public static String[] STRUCTURED_PROPERTIES = {
59              CAMPAIGN,
60              GAME_GM,
61              GAME_PLAYERS,
62              DISCORD_GUILD,
63              DISCORD_CHANNEL
64      };
65  
66      @Override
67      public String[] getDefaultProperties() {
68          return STRUCTURED_PROPERTIES;
69      }
70  
71  
72      @JsonIgnore
73      public Optional<Pointer> getCampaign() {
74          return getResourcePointer(CAMPAIGN);
75      }
76  
77  
78      @JsonIgnore
79      public Optional<Pointer> getGameMaster() {
80          return getResourcePointer(GAME_GM);
81      }
82  
83  
84      @JsonIgnore
85      public List<Pointer> getPlayers() {
86          return getResourcePointers(GAME_PLAYERS);
87      }
88  
89  
90      @JsonIgnore
91      public Optional<Pointer> getDiscordChannel() {
92          return getResourcePointer(DISCORD_CHANNEL);
93      }
94  
95  
96      @JsonIgnore
97      public Optional<Pointer> getDiscordGuild() {
98          return getResourcePointer(DISCORD_GUILD);
99      }
100 }