From 5810e85039a29d11a47f11654522ee21fca8a564 Mon Sep 17 00:00:00 2001 From: Gianlu Date: Thu, 28 May 2020 19:20:44 +0200 Subject: [PATCH] Return watermark in CardSet data --- src/main/java/net/socialgamer/cah/Constants.java | 2 ++ .../cah/customsets/CustomCardsService.java | 2 +- .../net/socialgamer/cah/customsets/CustomDeck.java | 13 ++++++++++++- src/main/java/net/socialgamer/cah/data/CardSet.java | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/socialgamer/cah/Constants.java b/src/main/java/net/socialgamer/cah/Constants.java index 89c08a5..a403c5f 100644 --- a/src/main/java/net/socialgamer/cah/Constants.java +++ b/src/main/java/net/socialgamer/cah/Constants.java @@ -664,6 +664,8 @@ public class Constants { CARD_SET_DESCRIPTION("csd"), CARD_SET_NAME("csn"), @DuplicationAllowed + WATERMARK(WhiteCardData.WATERMARK), + @DuplicationAllowed @GoDataType("int") ID(WhiteCardData.ID), @GoDataType("int") diff --git a/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java b/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java index 7413859..181fe17 100644 --- a/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java +++ b/src/main/java/net/socialgamer/cah/customsets/CustomCardsService.java @@ -151,7 +151,7 @@ public class CustomCardsService { } int deckId = deckIdCounter.decrementAndGet(); - final CustomDeck deck = new CustomDeck(deckId, StringEscapeUtils.escapeXml11(name), StringEscapeUtils.escapeXml11(description)); + final CustomDeck deck = new CustomDeck(deckId, StringEscapeUtils.escapeXml11(name), StringEscapeUtils.escapeXml11(watermark), StringEscapeUtils.escapeXml11(description)); // load up the cards final JSONArray blacks = (JSONArray) obj.get("calls"); diff --git a/src/main/java/net/socialgamer/cah/customsets/CustomDeck.java b/src/main/java/net/socialgamer/cah/customsets/CustomDeck.java index 597e5ae..d5b8f65 100644 --- a/src/main/java/net/socialgamer/cah/customsets/CustomDeck.java +++ b/src/main/java/net/socialgamer/cah/customsets/CustomDeck.java @@ -23,22 +23,26 @@ package net.socialgamer.cah.customsets; +import net.socialgamer.cah.Constants; import net.socialgamer.cah.data.CardSet; import java.util.HashSet; +import java.util.Map; import java.util.Set; public class CustomDeck extends CardSet { private final int id; private final String name; + private final String watermark; private final String description; private final Set blackCards = new HashSet<>(); private final Set whiteCards = new HashSet<>(); - public CustomDeck(final int id, final String name, final String description) { + public CustomDeck(final int id, final String name, final String watermark, final String description) { this.id = id; this.name = name; + this.watermark = watermark; this.description = description; if (id >= 0) throw new IllegalArgumentException("Custom deck ID must be negative."); @@ -83,4 +87,11 @@ public class CustomDeck extends CardSet { public Set getWhiteCards() { return whiteCards; } + + @Override + protected Map getCommonClientMetadata() { + Map data = super.getCommonClientMetadata(); + data.put(Constants.CardSetData.WATERMARK, watermark); + return data; + } } diff --git a/src/main/java/net/socialgamer/cah/data/CardSet.java b/src/main/java/net/socialgamer/cah/data/CardSet.java index b2d0445..8aeae0f 100644 --- a/src/main/java/net/socialgamer/cah/data/CardSet.java +++ b/src/main/java/net/socialgamer/cah/data/CardSet.java @@ -37,7 +37,7 @@ public abstract class CardSet { return cardSetData; } - protected final Map getCommonClientMetadata() { + protected Map getCommonClientMetadata() { final Map cardSetData = new HashMap(); cardSetData.put(CardSetData.ID, getId()); cardSetData.put(CardSetData.CARD_SET_NAME, getName());