Commit 532b0ddd authored by Khoirunnisa Afifah's avatar Khoirunnisa Afifah
Browse files

mixitem

parent b28444ed
......@@ -146,8 +146,10 @@ public class MapPanel extends javax.swing.JPanel {
switch(res){
case "ok" :
item = Item.getItemName(Integer.parseInt(Request.findInResponses("item")));
JOptionPane.showMessageDialog(null, "Congratulation, you've earned "+ item,"Information", JOptionPane.PLAIN_MESSAGE);
//PANEL MIXEDITEM
MixedItem mi = new MixedItem();
mi.MixedItem.setIcon(new ImageIcon(getClass().getResource(Item.getItemIcon(Integer.parseInt(Request.findInResponses("item"))))));
mi.MixedItem.setText("");
mi.ItemName.setText(item);
break;
case "fail" :
JOptionPane.showMessageDialog(null, "Failed! \n"+Request.findInResponses("description"), "Information", JOptionPane.ERROR_MESSAGE);
......
......@@ -112,7 +112,7 @@ public class TradePanel extends javax.swing.JPanel {
}
}
} // end of 'Fetch' case
else{
else if (Offer.getValueAt(modelRow, 4)=="Cancel"){
String offer_token = Offer.getValueAt(modelRow, 5).toString();
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.fetchItem(GrandQuest.token,offer_token).toString();
......@@ -134,6 +134,29 @@ public class TradePanel extends javax.swing.JPanel {
}
}
}
else {
String offer_token = Offer.getValueAt(modelRow, 5).toString();
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.sendAccept(GrandQuest.token,offer_token).toString();
Request.responseHandler(Request.send(sentence));
}
if (Request.serverResponse!=null){
String res = Request.findInResponses("status");
switch(res){
case "ok" :
JOptionPane.showMessageDialog(null, "Congratulation you've got new item", "Information", JOptionPane.PLAIN_MESSAGE);
break;
case "fail":
JOptionPane.showMessageDialog(null, "Fail getting item\n" + Request.findInResponses("fail"), "Information", JOptionPane.WARNING_MESSAGE);
break;
default :
JOptionPane.showMessageDialog(null, "Error!", "Error", JOptionPane.ERROR_MESSAGE);
break;
}
}
}
}
};
......
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