Commit 9eeb5ae6 authored by adwisatya's avatar adwisatya
Browse files
parents cbea3610 ee77c18d
......@@ -26,7 +26,7 @@ user.properties.file=C:\\Users\\Muldani\\AppData\\Roaming\\NetBeans\\8.0\\build.
<<<<<<< HEAD
user.properties.file=C:\\Users\\A450LC W8\\AppData\\Roaming\\NetBeans\\8.0.1\\build.properties
=======
user.properties.file=C:\\Users\\adwisatya\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
user.properties.file=C:\\Users\\Muldani\\AppData\\Roaming\\NetBeans\\8.0\\build.properties
>>>>>>> 02323e945e52f7a247d213f954c360232adc5b0e
>>>>>>> 43edd7f388dc28ed09074436ded7167fffce2bcf
>>>>>>> 08b39e9ffc058e8856fd1186a9d3fbe46d951054
......
......@@ -3,6 +3,17 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<<<<<<< HEAD
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/gui/AlcMixItem.java</file>
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/gui/AlcLogon.java</file>
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/gui/AlcMap.java</file>
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/gui/AlcFindItem.java</file>
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/engine/Main.java</file>
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/gui/AlcTradeBox.java</file>
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/gui/AlcItem.java</file>
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/engine/Response.java</file>
<file>file:/F:/z~edo/Kuliah/Semester%206/IF3230%20Sistem%20Paralel%20dan%20Terdistribusi/Tugas%20Akhir/src/client/TheAlchemistClient/src/thealchemist/engine/Connection.java</file>
=======
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/client/TheAlchemistClient/src/thealchemist/gui/AlcOffer.java</file>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/client/TheAlchemistClient/src/thealchemist/gui/AlcItem.java</file>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/client/TheAlchemistClient/src/thealchemist/gui/AlcFindItem.java</file>
......@@ -14,6 +25,7 @@
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/client/TheAlchemistClient/src/thealchemist/gui/AlcLogon.java</file>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/client/TheAlchemistClient/src/thealchemist/gui/AlcMixItem.java</file>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/client/TheAlchemistClient/src/thealchemist/gui/ImagePanel.java</file>
>>>>>>> ab35a18e11b0fab1af378a1ddb185a0c486fc47b
</group>
</open-files>
</project-private>
......@@ -7,7 +7,9 @@ package thealchemist.engine;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
......@@ -28,7 +30,10 @@ import org.json.JSONObject;
public class Connection {
String response;
String request;
private static String URL = "192.168.0.107";
// private static String URL = "167.205.32.46";
// private static int defPort = 8025;
private static String URL = "localhost";
private static int defPort = 6789;
private String token = "kosong";
......@@ -37,13 +42,16 @@ public class Connection {
Socket miniSocket = new Socket(URL,defPort);
JSONObject obj = new JSONObject(JSON);
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(miniSocket.getOutputStream())));
out.println(obj);
out.println();
out.flush();
BufferedReader in = new BufferedReader(new InputStreamReader(miniSocket.getInputStream()));
response = org.apache.commons.io.IOUtils.toString(in);
InputStream dataInputStream = new DataInputStream(miniSocket.getInputStream());
InputStreamReader inputStreamReader = new InputStreamReader(dataInputStream);
BufferedReader in = new BufferedReader(inputStreamReader);
response = in.readLine();
in.close();
return response;
......@@ -73,10 +81,7 @@ public class Connection {
obj.put("username", username);
obj.put("password", toMD5(password));
String hasil = sendRequest(obj.toString());
System.out.println(hasil);
return hasil;
return sendRequest(obj.toString());
}
public String map() throws JSONException, IOException{
......
......@@ -9,6 +9,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.json.JSONException;
import thealchemist.engine.Connection;
import thealchemist.engine.Response;
......@@ -451,15 +452,23 @@ public class AlcFindItem extends javax.swing.JFrame {
}//GEN-LAST:event_btnBackActionPerformed
private void btnFindActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFindActionPerformed
String hasilrespon;
String hasilRespon;
try {
hasilrespon = connection.sendFind(idItem);
if(connection.JSONtoString("status", hasilrespon).equals("ok")){
System.out.println("ok");
}
System.out.println(connection.sendFind(idItem));
hasilRespon = connection.sendFind(idItem);
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
JOptionPane.showMessageDialog(this,
"Benda dapat dicari",
"Informasi",
JOptionPane.INFORMATION_MESSAGE);
dispose();
new AlcTradeItem(connection).setVisible(true);
}
else{
JOptionPane.showMessageDialog(this,
connection.JSONtoString("description", hasilRespon),
"Fail",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcFindItem.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
......
......@@ -11,6 +11,7 @@ import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.json.JSONException;
import thealchemist.engine.Connection;
import thealchemist.engine.Response;
......@@ -170,29 +171,29 @@ public class AlcLogon extends javax.swing.JFrame {
try {
pass = new String(txtPassword.getPassword());
<<<<<<< HEAD
try {
hasilRespon = respon.loginOK(connection.login(txtAccount.getText(), pass));
} catch (IOException ex) {
Logger.getLogger(AlcLogon.class.getName()).log(Level.SEVERE, null, ex);
}
=======
hasilRespon = connection.login(txtAccount.getText(), pass);
>>>>>>> 7644cdc12ce7e4a7eaa9ccb573947bde3d34b96a
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
System.out.println("ok");
JOptionPane.showMessageDialog(this,
"Berhasil Masuk.",
"Informasi",
JOptionPane.INFORMATION_MESSAGE);
connection.setToken(connection.JSONtoString("token", hasilRespon));
// go to map
dispose();
new AlcMap(connection, new Integer(connection.JSONtoString("x", hasilRespon)), new Integer(connection.JSONtoString("y", hasilRespon))).setVisible(true);
}
else if(connection.JSONtoString("status", hasilRespon).equals("fail")){
System.out.println("fail");
JOptionPane.showMessageDialog(this,
connection.JSONtoString("description", hasilRespon),
"Fail",
JOptionPane.WARNING_MESSAGE);
}
else if(connection.JSONtoString("status", hasilRespon).equals("error")){
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
// go to another map
dispose();
new AlcMap(connection, new Integer(connection.JSONtoString("x", hasilRespon)), new Integer(connection.JSONtoString("y", hasilRespon))).setVisible(true);
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(AlcLogon.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
......@@ -223,13 +224,22 @@ public class AlcLogon extends javax.swing.JFrame {
hasilRespon = connection.signUp(txtAccount.getText(), pass);
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
System.out.println("ok");
JOptionPane.showMessageDialog(this,
"Berhasil Mendaftar.",
"Informasi",
JOptionPane.INFORMATION_MESSAGE);
}
else if(connection.JSONtoString("status", hasilRespon).equals("fail")){
System.out.println("fail");
JOptionPane.showMessageDialog(this,
connection.JSONtoString("description", hasilRespon),
"Fail",
JOptionPane.WARNING_MESSAGE);
}
else{
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(AlcLogon.class.getName()).log(Level.SEVERE, null, ex);
......
......@@ -19,6 +19,7 @@ import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.Timer;
import javax.swing.border.Border;
import org.json.JSONException;
......@@ -49,6 +50,8 @@ public class AlcMap extends javax.swing.JFrame {
private int x = 0;
private int y = 0;
private Boolean isBergerak = false;
/**
* Creates new form AlcMap
*/
......@@ -78,6 +81,7 @@ public class AlcMap extends javax.swing.JFrame {
public void cekDate(Date date1, Date date2){
if(date1.compareTo(date2)>0){
initMap();
isBergerak = false;
}
}
......@@ -121,7 +125,6 @@ public class AlcMap extends javax.swing.JFrame {
private void initMap(){
try {
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
System.out.println("ok");
lblMap.setText(connection.JSONtoString("name", hasilRespon));
lblPosition.setText("("+ getPosX() +","+ getPosY() +")");
......@@ -143,7 +146,7 @@ public class AlcMap extends javax.swing.JFrame {
for (int col = 0; col < cols; col++) {
labels[row][col] = new JLabel();
if((row == getPosX()) && (col == getPosY())){
if(dateCurrent.compareTo(dateMove)<0){
if(isBergerak){
labels[row][col].setIcon(new ImageIcon(getClass().getResource("/thealchemist/img/mami_run.gif")));
}
else{
......@@ -380,8 +383,11 @@ public class AlcMap extends javax.swing.JFrame {
Long timeX;
hasilRespon = connection.move(posX, posY);
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
System.out.println("ok");
isBergerak = true;
JOptionPane.showMessageDialog(this,
"Bergerak ke ("+posX+","+posY+")",
"Berhasil",
JOptionPane.INFORMATION_MESSAGE);
timeX = new Long(connection.JSONtoString("time", hasilRespon));
timeX = timeX * 1000;
......@@ -395,14 +401,19 @@ public class AlcMap extends javax.swing.JFrame {
lblTime.setText(dateString+" "+time);
System.out.println(connection.move(posX, posY));
x = posX;
y = posY;
//initMap();
}else if(connection.JSONtoString("status", hasilRespon).equals("fail")){
System.out.println("fail");
JOptionPane.showMessageDialog(this,
connection.JSONtoString("description", hasilRespon),
"Fail",
JOptionPane.WARNING_MESSAGE);
}else if(connection.JSONtoString("status", hasilRespon).equals("error")){
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcMap.class.getName()).log(Level.SEVERE, null, ex);
......@@ -417,11 +428,17 @@ public class AlcMap extends javax.swing.JFrame {
hasilRespon = connection.inventory();
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
JOptionPane.showMessageDialog(this,
"Melihat Inventory",
"Berhasil",
JOptionPane.INFORMATION_MESSAGE);
new AlcItem(connection).setVisible(true);
System.out.println("ok");
}
else{
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcMap.class.getName()).log(Level.SEVERE, null, ex);
......@@ -436,11 +453,17 @@ public class AlcMap extends javax.swing.JFrame {
hasilRespon = connection.inventory();
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
JOptionPane.showMessageDialog(this,
"Masuk Menu Mix Item",
"Berhasil",
JOptionPane.INFORMATION_MESSAGE);
new AlcMixItem(connection).setVisible(true);
System.out.println("ok");
}
else{
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcMap.class.getName()).log(Level.SEVERE, null, ex);
......@@ -463,11 +486,17 @@ public class AlcMap extends javax.swing.JFrame {
hasilRespon = connection.tradeBox();
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
JOptionPane.showMessageDialog(this,
"Melihat Trade Box",
"Berhasil",
JOptionPane.INFORMATION_MESSAGE);
new AlcTradeBox(connection).setVisible(true);
System.out.println("ok");
}
else{
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcMap.class.getName()).log(Level.SEVERE, null, ex);
......@@ -482,14 +511,17 @@ public class AlcMap extends javax.swing.JFrame {
hasilRespon = connection.inventory();
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
JOptionPane.showMessageDialog(this,
"Masuk Ke Menu Offer Item",
"Berhasil",
JOptionPane.INFORMATION_MESSAGE);
new AlcOffer(connection).setVisible(true);
System.out.println("ok");
}
else if(connection.JSONtoString("status", hasilRespon).equals("fail")){
System.out.println("fail");
}
else if(connection.JSONtoString("status", hasilRespon).equals("error")){
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcMap.class.getName()).log(Level.SEVERE, null, ex);
......@@ -504,11 +536,17 @@ public class AlcMap extends javax.swing.JFrame {
hasilRespon = connection.inventory();
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
JOptionPane.showMessageDialog(this,
"Masuk Ke menu Find Item",
"Berhasil",
JOptionPane.INFORMATION_MESSAGE);
new AlcFindItem(connection).setVisible(true);
System.out.println("ok");
}
else{
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcMap.class.getName()).log(Level.SEVERE, null, ex);
......@@ -530,11 +568,21 @@ public class AlcMap extends javax.swing.JFrame {
String hasilRespon;
hasilRespon = connection.field();
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
System.out.println("ok");
JOptionPane.showMessageDialog(this,
"Berhasil didapatkan",
"Informasi",
JOptionPane.INFORMATION_MESSAGE,
connection.idToIcon(connection.JSONtoString("item", hasilRespon)));
}else if(connection.JSONtoString("status", hasilRespon).equals("fail")){
System.out.println("fail");
JOptionPane.showMessageDialog(this,
connection.JSONtoString("description", hasilRespon),
"Fail",
JOptionPane.WARNING_MESSAGE);
}else if(connection.JSONtoString("status", hasilRespon).equals("error")){
System.out.println("error");
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcMap.class.getName()).log(Level.SEVERE, null, ex);
......
......@@ -10,6 +10,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.json.JSONException;
import thealchemist.engine.Connection;
import thealchemist.engine.Response;
......@@ -525,55 +526,28 @@ public class AlcMixItem extends javax.swing.JFrame {
}//GEN-LAST:event_btnBackActionPerformed
private void btnMixActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMixActionPerformed
String hasilrespon;
String hasilRespon;
try {
hasilrespon = connection.mixItem(idItem1, idItem2);
if(connection.JSONtoString("status", hasilrespon).equals("ok")){
System.out.println("ok");
hasilRespon = connection.mixItem(idItem1, idItem2);
if(connection.JSONtoString("status", hasilRespon).equals("ok")){
JOptionPane.showMessageDialog(this,
"Berhasil Di-Mix",
"Informasi",
JOptionPane.INFORMATION_MESSAGE,
connection.idToIcon(connection.JSONtoString("item", hasilRespon)));
dispose();
// if(connection.JSONtoString("item", hasilrespon).equals("1")){
// Integer apa = new Integer(txtCount1.getText());
// apa = apa + 1;
// txtCount1.setText("" + apa);
// }else if(connection.JSONtoString("item", hasilrespon).equals("2")){
// Integer apa = new Integer(txtCount2.getText());
// apa = apa + 1;
// txtCount2.setText("" + apa);
// }else if(connection.JSONtoString("item", hasilrespon).equals("3")){
// Integer apa = new Integer(txtCount2.getText());
// apa = apa + 1;
// txtCount3.setText("" + apa);
// }else if(connection.JSONtoString("item", hasilrespon).equals("4")){
// Integer apa = new Integer(txtCount4.getText());
// apa = apa + 1;
// txtCount4.setText("" + apa);
// }else if(connection.JSONtoString("item", hasilrespon).equals("5")){
// Integer apa = new Integer(txtCount5.getText());
// apa = apa + 1;
// txtCount5.setText("" + apa);
// }else if(connection.JSONtoString("item", hasilrespon).equals("6")){
// Integer apa = new Integer(txtCount6.getText());
// apa = apa + 1;
// txtCount6.setText("" + apa);
// }else if(connection.JSONtoString("item", hasilrespon).equals("7")){
// Integer apa = new Integer(txtCount7.getText());
// apa = apa + 1;
// txtCount7.setText("" + apa);
// }else if(connection.JSONtoString("item", hasilrespon).equals("8")){
// Integer apa = new Integer(txtCount8.getText());
// apa = apa + 1;
// txtCount8.setText("" + apa);
// }else if(connection.JSONtoString("item", hasilrespon).equals("9")){
// Integer apa = new Integer(txtCount9.getText());
// apa = apa + 1;
// txtCount9.setText("" + apa);
// }
}
else if(connection.JSONtoString("fail", hasilrespon).equals("fail")){
System.out.println("fail");
}
else if(connection.JSONtoString("error", hasilrespon).equals("error")){
System.out.println("error");
}
else if(connection.JSONtoString("status", hasilRespon).equals("fail")){
JOptionPane.showMessageDialog(this,
connection.JSONtoString("description", hasilRespon),
"Fail",
JOptionPane.WARNING_MESSAGE);
}
else if(connection.JSONtoString("status", hasilRespon).equals("error")){
JOptionPane.showMessageDialog(this,
"There's something wrong!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
} catch (JSONException ex) {
Logger.getLogger(AlcMixItem.class.getName()).log(Level.SEVERE, null, ex);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment