Skip to content

Commit

Permalink
corrected resource bugs in jar
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasMW committed Mar 3, 2017
1 parent 0e0a468 commit 77d84b4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 5 deletions.
Binary file added src/ObjectiveCard.class
Binary file not shown.
2 changes: 1 addition & 1 deletion src/com/menezesworks/warclient/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Client
public Client(int socketNumber)
{
this.socketNumber = socketNumber;
this.ipLocalhost = "45.55.91.148";
this.ipLocalhost = "127.0.0.1";
}
public void connect(String ip, String identifierName, int colorNum) throws UnknownHostException, IOException
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.puc.rio.inf1636.hglm.war.viewcontroller;
package org.puc.rio.inf1636.hglm.war;

import java.net.URL;

Expand Down
17 changes: 15 additions & 2 deletions src/org/puc/rio/inf1636/hglm/war/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import java.awt.geom.Line2D;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand Down Expand Up @@ -77,8 +80,7 @@ public void setBoundsPoints(List<List<java.lang.Double>> cos) {
public static void loadTerritories(Map map, Deck deck) {
String jsonContent;
try {
jsonContent = readFile("resources/territories.json",
StandardCharsets.UTF_8);
jsonContent = readFileFromUrl(ResourceUtil.getResource("territories.json"));
} catch (IOException e) {
e.printStackTrace();
return;
Expand Down Expand Up @@ -146,6 +148,17 @@ public static ArrayList<Line2D.Double> getLineSegments(GeneralPath p) {
}
return lineSegments;
}
public static String readFileFromUrl(URL url) throws IOException {
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));

String fileString = "";
String inputLine;
while ((inputLine = in.readLine()) != null)
fileString += inputLine;
in.close();
return fileString;
}

public static String readFile(String path, Charset encoding)
throws IOException {
Expand Down
2 changes: 1 addition & 1 deletion src/org/puc/rio/inf1636/hglm/war/WarGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void startMultiplayer(Player player)
this.client = new Client(5507);
try {

client.connect(null, player.getName(),player.getColor().hashCode());
client.connect("45.55.91.148", player.getName(),player.getColor().hashCode());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.puc.rio.inf1636.hglm.war.ResourceUtil;
import org.puc.rio.inf1636.hglm.war.WarGame;
import org.puc.rio.inf1636.hglm.war.WarLogic;
import org.puc.rio.inf1636.hglm.war.model.Territory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.puc.rio.inf1636.hglm.war.ResourceUtil;
import org.puc.rio.inf1636.hglm.war.WarGame;
import org.puc.rio.inf1636.hglm.war.model.Card;
import org.puc.rio.inf1636.hglm.war.model.Player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import org.puc.rio.inf1636.hglm.war.ResourceUtil;
import org.puc.rio.inf1636.hglm.war.Util;
import org.puc.rio.inf1636.hglm.war.WarGame;
import org.puc.rio.inf1636.hglm.war.model.Player;
Expand Down

0 comments on commit 77d84b4

Please sign in to comment.