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
lancarjodoh
IF3230-Tugas-Besar-Sister-2015
Commits
144160a2
Commit
144160a2
authored
Apr 26, 2015
by
mamat-rahmat
Browse files
move to v2
parent
9ef63d65
Changes
3
Hide whitespace changes
Inline
Side-by-side
bin/server/mainserver_thread.py
View file @
144160a2
...
...
@@ -4,10 +4,7 @@ import hashlib
import
pymongo
import
threading
from
pymongo
import
MongoClient
<<<<<<<
HEAD
=======
import
datetime
>>>>>>>
2e1
c3f425d37b26acefb8d5cf9ad75f7635538c1
from
random
import
randint
# informasi port dan socket
...
...
@@ -258,22 +255,13 @@ def handler(a, c):
else
:
response
=
'{"status" : "fail", "description" : "still available"}'
else
:
<<<<<<<
HEAD
response
=
"{'status' : 'fail','description':'not exists'}"
elif
(
method
==
"map"
):
#tokem from client
token
=
dataJSON
[
'token'
]
=======
response
=
'{"status" : "fail", "description" : "not exists"}'
elif
(
method
==
"move"
):
#from client
token
=
dataJSON
[
"token"
]
posisiXnew
=
dataJSON
[
"posisiX"
]
posisiYnew
=
dataJSON
[
"posisiY"
]
>>>>>>>
2e1
c3f425d37b26acefb8d5cf9ad75f7635538c1
#from database
kriteriaObject
=
{
"token"
:
token
}
user
=
database
.
playerCollection
.
find_one
(
kriteriaObject
)
...
...
@@ -301,7 +289,8 @@ def handler(a, c):
json
.
dump
(
data
,
f
,
indent
=
4
,
separators
=
(
','
,
': '
))
response
=
'{"status" : "ok", "name" : "'
+
username
+
'", "width" : 5, "height" : 5}'
elif
(
method
==
'move'
):
elif
(
method
==
"move"
):
#from client
token
=
dataJSON
[
'token'
]
posisiXnew
=
dataJSON
[
'posisiX'
]
...
...
@@ -331,11 +320,12 @@ def handler(a, c):
response
=
'{"status" : "ok", "time" : delta_milisecond}'
else
:
response
=
'{"status" : "fail", "time" : "FAILURE MESSAGE HERE"}'
elif
(
method
==
'field'
):
#from client
token
=
dataJSON
[
'token'
]
posisiX
=
dataJSON
[
'
posisiX
'
]
posisiY
=
dataJSON
[
'
posisiY
'
]
posisiX
=
dataJSON
[
'
x
'
]
posisiY
=
dataJSON
[
'
y
'
]
#Datetime
current_time
=
datetime
.
datetime
.
now
()
...
...
@@ -358,54 +348,11 @@ def handler(a, c):
if
(
current_time
>=
time
):
new_n_item
=
n_item
+
1
;
database
.
inventoriCollection
.
update
(
kriteriaObject
,
{
"$set"
:
name_item_here
:
new_n_item
}})
database
.
inventoriCollection
.
update
(
kriteriaObject
,
{
"$set"
:
{
name_item_here
:
new_n_item
}})
response
=
'{"status" : "ok", "item" : item_here}'
else
:
<<<<<<<
HEAD
response
=
'{"status" : "fail", "time" : "FAILURE MESSAGE HERE"}'
=======
response
=
'{"status" : "fail", "time" : "FAILURE MESSAGE HERE"}'
elif
(
method
==
"map"
):
#random number for width and height
#width = randint(5,15)
#height = width
#tokem from client
token
=
dataJSON
[
'token'
]
#from database
kriteriaObject
=
{
"token"
:
token
}
user
=
database
.
playerCollection
.
find_one
(
kriteriaObject
)
username
=
user
[
'username'
]
#kriteriaObject = {"token" : token}
#write json file
data
=
{
'map'
:
[
[
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
)],
[
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
)],
[
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
)],
[
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
)],
[
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
),
randint
(
0
,
9
)]
],
'height'
:
5
,
'width'
:
5
,
'name'
:
username
}
map
=
json
.
dumps
(
data
,
indent
=
4
,
separators
=
(
','
,
': '
))
with
open
(
'map'
,
'w'
)
as
f
:
json
.
dump
(
data
,
f
,
indent
=
4
,
separators
=
(
','
,
': '
))
response
=
'{"status" : "ok", "name" : "'
+
username
+
'", "width" : 5, "height" : 5}'
>>>>>>>
2e1
c3f425d37b26acefb8d5cf9ad75f7635538c1
elif
(
method
==
"offer"
):
token
=
dataJSON
[
"token"
]
offered_item
=
dataJSON
[
"offered_item"
]
...
...
bin/server/mainserver_thread_v2.py
0 → 100644
View file @
144160a2
192.168
.
0.113
:
8500
\ No newline at end of file
bin/server/map
View file @
144160a2
{
"name": "tujuh",
"height": 5,
"name": "pulpen",
"map": [
[
<<<<<<< HEAD
3,
7,
9,
8,
5
1,
1,
2
],
[
4,
0,
6,
9,
8,
3
6,
6
],
[
3,
8,
9,
0,
2
],
[
2,
1,
9,
1,
5
],
[
2,
9,
7,
2,
6,
5,
7
]
],
"width": 5
=======
7,
7,
7,
0,
1
],
[
0,
5,
5,
9,
8
],
[
2,
9,
5,
5,
3,
7,
0,
6
],
[
9,
0,
4,
5,
2,
6,
1
],
[
4,
1,
9,
4,
3
3,
0
]
],
"height": 5,
"width": 5,
"name": "tujuh"
>>>>>>> 2e1c3f425d37b26acefb8d5cf9ad75f7635538c1
"width": 5
}
\ No newline at end of file
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