Restored local changes after SSH re-clone
This commit is contained in:
BIN
src/main/.DS_Store
vendored
Normal file
BIN
src/main/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -4,6 +4,7 @@ import Server.*;
|
||||
import Server.Cards.*;
|
||||
import Server.Utils.LoadingCardsException;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -94,12 +95,12 @@ public class Game {
|
||||
* Initial food (rulebook setup step 10):
|
||||
* Slot 1 -> 2 food, slots 2-3 -> 3 food, slots 4-5 -> 4 food.
|
||||
*/
|
||||
public void newGame(String cardsFilePath) {
|
||||
public void newGame(InputStream csvStream) {
|
||||
try {
|
||||
logger.info("STARTING NEW GAME : ", cardsFilePath);
|
||||
logger.info("STARTING NEW GAME");
|
||||
|
||||
CardDeck deck = new CardDeck();
|
||||
deck.setForNPlayer(cardsFilePath, players.size());
|
||||
deck.setForNPlayer(csvStream, players.size());
|
||||
|
||||
gameBoard = new GameBoard(Era.I, deck, players.size());
|
||||
gameBoard.initOfferingTiles(players.size());
|
||||
|
||||
@@ -6,7 +6,10 @@ import Server.Utils.LoadingCardsException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
@@ -25,7 +28,7 @@ public class CardDeck {
|
||||
return buildingDeck.get(era);
|
||||
}
|
||||
|
||||
public void setForNPlayer(String path, int n) throws LoadingCardsException {
|
||||
public void setForNPlayerPathTest(String path, int n) throws LoadingCardsException {
|
||||
|
||||
List<Card> tribe = new ArrayList<>();
|
||||
List<Card> building = new ArrayList<>();
|
||||
@@ -70,6 +73,52 @@ public class CardDeck {
|
||||
this.buildingDeck = building.stream().collect(Collectors.groupingBy(Card::getEra));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setForNPlayer(InputStream csvStream, int n) throws LoadingCardsException {
|
||||
List<Card> tribe = new ArrayList<>();
|
||||
List<Card> building = new ArrayList<>();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(csvStream))) {
|
||||
String row;
|
||||
int p = 0;
|
||||
while ((row = reader.readLine()) != null) {
|
||||
String cleanRow = row.trim();
|
||||
String[] fields = cleanRow.split(";");
|
||||
|
||||
logger.info((p++) + " ROW " + row);
|
||||
|
||||
switch (fields[0]) {
|
||||
case "C":
|
||||
tribe.add(CharacterCard.parsRow(row));
|
||||
break;
|
||||
case "E":
|
||||
tribe.add(EventCard.parsRow(row));
|
||||
break;
|
||||
case "B":
|
||||
building.add(BuildingCard.parsRow(row));
|
||||
break;
|
||||
default:
|
||||
throw new LoadingCardsException("Content not supported");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error(e);
|
||||
throw new LoadingCardsException("file not found");
|
||||
}
|
||||
|
||||
building = CardDeck.shuffle(building);
|
||||
|
||||
this.tribeDeck = tribe.stream()
|
||||
.filter(card -> card.getForMinPlayer() <= n)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
this.tribeDeck = CardDeck.shuffle(this.tribeDeck);
|
||||
this.buildingDeck = building.stream().collect(Collectors.groupingBy(Card::getEra));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Card> drawTribe(int n) {
|
||||
List<Card> cards = new ArrayList<>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
||||
@@ -33,6 +33,8 @@ import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -69,29 +71,26 @@ public class DeckGridAppFX extends Application {
|
||||
players.add(new Player("Blue", TotemColor.BLUE));
|
||||
//players.add(new Player("Purple", TotemColor.PURPLE));
|
||||
players.add(new Player("Red", TotemColor.RED));
|
||||
|
||||
//players.add(new Player("Green", TotemColor.GREEN));
|
||||
|
||||
Game game = new Game(players);
|
||||
String fileCards="/home/lorenzo/dev/Mesos2/src/main/resources/files/cards.csv";
|
||||
String fileCardsImgFront="/home/lorenzo/dev/Mesos2/src/main/resources/files/Cards_total_front_PROMO.pdf";
|
||||
String fileCardsImgCover="/home/lorenzo/dev/Mesos2/src/main/resources/files/Cards_total_back_PROMO.pdf";
|
||||
|
||||
InputStream frontStream = getClass().getResourceAsStream("/files/Cards_total_front_PROMO.pdf");
|
||||
InputStream backStream = getClass().getResourceAsStream("/files/Cards_total_back_PROMO.pdf");
|
||||
InputStream csvStream = getClass().getResourceAsStream("/files/cards.csv");
|
||||
|
||||
try {
|
||||
|
||||
File fileFront = new File(fileCardsImgFront);
|
||||
File fileBack = new File(fileCardsImgCover);
|
||||
|
||||
documentFront = PDDocument.load(fileFront);
|
||||
documentFront = PDDocument.load(frontStream);
|
||||
pdfRendererFront = new PDFRenderer(documentFront);
|
||||
documentBack = PDDocument.load(fileBack);
|
||||
|
||||
documentBack = PDDocument.load(backStream);
|
||||
pdfRendererBack = new PDFRenderer(documentBack);
|
||||
|
||||
} catch ( IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
game.newGame(fileCards);
|
||||
//File fileCsv = new File(getClass().getResource("/files/cards.csv").toURI());
|
||||
game.newGame(csvStream);
|
||||
|
||||
game.setEventListener(notification -> {
|
||||
Platform.runLater(() -> {
|
||||
@@ -327,9 +326,9 @@ public class DeckGridAppFX extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
private StackPane drawTurnTileCardImageWithPlayers(String imagePath, int height, Player[] players) {
|
||||
private StackPane drawTurnTileCardImageWithPlayers(InputStream imgStream, int height, Player[] players) {
|
||||
try {
|
||||
Image fxImage = new Image("file:" + imagePath);
|
||||
Image fxImage = new Image(imgStream);
|
||||
|
||||
ImageView imageView = new ImageView(fxImage);
|
||||
imageView.setFitHeight(height);
|
||||
@@ -366,7 +365,7 @@ public class DeckGridAppFX extends Application {
|
||||
return stack;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Errore caricamento immagine {}", imagePath, e);
|
||||
logger.error("Errore caricamento immagine {}", imgStream, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -397,8 +396,9 @@ public class DeckGridAppFX extends Application {
|
||||
row.getChildren().add(turnBox);
|
||||
|
||||
// --- TURN TILE ---
|
||||
|
||||
StackPane pane = drawTurnTileCardImageWithPlayers(
|
||||
"/home/lorenzo/dev/Mesos2/src/main/resources/files/Start_" + n + "P.png",
|
||||
getClass().getResourceAsStream("/files/Start_" + n + "P.png"),
|
||||
IMG_HEIGHT,
|
||||
game.getGameBoard().getTurnTile().getPositions()
|
||||
);
|
||||
@@ -409,10 +409,9 @@ public class DeckGridAppFX extends Application {
|
||||
for (OfferingTile offering : game.getGameBoard().getOfferingTiles()) {
|
||||
Player occupant = offering.getOccupant();
|
||||
StackPane offPane =drawOfferingCardImageWithTotem(
|
||||
"/home/lorenzo/dev/Mesos2/src/main/resources/files/offering" + offering.getLetter() + ".png",
|
||||
getClass().getResourceAsStream("/files/offering" + offering.getLetter() + ".png"),
|
||||
IMG_HEIGHT,
|
||||
occupant, game, offering);
|
||||
|
||||
if (offPane != null) {
|
||||
row.getChildren().add(offPane);
|
||||
}
|
||||
@@ -550,9 +549,10 @@ public class DeckGridAppFX extends Application {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private StackPane drawOfferingCardImageWithTotem(String imagePath, int height, Player occupant, Game game, OfferingTile offering) {
|
||||
|
||||
private StackPane drawOfferingCardImageWithTotem(InputStream imagePath, int height, Player occupant, Game game, OfferingTile offering) {
|
||||
try {
|
||||
Image fxImage = new Image("file:" + imagePath);
|
||||
Image fxImage = new Image(imagePath);
|
||||
|
||||
ImageView imageView = new ImageView(fxImage);
|
||||
imageView.setFitHeight(height);
|
||||
@@ -588,10 +588,9 @@ public class DeckGridAppFX extends Application {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ImageView createCardImage(String imagePath, int height) {
|
||||
private ImageView createCardImage(InputStream imagePath, int height) {
|
||||
try {
|
||||
Image fxImage = new Image("file:" + imagePath);
|
||||
Image fxImage = new Image(imagePath);
|
||||
|
||||
ImageView imageView = new ImageView(fxImage);
|
||||
imageView.setFitHeight(height);
|
||||
@@ -604,6 +603,7 @@ public class DeckGridAppFX extends Application {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void showPopup(String message) {
|
||||
Platform.runLater(() -> {
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
@@ -70,25 +71,24 @@ public class DeckGridAppFX extends Application {
|
||||
players.add(new Player("Gino", TotemColor.GREEN));
|
||||
|
||||
Game game = new Game(players);
|
||||
String fileCards="/home/lorenzo/dev/Mesos2/src/main/resources/files/cards.csv";
|
||||
String fileCardsImgFront="/home/lorenzo/dev/Mesos2/src/main/resources/files/Cards_total_front_PROMO.pdf";
|
||||
String fileCardsImgCover="/home/lorenzo/dev/Mesos2/src/main/resources/files/Cards_total_back_PROMO.pdf";
|
||||
|
||||
InputStream frontStream = getClass().getResourceAsStream("/files/Cards_total_front_PROMO.pdf");
|
||||
InputStream backStream = getClass().getResourceAsStream("/files/Cards_total_back_PROMO.pdf");
|
||||
InputStream csvStream = getClass().getResourceAsStream("/files/cards.csv");
|
||||
|
||||
try {
|
||||
|
||||
File fileFront = new File(fileCardsImgFront);
|
||||
File fileBack = new File(fileCardsImgCover);
|
||||
|
||||
documentFront = PDDocument.load(fileFront);
|
||||
documentFront = PDDocument.load(frontStream);
|
||||
pdfRendererFront = new PDFRenderer(documentFront);
|
||||
documentBack = PDDocument.load(fileBack);
|
||||
|
||||
documentBack = PDDocument.load(backStream);
|
||||
pdfRendererBack = new PDFRenderer(documentBack);
|
||||
|
||||
} catch ( IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
//File fileCsv = new File(getClass().getResource("/files/cards.csv").toURI());
|
||||
game.newGame(csvStream);
|
||||
|
||||
game.newGame(fileCards);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,7 +50,8 @@ public class DeckViewerFX extends Application {
|
||||
players.add(new Player("Gino", TotemColor.GREEN));
|
||||
|
||||
Game game = new Game(players);
|
||||
game.newGame("/home/lorenzo/dev/Mesos2/src/main/resources/files/cards.csv");
|
||||
InputStream csvStream = getClass().getResourceAsStream("/files/cards.csv");
|
||||
game.newGame(csvStream);
|
||||
|
||||
primaryStage.setTitle("Visualizzatore Mazzo di Carte (PDF)");
|
||||
|
||||
|
||||
BIN
src/main/resources/.DS_Store
vendored
Normal file
BIN
src/main/resources/.DS_Store
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user