Improved blueprint json parsing to support multiple home sites on allies.
This commit is contained in:
@@ -6,14 +6,18 @@ import com.gempukku.lotro.cards.build.FieldProcessor;
|
||||
import com.gempukku.lotro.cards.build.InvalidCardDefinitionException;
|
||||
import com.gempukku.lotro.common.SitesBlock;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AllyHomeFieldProcessor implements FieldProcessor {
|
||||
@Override
|
||||
public void processField(String key, Object value, BuiltLotroCardBlueprint blueprint, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||
final String allyHome = FieldUtils.getString(value, "allyHome");
|
||||
final String[] allyHomeSplit = allyHome.split(",", 2);
|
||||
final String[] allyHomeSplit = allyHome.split(",", 4);
|
||||
SitesBlock sitesBlock = Enum.valueOf(SitesBlock.class, allyHomeSplit[0].toUpperCase().replace(' ', '_'));
|
||||
final int number = Integer.parseInt(allyHomeSplit[1]);
|
||||
|
||||
blueprint.setAllyHomeSites(sitesBlock, new int[]{number});
|
||||
String[] sites = Arrays.copyOfRange(allyHomeSplit, 1, allyHomeSplit.length);
|
||||
int[] numbers = Arrays.stream(sites).mapToInt(Integer::parseInt).toArray();
|
||||
|
||||
blueprint.setAllyHomeSites(sitesBlock, numbers);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user