-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer.pony
33 lines (27 loc) · 853 Bytes
/
player.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use "net"
actor Player
let _conn: TCPConnection tag
let _cm: ConnectionManager tag
var _pname: (String | None) = None
new create(cm: ConnectionManager tag, conn: TCPConnection tag) =>
_cm = cm
_conn = conn
be tell(msg: String) =>
_conn.write(msg)
be parsecommand(cmd: String) =>
if _pname is None then
_pname = cmd
_conn.write("You've chosen a name.\n")
emitall("has logged in.\n")
else
_conn.write("[Debug] You typed " + cmd + ".\n" )
emitall("typed '" + cmd + "'\n")
end
be emitall(text: String) =>
_cm.broadcast(_name() + " " + text)
fun _name(): String =>
match _pname
| let n: String => n
else
"Someone"
end