Commit 5a257e08 authored by Steve Immanuel Harnadi's avatar Steve Immanuel Harnadi
Browse files
parents 70bb0024 954ac266
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.controller;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.json.JSONException;
import org.json.JSONObject;
/**
*
* @author toshibapc
*/
public class ConnectionControler {
private Socket socket;
public static String host;
public static int port;
public ConnectionControler(String host, int port)
{
try {
socket = new Socket(host, port);
} catch (IOException ex) {
Logger.getLogger(ConnectionControler.class.getName()).log(Level.SEVERE, null, ex);
}
}
public Boolean sendMessage(JSONObject jSONObject)
{
try {
DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
PrintWriter printWriter = new PrintWriter(dataOutputStream);
printWriter.println(jSONObject.toString());
printWriter.flush();
return true;
} catch (IOException ex) {
return false;
}
}
public JSONObject receiveMessage ()
{
DataInputStream dataInputStream = null;
try {
dataInputStream = new DataInputStream(socket.getInputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(dataInputStream));
return new JSONObject(br.readLine());
} catch (IOException | JSONException ex) {
Logger.getLogger(ConnectionControler.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
dataInputStream.close();
} catch (IOException ex) {
Logger.getLogger(ConnectionControler.class.getName()).log(Level.SEVERE, null, ex);
}
}
return null;
}
public void closeConnection ()
{
try {
socket.close();
} catch (IOException ex) {
Logger.getLogger(ConnectionControler.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.controller;
/**
*
* @author toshibapc
*/
public class Controller {
public boolean MixItem ()
{
return true;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
/**
*
* @author toshibapc
*/
public class Avatar {
public static int posX, posY;
public static String token;
public static int findItem;
public static String findItemId;
public static long time;
public Avatar()
{
}
/**
* @return the posX
*/
public int getPosX() {
return posX;
}
/**
* @param posX the posX to set
*/
public void setPosX(int posX) {
this.posX = posX;
}
/**
* @return the posY
*/
public int getPosY() {
return posY;
}
/**
* @param posY the posY to set
*/
public void setPosY(int posY) {
this.posY = posY;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author toshibapc
*/
public class Clay {
private int amount;
private JLabel label;
private String offerToken;
public Clay() {
amount = 2;
ImageIcon imageIcon = new ImageIcon("F:\\Tubes Sister\\Clay.PNG");
label = new JLabel(imageIcon);
offerToken="";
}
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* @return the label
*/
public JLabel getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(JLabel label) {
this.label = label;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author toshibapc
*/
public class Gem {
private int amount;
private JLabel label;
private String offerToken;
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
public Gem() {
amount = 3;
ImageIcon imageIcon = new ImageIcon("F:\\Tubes Sister\\Gems.PNG");
label = new JLabel(imageIcon);
offerToken = "";
}
/**
* @return the label
*/
public JLabel getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(JLabel label) {
this.label = label;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author toshibapc
*/
public class Herb {
public Herb() {
amount = 5;
ImageIcon imageIcon = new ImageIcon("F:\\Tubes Sister\\Herbs.PNG");
label = new JLabel(imageIcon);
offerToken = "";
}
private int amount;
private JLabel label;
private String offerToken;
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* @return the label
*/
public JLabel getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(JLabel label) {
this.label = label;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author toshibapc
*/
public class Honey {
public Honey() {
amount = 5;
ImageIcon imageIcon = new ImageIcon("F:\\Tubes Sister\\Honey.PNG");
label = new JLabel(imageIcon);
offerToken = "";
}
private int amount;
private JLabel label;
private String offerToken;
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* @return the label
*/
public JLabel getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(JLabel label) {
this.label = label;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author toshibapc
*/
public class Incense {
public Incense() {
amount = 5;
ImageIcon imageIcon = new ImageIcon("F:\\Tubes Sister\\Incense.PNG");
label = new JLabel(imageIcon);
offerToken = "";
}
private int amount;
private JLabel label;
private String offerToken;
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* @return the label
*/
public JLabel getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(JLabel label) {
this.label = label;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author toshibapc
*/
public class LifeElixir {
public LifeElixir() {
amount = 5;
ImageIcon imageIcon = new ImageIcon("F:\\Tubes Sister\\LifeElixir.PNG");
label = new JLabel(imageIcon);
offerToken = "";
}
private int amount;
private JLabel label;
private String offerToken;
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* @return the label
*/
public JLabel getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(JLabel label) {
this.label = label;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author toshibapc
*/
public class ManaCrystal {
public ManaCrystal() {
amount = 5;
ImageIcon imageIcon = new ImageIcon("F:\\Tubes Sister\\ManaCrystal.PNG");
label = new JLabel(imageIcon);
offerToken = "";
}
private int amount;
private JLabel label;
private String offerToken;
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* @return the label
*/
public JLabel getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(JLabel label) {
this.label = label;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package thealchemist.model;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author toshibapc
*/
public class Mineral {
public Mineral() {
amount = 5;
ImageIcon imageIcon = new ImageIcon("F:\\Tubes Sister\\Mineral.PNG");
label = new JLabel(imageIcon);
offerToken = "";
}
private int amount;
private JLabel label;
private String offerToken;
/**
* @return the amount
*/
public int getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**