summaryrefslogtreecommitdiff
path: root/server/player.lua
blob: bd7b52a0c6b2e1257938bab62b0ff27b732ed681 (plain)
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
local class = require'common.class'
local Pos = require'common.coords'.Pos

local nextid = 1

local function random_color()
	return {math.random(),math.random(),math.random()}
end

local Player = class()
function Player.make(cls,peer,username)
	local self = {
		pos = Pos:make(0,0),
		color = random_color(),
		peer = peer,
		id = nextid,
		username = username,
	}
	nextid = nextid + 1
	return setmetatable(self,cls)
end
function Player.info_part(self)
	-- eh
	return {
		id=self.id,
		x=self.pos.x,
		y=self.pos.y,
		color=self.color,
		username=self.username,
	}
end

return {Player=Player}