Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Barry
/
esp8266-Mud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
17133446
authored
2018-04-28 19:24:34 -0700
by
Barry
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
prevent dupe players, fixed entered game message.
1 parent
83e4eec5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
main.py
main.py
View file @
1713344
...
...
@@ -107,13 +107,13 @@ while True:
for
pid
,
pl
in
players
.
items
():
# send each player a message to tell them about the diconnected
# player
if
players
[
id
][
"name"
]
!=
None
:
if
players
[
p
id
][
"name"
]
!=
None
:
mud
.
send_message
(
pid
,
"{} quit the game"
.
format
(
players
[
id
][
"name"
]))
else
:
save_object_to_file
(
players
[
id
],
"players/{}.json"
.
format
(
players
[
id
][
"name"
]))
players
[
pid
][
"name"
]))
# remove the player's entry in the player dictionary
if
players
[
id
][
"name"
]
!=
None
:
utils
.
save_object_to_file
(
players
[
id
],
"players/{}.json"
.
format
(
players
[
id
][
"name"
]))
del
(
players
[
id
])
# go through any new commands sent from players
...
...
@@ -130,6 +130,14 @@ while True:
if
command
.
strip
()
==
''
or
command
is
None
:
mud
.
send_message
(
id
,
"Invalid Name"
)
continue
already_logged_in
=
False
for
pid
,
pl
in
players
.
items
():
if
players
[
pid
][
"name"
]
==
command
:
mud
.
send_message
(
id
,
"{} is already logged in."
.
format
(
command
))
mud
.
disconnect_player
(
id
)
already_logged_in
=
True
if
already_logged_in
:
continue
loaded_player
=
utils
.
load_object_from_file
(
"players/{}.json"
.
format
(
command
))
if
loaded_player
is
None
:
players
[
id
][
"name"
]
=
command
...
...
Please
register
or
sign in
to post a comment