View Javadoc
1   /*
2    * Copyright (c) 2022 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.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 campaign 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 = "CampaignData", description = "The data for a multiple game spanning campaign.")
51  public class CampaignData extends DefaultResourceSpecImpl {
52      public static String CAMPAIGN_GM = "campaign.gm";
53      public static String CAMPAIGN_PLAYERS = "campaign.players";
54      public static String DISCORD_CHANNEL = "discord.channel";
55      public static String DISCORD_GUILD = "discord.guild";
56      public static String GAMES = "games";
57  
58      public static String[] STRUCTURED_PROPERTIES = {
59              CAMPAIGN_GM,
60              CAMPAIGN_PLAYERS,
61              DISCORD_GUILD,
62              DISCORD_CHANNEL,
63              GAMES
64      };
65  
66  
67      @Override
68      public String[] getDefaultProperties() {
69          return STRUCTURED_PROPERTIES;
70      }
71  
72  
73      @JsonIgnore
74      public Optional<Pointer> getGameMaster() {
75          return getResourcePointer(CAMPAIGN_GM);
76      }
77  
78      @JsonIgnore
79      public List<Pointer> getPlayers() {
80          return getResourcePointers(CAMPAIGN_PLAYERS);
81      }
82  
83      @JsonIgnore
84      public Optional<Pointer> getDiscordChannel() {
85          return getResourcePointer(DISCORD_CHANNEL);
86      }
87  
88      @JsonIgnore
89      public Optional<Pointer> getDiscordGuild() {
90          return getResourcePointer(DISCORD_GUILD);
91      }
92  
93      @JsonIgnore
94      public List<Pointer> getGames() {
95          return getResourcePointers(GAMES);
96      }
97  }