Commit 6c71e43a authored by adwisatya's avatar adwisatya
Browse files

Update SQL

parent 02323e94
-- phpMyAdmin SQL Dump
-- version 4.1.6
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Apr 25, 2015 at 03:37 AM
-- Server version: 5.6.16
-- PHP Version: 5.5.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `the_alchemist`
--
-- --------------------------------------------------------
--
-- Table structure for table `inventory`
--
CREATE TABLE IF NOT EXISTS `inventory` (
`token` varchar(255) NOT NULL,
`item1` int(11) NOT NULL,
`item2` int(11) NOT NULL,
`item3` int(11) NOT NULL,
`item4` int(11) NOT NULL,
`item5` int(11) NOT NULL,
`item6` int(11) NOT NULL,
`item7` int(11) NOT NULL,
`item8` int(11) NOT NULL,
`item9` int(11) NOT NULL,
`item10` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `offers`
--
CREATE TABLE IF NOT EXISTS `offers` (
`id_offer` int(11) NOT NULL AUTO_INCREMENT,
`token` varchar(255) NOT NULL,
`offered_item` int(11) NOT NULL,
`n1` int(11) NOT NULL,
`demanded_item` int(11) NOT NULL,
`n2` int(11) NOT NULL,
`available` int(11) NOT NULL,
`offer_token` varchar(255) NOT NULL,
PRIMARY KEY (`id_offer`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id_user` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`token` varchar(255) NOT NULL,
`x` int(11) NOT NULL,
`y` int(11) NOT NULL,
`item` varchar(255) NOT NULL,
PRIMARY KEY (`id_user`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-- phpMyAdmin SQL Dump
-- version 4.2.11
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Apr 26, 2015 at 11:26 AM
-- Server version: 5.6.21
-- PHP Version: 5.6.3
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `the_alchemist`
--
-- --------------------------------------------------------
--
-- Table structure for table `inventory`
--
CREATE TABLE IF NOT EXISTS `inventory` (
`token` varchar(32) NOT NULL,
`item1` int(2) NOT NULL DEFAULT '0',
`item2` int(2) NOT NULL DEFAULT '0',
`item3` int(2) NOT NULL DEFAULT '0',
`item4` int(2) NOT NULL DEFAULT '0',
`item5` int(2) NOT NULL DEFAULT '0',
`item6` int(2) NOT NULL DEFAULT '0',
`item7` int(2) NOT NULL DEFAULT '0',
`item8` int(2) NOT NULL DEFAULT '0',
`item9` int(2) NOT NULL DEFAULT '0',
`item0` int(2) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `inventory`
--
INSERT INTO `inventory` (`token`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `item9`, `item0`) VALUES
('76aafe92b629d489996f7a1357005d33', 0, 0, 2, 1, 0, 0, 0, 0, 0, 0);
-- --------------------------------------------------------
--
-- Table structure for table `map`
--
CREATE TABLE IF NOT EXISTS `map` (
`width` int(1) NOT NULL,
`height` int(1) NOT NULL,
`description` text NOT NULL,
`nama` varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `map`
--
INSERT INTO `map` (`width`, `height`, `description`, `nama`) VALUES
(4, 4, '{"R11":2,"R12":0,"R22":1}', 'sekre1');
-- --------------------------------------------------------
--
-- Table structure for table `offers`
--
CREATE TABLE IF NOT EXISTS `offers` (
`id_offer` int(11) NOT NULL,
`token` varchar(32) NOT NULL,
`offered_item` int(11) NOT NULL,
`n1` int(11) NOT NULL,
`demanded_item` int(11) NOT NULL,
`n2` int(11) NOT NULL,
`available` tinyint(1) NOT NULL DEFAULT '1',
`offer_token` varchar(32) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `offers`
--
INSERT INTO `offers` (`id_offer`, `token`, `offered_item`, `n1`, `demanded_item`, `n2`, `available`, `offer_token`) VALUES
(1, '47af9eb308ce2fc95bcc088add67b794', 0, 3, 1, 3, 0, '47af9eb308ce2fc95bcc088add67b79a'),
(2, '47af9eb308ce2fc95bcc088add67b749', 0, 3, 1, 3, 1, '47af9eb308ce2fc95bcc088add67b795');
-- --------------------------------------------------------
--
-- Table structure for table `servers`
--
CREATE TABLE IF NOT EXISTS `servers` (
`ip` varchar(15) NOT NULL,
`port` int(4) NOT NULL,
`status` int(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `servers`
--
INSERT INTO `servers` (`ip`, `port`, `status`) VALUES
('127.0.0.1', 6789, 1),
('localhost', 6789, 1);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`username` varchar(32) NOT NULL,
`password` varchar(32) NOT NULL,
`x` int(11) NOT NULL DEFAULT '0',
`y` int(11) NOT NULL DEFAULT '0',
`items` text,
`token` varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`username`, `password`, `x`, `y`, `items`, `token`) VALUES
('adswisatya1d', 'adwisatya', 2, 1, NULL, 'f517114901e23461b1dcffe2bb4fa5b0'),
('adswisdatya1d', 'adwisatya2', 0, 0, NULL, '76aafe92b629d489996f7a1357005d33'),
('adwisatya', '84c29c7a16116c6e549fcafdc4a8fcf1', 0, 0, NULL, '84c29c7a16116c6e549fcafdc4a8fcf1'),
('adwisatya1', '76aafe92b629d489996f7a1357005d33', 0, 0, NULL, '99e22b7a40b480986716097f3e4eda12'),
('adwisatya1d', '76aafe92b629d489996f7a1357005d33', 0, 0, NULL, 'dfd24f80311c10f753e2a1fe3c0514ef'),
('root', '63a9f0ea7bb98050796b649e85481845', 0, 0, NULL, '63a9f0ea7bb98050796b649e85481845');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `inventory`
--
ALTER TABLE `inventory`
ADD PRIMARY KEY (`token`);
--
-- Indexes for table `map`
--
ALTER TABLE `map`
ADD PRIMARY KEY (`nama`);
--
-- Indexes for table `offers`
--
ALTER TABLE `offers`
ADD PRIMARY KEY (`id_offer`);
--
-- Indexes for table `servers`
--
ALTER TABLE `servers`
ADD PRIMARY KEY (`ip`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`username`), ADD UNIQUE KEY `token` (`token`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `offers`
--
ALTER TABLE `offers`
MODIFY `id_offer` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
......@@ -7,6 +7,8 @@ package thealchemist;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
......@@ -115,7 +117,8 @@ public class Client extends Thread{
cmdMixitem(JSONtoString("token",cmd),JSONtoString("item1",cmd),JSONtoString("item2",cmd));
break;
/* 6 belum */
case "map": System.out.println(cmdMap("ece63df163ce1948008064c006f4900d"));
case "map":
cmdMap(JSONtoString("token",cmd));
break;
/* 7 */
case "move":
......@@ -278,22 +281,9 @@ public class Client extends Thread{
/* Sukses */
public String cmdMap(String token) throws IOException, NoSuchAlgorithmException, JSONException{
String response = "";
String request= "";
Socket miniSocket = new Socket(URL,dbPort);
JSONObject obj = new JSONObject();
obj.put("method", "map");
obj.put("token", token);
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);
in.close();
loadMap();
return response;
}
/* Sukses */
......@@ -621,4 +611,15 @@ public class Client extends Thread{
}
return addr;
}
public void loadMap(){
String filename = "map.json";
try {
JSONObject objMap = new JSONObject(new FileReader("folder/"+filename));
System.out.println(objMap.toString());
} catch (FileNotFoundException ex) {
System.out.println("gagal load");
Logger.getLogger(Client.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