@@ -0,0 +1,2576 @@
+package org.sillylossy.games.common;%0A%0Aimport org.sillylossy.games.common.game.CardGame;%0Aimport org.sillylossy.games.common.game.GameController;%0Aimport org.sillylossy.games.common.ui.GameInterface;%0Aimport org.sillylossy.games.common.util.FileSerializer;%0A%0Aimport java.awt.*;%0A%0A/**%0A * Contains program entry point and some basic logic.%0A */%0Apublic class Main %7B%0A%0A    /**%0A     * Path to the file from where game data should be read / written to.%0A     */%0A    public static final String FILE_DATA = %22data.bin%22;%0A%0A    /**%0A     * Reference to a game controller assigned to an application.%0A     */%0A    private static GameController controller;%0A%0A    /**%0A     * Reference to a GUI instance assigned to an application.%0A     */%0A    private static GameInterface ui;%0A%0A    /**%0A     * Current game instance.%0A     */%0A    private static CardGame gameInstance;%0A%0A    /**%0A     * Gets a reference to a game controller.%0A     */%0A    public static GameController getGameController() %7B%0A        return controller;%0A    %7D%0A%0A    /**%0A     * Gets a reference to a game instance.%0A     */%0A    public static CardGame getGameInstance() %7B%0A        return gameInstance;%0A    %7D%0A%0A    /**%0A     * Sets a game instance with value from param.%0A     */%0A    public static void setGameInstance(CardGame gameInstance) %7B%0A        Main.gameInstance = gameInstance;%0A    %7D%0A%0A    /**%0A     * Gets a reference to a game user interface assigned to a application instance.%0A     *%0A     * @return a reference to a game user interface%0A     */%0A    public static GameInterface getUI() %7B%0A        return ui;%0A    %7D%0A%0A    /**%0A     * A program's entry point. This method loads / creates a game controller and constructs a GUI.%0A     *%0A     * @param args command line args array%0A     */%0A    public static void main(String%5B%5D args) %7B%0A        EventQueue.invokeLater(() -%3E %7B%0A            try %7B%0A                controller = loadData();%0A                ui = new GameInterface();%0A            %7D catch (Exception e) %7B%0A                e.printStackTrace();%0A            %7D%0A        %7D);%0A    %7D%0A%0A    /**%0A     * Saves game data to a file. Runs in a separate thread.%0A     */%0A    public static void saveData() %7B%0A        new Thread(() -%3E %7B%0A            try %7B%0A                FileSerializer.serialize(controller);%0A            %7D catch (Exception e) %7B%0A                e.printStackTrace();%0A            %7D%0A        %7D).start();%0A    %7D%0A%0A    /**%0A     * Loads game data from a file.%0A     */%0A    private static GameController loadData() %7B%0A        try %7B%0A            return FileSerializer.deserialize();%0A        %7D catch (Exception e) %7B%0A            return new GameController();%0A        %7D%0A    %7D%0A%7D%0A

add main