Commit 2af35b86 authored by Akhmad Fakhoni Listiyan Dede's avatar Akhmad Fakhoni Listiyan Dede
Browse files

Merge branch 'master' of...

Merge branch 'master' of http://gitlab.informatika.org/sinambelajunita/IF3230-Tugas-Besar-Sister-2015
parents a5aa3d35 b28444ed
......@@ -29,14 +29,13 @@ dist.jar=${dist.dir}/GrandQuest.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.json-simple-1.1.1.jar-1=D:\\AFIK\\Project\\GrandQuest Sister\\json-simple-1.1.1.jar
file.reference.json-simple-1.1.1.jar=D:\\AFIK\\Project\\GrandQuest Sister\\json-simple-1.1.1.jar
file.reference.org.json-20120521.jar=..\\server\\lib\\org.json-20120521.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.org.json-20120521.jar}:\
${libs.absolutelayout.classpath}:\
${file.reference.json-simple-1.1.1.jar-1}
${file.reference.json-simple-1.1.1.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
......
......@@ -318,13 +318,13 @@ public class FindPanel extends javax.swing.JPanel {
private void PilosopherStoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PilosopherStoneActionPerformed
ImageIcon image = new ImageIcon("img/stone.png");
selectedItem.setIcon(image);
item = 5;
item = 9;
}//GEN-LAST:event_PilosopherStoneActionPerformed
private void ManaCrystalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ManaCrystalActionPerformed
ImageIcon image = new ImageIcon("img/mana.png");
selectedItem.setIcon(image);
item = 6;
item = 8;
}//GEN-LAST:event_ManaCrystalActionPerformed
private void LifeElixirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LifeElixirActionPerformed
......@@ -336,13 +336,13 @@ public class FindPanel extends javax.swing.JPanel {
private void GemsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GemsActionPerformed
ImageIcon image = new ImageIcon("img/gems.png");
selectedItem.setIcon(image);
item = 8;
item = 6;
}//GEN-LAST:event_GemsActionPerformed
private void IncenseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IncenseActionPerformed
ImageIcon image = new ImageIcon("img/incense.png");
selectedItem.setIcon(image);
item = 9;
item = 5;
}//GEN-LAST:event_IncenseActionPerformed
private void findButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findButtonActionPerformed
......
......@@ -21,16 +21,6 @@ public class LoginPanel extends javax.swing.JPanel {
* Creates new form LoginPanel
*/
public LoginPanel() {
// GrandQuest.host = "192.168.43.249";
// GrandQuest.port = 6789;
GrandQuest.host = "localhost";
GrandQuest.port = 8080;
// GrandQuest.host = "167.205.32.46";
// GrandQuest.port = 8025;
// GrandQuest.host = "localhost";
// GrandQuest.port = 8080;
// GrandQuest.host = "167.205.88.51";
// GrandQuest.port = 6789;
gq = new GrandQuest();
initComponents();
}
......@@ -178,8 +168,10 @@ public class LoginPanel extends javax.swing.JPanel {
}//GEN-LAST:event_usernameFormActionPerformed
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButtonActionPerformed
GrandQuest.host = ipaddressForm.getText();
GrandQuest.port = Integer.valueOf(portForm.getText());
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.loginJSON("abcdef", "abcdef").toString();
String sentence = Request.loginJSON(usernameForm.getText(), Request.encryptToMD5(String.valueOf(passwordForm.getPassword()))).toString();
Request.responseHandler(Request.send(sentence));
} else{
JOptionPane.showMessageDialog(null, "Can't Connect to the Server!", "Information", JOptionPane.ERROR_MESSAGE);
......@@ -198,7 +190,7 @@ public class LoginPanel extends javax.swing.JPanel {
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.signUp(usernameForm.getText(),String.valueOf(passwordForm.getPassword())).toString();
String sentence = Request.signUp(usernameForm.getText(),Request.encryptToMD5(String.valueOf(passwordForm.getPassword()))).toString();
Request.responseHandler(Request.send(sentence));
}
......
......@@ -34,12 +34,6 @@ public class TradePanel extends javax.swing.JPanel {
public TradePanel() {
gq = new GrandQuest();
offers = parseOffer(GrandQuest.offers);
for (String[] a : offers) {
for (String b : a) {
System.out.print(b + " ");
}
System.out.println(" ");
}
initComponents();
initTable();
}
......
......@@ -19,8 +19,8 @@ public class Server {
try
{
int port = 8080;
String username = "abcdef";
String password = "abcdef";
String username = "abcdefgh";
String password = "e8dc4081b13434b45189a720b77b6818";
Random rand = new Random(); // untuk random posisi awal player
......
......@@ -12,6 +12,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
......@@ -442,13 +444,36 @@ public class Request {
return null;
}
public static void main(String argv[]) throws Exception{
if(connectToServer("localhost", 8080)){
String sentence = loginJSON("abc", "def").toString();
responseHandler(send(sentence));
/**
* method used to encrypt user data (password) before send it to the server
* @param str
* @return
*/
public static String encryptToMD5(String str) {
MessageDigest digester;
StringBuffer hexString = null;
try {
digester = MessageDigest.getInstance("MD5");
if (str == null || str.length() == 0) {
return null;
}
digester.update(str.getBytes());
byte[] hash = digester.digest();
hexString = new StringBuffer();
for (int i = 0; i < hash.length; i++) {
if ((0xff & hash[i]) < 0x10) {
hexString.append("0").append(Integer.toHexString((0xFF & hash[i])));
}
else {
hexString.append(Integer.toHexString(0xFF & hash[i]));
}
}
} catch (NoSuchAlgorithmException ex) {
System.err.println(ex);
}
System.out.println("respon status: " + findInResponses("status"));
System.out.println("respon description: " + findInResponses("description"));
return hexString.toString();
}
}
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