summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/game.lua12
-rw-r--r--client/util.lua2
2 files changed, 10 insertions, 4 deletions
diff --git a/client/game.lua b/client/game.lua
index 43e2352..ede8d98 100644
--- a/client/game.lua
+++ b/client/game.lua
@@ -214,11 +214,12 @@ local function handle_net()
username=pl.username,
inv = {},
}
- elseif op == "inv" then
- local_player.inv = j.inv
elseif op == "chunk" then
local ch = ChunkC:from_packet_data(j)
map:add_chunk(ch)
+ elseif op == "give" then
+ local old_count = local_player.inv[j.tile] or 0
+ local_player.inv[j.tile] = old_count + 1
elseif op == "settile" then
local h = coords.Hex:make(j.q,j.r)
map:set_at(h,j.tile)
@@ -241,10 +242,13 @@ local function update(dt)
local msx,msy = love.mouse.getPosition()
local mh =
camera:screen_to_world(Pos:make(msx,msy)):to_hex():round()
+ local inv = local_player.inv
if map:at(mh) == 0 and love.mouse.isDown(1) then
- if (local_player.inv[selected_tile] or 0) > 0 then
+ local old_count = inv[selected_tile] or 0
+ if old_count > 0 then
map:set_at(mh,selected_tile)
send_settile(mh,selected_tile)
+ inv[selected_tile] = old_count - 1
end
elseif map:at(mh) ~= 0 and love.mouse.isDown(2) then
map:set_at(mh,0)
@@ -350,7 +354,7 @@ local function draw()
end
table.insert(inv_rows, s)
end
- util.print_good(table.concat(inv_rows,'\n'),0,0)
+ util.print_good(table.concat(inv_rows,'\n'),"end",0)
if show_controls then
diff --git a/client/util.lua b/client/util.lua
index a1c4b35..ebfad6c 100644
--- a/client/util.lua
+++ b/client/util.lua
@@ -7,6 +7,8 @@ local function print_good(str,x,y)
local W,H = love.graphics.getDimensions()
if x == "center" then x = (W/2)-(w/2) end
if y == "center" then y = (H/2)-(h/2) end
+ if x == "end" then x = W-w end
+ if y == "end" then y = H-h end
love.graphics.setColor(0,0,0,0.8)
love.graphics.rectangle("fill",x,y,w,h)
love.graphics.setColor(1,1,1)