Commit 8188d806 authored by Khoirunnisa Afifah's avatar Khoirunnisa Afifah
Browse files

edit find

parent bc8e9e04
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
package GUI; package GUI;
import Request.Request;
import grandquest.GrandQuest; import grandquest.GrandQuest;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/** /**
* *
...@@ -15,7 +17,7 @@ import javax.swing.ImageIcon; ...@@ -15,7 +17,7 @@ import javax.swing.ImageIcon;
*/ */
public class FindPanel extends javax.swing.JPanel { public class FindPanel extends javax.swing.JPanel {
GrandQuest gq; GrandQuest gq;
int item; int item = 0;
/** /**
* Creates new form FindPanel * Creates new form FindPanel
...@@ -292,59 +294,79 @@ public class FindPanel extends javax.swing.JPanel { ...@@ -292,59 +294,79 @@ public class FindPanel extends javax.swing.JPanel {
private void HerbsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HerbsActionPerformed private void HerbsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HerbsActionPerformed
ImageIcon image = new ImageIcon("img/herbs.png"); ImageIcon image = new ImageIcon("img/herbs.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 1;
}//GEN-LAST:event_HerbsActionPerformed }//GEN-LAST:event_HerbsActionPerformed
private void ClayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClayActionPerformed private void ClayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClayActionPerformed
ImageIcon image = new ImageIcon("img/clay.png"); ImageIcon image = new ImageIcon("img/clay.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 2;
}//GEN-LAST:event_ClayActionPerformed }//GEN-LAST:event_ClayActionPerformed
private void MineralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MineralActionPerformed private void MineralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MineralActionPerformed
ImageIcon image = new ImageIcon("img/mineral.png"); ImageIcon image = new ImageIcon("img/mineral.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 3;
}//GEN-LAST:event_MineralActionPerformed }//GEN-LAST:event_MineralActionPerformed
private void PotionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PotionActionPerformed private void PotionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PotionActionPerformed
ImageIcon image = new ImageIcon("img/potion.png"); ImageIcon image = new ImageIcon("img/potion.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 4;
}//GEN-LAST:event_PotionActionPerformed }//GEN-LAST:event_PotionActionPerformed
private void PilosopherStoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PilosopherStoneActionPerformed private void PilosopherStoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PilosopherStoneActionPerformed
ImageIcon image = new ImageIcon("img/stone.png"); ImageIcon image = new ImageIcon("img/stone.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 5;
}//GEN-LAST:event_PilosopherStoneActionPerformed }//GEN-LAST:event_PilosopherStoneActionPerformed
private void ManaCrystalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ManaCrystalActionPerformed private void ManaCrystalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ManaCrystalActionPerformed
ImageIcon image = new ImageIcon("img/mana.png"); ImageIcon image = new ImageIcon("img/mana.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 6;
}//GEN-LAST:event_ManaCrystalActionPerformed }//GEN-LAST:event_ManaCrystalActionPerformed
private void LifeElixirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LifeElixirActionPerformed private void LifeElixirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LifeElixirActionPerformed
ImageIcon image = new ImageIcon("img/life.png"); ImageIcon image = new ImageIcon("img/life.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 7;
}//GEN-LAST:event_LifeElixirActionPerformed }//GEN-LAST:event_LifeElixirActionPerformed
private void GemsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GemsActionPerformed private void GemsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GemsActionPerformed
ImageIcon image = new ImageIcon("img/gems.png"); ImageIcon image = new ImageIcon("img/gems.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 8;
}//GEN-LAST:event_GemsActionPerformed }//GEN-LAST:event_GemsActionPerformed
private void IncenseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IncenseActionPerformed private void IncenseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IncenseActionPerformed
ImageIcon image = new ImageIcon("img/incense.png"); ImageIcon image = new ImageIcon("img/incense.png");
selectedItem.setIcon(image); selectedItem.setIcon(image);
item = 0; item = 9;
}//GEN-LAST:event_IncenseActionPerformed }//GEN-LAST:event_IncenseActionPerformed
private void findButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findButtonActionPerformed private void findButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findButtonActionPerformed
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.sendFind(GrandQuest.token, Integer.toString(item)).toString();
Request.responseHandler(Request.send(sentence));
}
if (Request.serverResponse!=null){
String res = Request.findInResponses("status");
switch(res){
case "ok" :
GrandQuest.offers = Request.findInResponses("offers");
System.out.println(GrandQuest.offers);
break;
default :
JOptionPane.showMessageDialog(null, "Error!", "Error", JOptionPane.ERROR_MESSAGE);
break;
}
GrandQuest.savedPane = this;
//SET TO FIND
gq.retTrade();
}
}//GEN-LAST:event_findButtonActionPerformed }//GEN-LAST:event_findButtonActionPerformed
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
......
...@@ -256,23 +256,6 @@ public class Request { ...@@ -256,23 +256,6 @@ public class Request {
return null; return null;
} }
/**
* generate JSON Object to find any item in offer menu
* @param item
* @return
*/
public static JSONObject findOffer(String item){
try {
JSONObject jo = new JSONObject();
jo.put("method", "findoffer");
jo.put("item", item);
return jo;
} catch (JSONException ex) {
Logger.getLogger(Request.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
/** /**
* generate JSON Object to accept other people's offer * generate JSON Object to accept other people's offer
...@@ -294,24 +277,6 @@ public class Request { ...@@ -294,24 +277,6 @@ public class Request {
return null; return null;
} }
/**
* generate JSON Object to accept people's offer request
* @param token
* @param offertoken
* @return
*/
public static JSONObject accept(String token, String offertoken){
try {
JSONObject jo = new JSONObject();
jo.put("method", "accept");
jo.put("offer_token", offertoken);
return jo;
} catch (JSONException ex) {
Logger.getLogger(Request.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
/** /**
* generate JSON Object to fetch any item from the finished offer * generate JSON Object to fetch any item from the finished offer
......
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