Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
sister-kering
IF3230-Tugas-Besar-Sister-2015
Commits
761076f6
Commit
761076f6
authored
Apr 23, 2015
by
Rafi Ramadhan
Browse files
update field
parent
c19d82de
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/server/GrandQuestServer/src/grandquestserver/MethodHandler.java
View file @
761076f6
...
...
@@ -260,18 +260,34 @@ public class MethodHandler {
return
JSONValue
.
toJSONString
(
response
);
}
public
boolean
isMoving
(
String
username
)
throws
SQLException
{
DBHandler
db
=
new
DBHandler
();
boolean
walking
=
false
;
Long
arrival
=
db
.
getTime
(
username
);
if
(
System
.
currentTimeMillis
()
<
arrival
)
{
walking
=
true
;
}
System
.
out
.
println
(
walking
);
return
walking
;
}
public
String
Move
(
String
input
)
throws
ParseException
,
SQLException
{
JSONParse
parse
=
new
JSONParse
();
Map
response
=
new
LinkedHashMap
();
DBHandler
db
=
new
DBHandler
();
Long
time
=
System
.
currentTimeMillis
()+
1
0000
;
Long
time
=
System
.
currentTimeMillis
()+
3
0000
;
String
token
=
parse
.
parseJSON
(
input
,
"token"
);
String
username
=
session
.
get
(
searchToken
(
token
)).
getUsername
();
Long
x
=
parse
.
parseIntJSON
(
input
,
"x"
);
Long
y
=
parse
.
parseIntJSON
(
input
,
"y"
);
System
.
out
.
println
(
width
);
System
.
out
.
println
(
height
);
if
(
x
<
width
&&
y
<
height
)
{
if
(
x
<
width
&&
y
<
height
&&
!
isMoving
(
username
))
{
System
.
out
.
println
(
session
.
get
(
0
).
getToken
());
int
index
=
searchToken
(
token
);
db
.
setPosX
(
session
.
get
(
index
).
getUsername
(),
x
);
db
.
setPosY
(
session
.
get
(
index
).
getUsername
(),
y
);
...
...
@@ -291,6 +307,7 @@ public class MethodHandler {
JSONParse
parse
=
new
JSONParse
();
DBHandler
db
=
new
DBHandler
();
Map
response
=
new
LinkedHashMap
();
int
item
=
-
999
;
String
token
=
parse
.
parseJSON
(
input
,
"token"
);
String
username
=
session
.
get
(
searchToken
(
token
)).
getUsername
();
...
...
@@ -299,9 +316,15 @@ public class MethodHandler {
String
s
=
field_map
.
getJSONArray
(
y
).
getString
(
x
);
System
.
out
.
println
(
s
);
int
item
=
db
.
pickItem
(
s
);
response
=
parse
.
fieldJSON
(
token
,
item
,
true
);
if
(!
s
.
equals
(
""
)
&&
!
isMoving
(
username
))
{
item
=
db
.
pickItem
(
s
);
response
=
parse
.
fieldJSON
(
token
,
item
,
true
);
db
.
addInventory
(
username
,
item
);
field_map
.
getJSONArray
(
y
).
put
(
x
,
""
);
}
else
{
response
=
parse
.
fieldJSON
(
token
,
item
,
false
);
}
System
.
out
.
println
(
JSONValue
.
toJSONString
(
response
));
return
JSONValue
.
toJSONString
(
response
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment