-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
222 changed files
with
851 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server; | ||
|
||
public class BackToMenu extends Exception { | ||
public BackToMenu() { | ||
super(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package server; | ||
|
||
import server.menus.Menu; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
import java.net.Socket; | ||
|
||
public class ClientThread extends Thread { | ||
Socket socket; | ||
DataInputStream dataInputStream; | ||
DataOutputStream dataOutputStream; | ||
|
||
public ClientThread(Socket socket) { | ||
try { | ||
this.socket = socket; | ||
dataInputStream = new DataInputStream(socket.getInputStream()); | ||
dataOutputStream = new DataOutputStream(socket.getOutputStream()); | ||
} catch (IOException ignored) { | ||
|
||
} | ||
} | ||
|
||
@Override | ||
public void run() { | ||
Menu menu = new Menu(); | ||
try { | ||
menu.run(dataInputStream, dataOutputStream); | ||
} catch (IOException e) { | ||
System.out.println("Caught an error!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package server; | ||
|
||
import server.ClientThread; | ||
|
||
import java.io.IOException; | ||
import java.net.ServerSocket; | ||
import java.net.Socket; | ||
|
||
public class ServerClass { | ||
public static void main(String[] args) { | ||
try { | ||
ServerSocket server = new ServerSocket(7776); | ||
while (true) { | ||
Socket socket = server.accept(); | ||
new ClientThread(socket).start(); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package server.controller; | ||
//TODO THERE ARE MANY THINGS TO HANDLE! | ||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.google.gson.reflect.TypeToken; | ||
import server.model.User; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.lang.reflect.Type; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
|
||
public class FileHandler { | ||
public static void loadThings() { | ||
// CardLoader.loadCsv(); | ||
loadUsers(); | ||
// loadAssets(); | ||
} | ||
|
||
// private static void loadAssets() { | ||
// PreCard.setPictures(); | ||
// Wallpaper.setAllWallpapers(); | ||
// DeckImageButton.setDeckImages(); | ||
// | ||
//// setCurtainPictures("gifs/out"); | ||
//// Reader.figureCatalog(new String[]{"Items/Coins/Bronze/with-star"}); | ||
// } | ||
|
||
// private static void setCurtainPictures(String folderPath) { | ||
// Reader.figureCatalog(new String[]{folderPath}); | ||
// } | ||
|
||
private static void loadUsers() { | ||
try { | ||
|
||
Gson gsonExt = null; | ||
{ | ||
GsonBuilder builder = new GsonBuilder(); | ||
builder.registerTypeAdapter(PreCard.class, new PreCardAdapter()); | ||
gsonExt = builder.create(); | ||
} | ||
String json = new String(Files.readAllBytes(Paths.get("users.json"))); | ||
Type type = new TypeToken<ArrayList<User>>() { | ||
}.getType(); | ||
User.setAllUsers(gsonExt.fromJson(json, type)); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static void saveUsers() { | ||
try { | ||
Gson gsonExt = null; | ||
{ | ||
GsonBuilder builder = new GsonBuilder(); | ||
builder.registerTypeAdapter(PreCard.class, new PreCardAdapter()); | ||
gsonExt = builder.create(); | ||
} | ||
FileWriter fileWriter = new FileWriter("users.json"); | ||
fileWriter.write(gsonExt.toJson(User.getAllUsers())); | ||
fileWriter.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class ActivateEffectNotSpell extends Exception { | ||
public ActivateEffectNotSpell() { | ||
super("Activate effect is only for spell cards."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class AlreadyActivatedEffect extends Exception { | ||
public AlreadyActivatedEffect() { | ||
super("You have already activated this card"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class AlreadyDoneAction extends Exception { | ||
public AlreadyDoneAction(String action) { | ||
super("You have already " + action + " on this turn"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package server.exceptions; | ||
|
||
public class AlreadyExistingError extends MyException{ | ||
|
||
public AlreadyExistingError(String type, String subType, String name) { | ||
super(String.format("%s with %s %s already exists", type, subType, name)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class AlreadyInWantedPosition extends Exception { | ||
public AlreadyInWantedPosition() { | ||
super("this card is already in the wanted position"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package server.exceptions; | ||
|
||
|
||
public class BeingFull extends Exception{ | ||
public BeingFull(String name) { | ||
super(String.format("%s is full", name)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class ButtonCantDoAction extends Exception { | ||
public ButtonCantDoAction() { | ||
super("this button is not designed for this action"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class CantAttackDirectlyException extends Exception { | ||
public CantAttackDirectlyException() { | ||
super("you can’t attack the opponent directly"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class CantDoActionWithCard extends Exception { | ||
public CantDoActionWithCard(String action) { | ||
super("You can’t " + action + " this card"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package server.exceptions; | ||
|
||
public class CardAttackedBeforeExeption extends Exception { | ||
public CardAttackedBeforeExeption() { | ||
super("This card already attacked"); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class CardCantAttack extends Exception { | ||
public CardCantAttack() { | ||
super("you can’t attack with this card"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class CardCreatorException extends Exception { | ||
public CardCreatorException(String s) { | ||
super(s); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class EmptyFieldException extends Exception { | ||
public EmptyFieldException() { | ||
super("you have at least one empty field"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package server.exceptions; | ||
|
||
public class EqualPasswordException extends Exception{ | ||
|
||
public EqualPasswordException() { | ||
super("please enter a new password"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class InvalidCommand extends Exception { | ||
public InvalidCommand() { | ||
super("invalid command"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class InvalidDeck extends Exception { | ||
public InvalidDeck(String username) { | ||
super(username + "’s deck is invalid"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class InvalidName extends Exception { | ||
public InvalidName(String group, String name) { | ||
super("There is no " + group + " with this " + name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class InvalidRitualPreparations extends Exception { | ||
public InvalidRitualPreparations() { | ||
super("there is no way you could ritual summon a monster"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class InvalidSelection extends Exception { | ||
public InvalidSelection() { | ||
super("invalid selection"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class InvalidThing extends Exception { | ||
public InvalidThing(String thing) { | ||
super(thing + " is invalid!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class InvalidTributeAddress extends Exception { | ||
public InvalidTributeAddress() { | ||
super("there no monsters on this address"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class LoginError extends Exception { | ||
public LoginError() { | ||
super("Username and password didn't match!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class MenuNavigationError extends Exception { | ||
public MenuNavigationError() { | ||
super("menu navigation is not possible"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package server.exceptions; | ||
|
||
public class MyException extends Exception { | ||
public MyException() { | ||
super(); | ||
} | ||
|
||
public MyException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class NeedToLogin extends Exception { | ||
public NeedToLogin() { | ||
super("please login first"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class NoActiveDeck extends Exception { | ||
public NoActiveDeck(String username) { | ||
super(username + " has no active deck"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class NoCardFound extends Exception { | ||
public NoCardFound() { | ||
super("no card found in the given position"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class NoCardToAttack extends Exception { | ||
public NoCardToAttack() { | ||
super("there is no card to attack here"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class NoSelectedCard extends Exception { | ||
public NoSelectedCard() { | ||
super("no card is selected"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class NotAppropriateCard extends Exception { | ||
public NotAppropriateCard(String cardType) { | ||
super(String.format("only %s cards can be selected!", cardType)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class NotCorrectDeck extends Exception{ | ||
public NotCorrectDeck(boolean side) { | ||
super("this card is not slected from the " + (side?"side" : "main") + " deck"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package server.exceptions; | ||
|
||
public class NotEnoughMoney extends Exception { | ||
public NotEnoughMoney() { | ||
super("you don't have enough money!"); | ||
} | ||
} |
Oops, something went wrong.