summaryrefslogtreecommitdiff
path: root/server/player.lua
blob: 105efff039f3a4834a4644cc46d6f3588db14a45 (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
34
35
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,
		inv = {},
	}
	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,
		inv = self.inv,
	}
end

return {Player=Player}