Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanjunxiong committed Nov 15, 2017
1 parent 303055c commit a0b1081
Show file tree
Hide file tree
Showing 38 changed files with 79,905 additions and 191 deletions.
2 changes: 2 additions & 0 deletions config/item.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
return {
[1] = {id=1, desc = "this is item one"},
[2] = {id=2, desc = "this is item two"},
[10] = {id=10, desc = "this is item ten 2"},
[11] = {id=11, desc = "this is item ten 11"},
}

216 changes: 216 additions & 0 deletions config/lifebuilding.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
return {
--只能连续的?? 后面要改
[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] = {},
[36] = {},
[37] = {},
[38] = {},
[39] = {},
[40] = {},
[41] = {},
[42] = {},
[43] = {},
[44] = {},
[45] = {},
[46] = {},
[47] = {},
[48] = {},
[49] = {},
[50] = {},
[51] = {},
[52] = {},
[53] = {},
[54] = {},
[55] = {},
[56] = {},
[57] = {},
[58] = {},
[59] = {},
[60] = {},
[61] = {},
[62] = {},
[63] = {},
[64] = {},
[65] = {},
[66] = {},
[67] = {},
[68] = {},
[69] = {},
[70] = {},
[71] = {},
[72] = {},
[73] = {},
[74] = {},
[75] = {},
[76] = {},
[77] = {},
[78] = {},
[79] = {},
[80] = {},
[81] = {},
[82] = {},
[83] = {},
[84] = {},
[85] = {},
[86] = {},
[87] = {},
[88] = {},
[89] = {},
[90] = {},
[91] = {},
[92] = {},
[93] = {},
[94] = {},
[95] = {},
[96] = {},
[97] = {},
[98] = {},
[99] = {},
[100] = {},

[101]={addtype=1, addval=30, condition={agegroup={0,1,2,3,4}}, eat=1},

[102] = {},
[103] = {},
[104] = {},
[105] = {},
[106] = {},
[107] = {},
[108] = {},
[109] = {},
[110] = {},
[111] = {},
[112] = {},
[113] = {},
[114] = {},
[115] = {},
[116] = {},
[117] = {},
[118] = {},
[119] = {},
[120] = {},
[121] = {},
[122] = {},
[123] = {},
[124] = {},
[125] = {},
[126] = {},
[127] = {},
[128] = {},
[129] = {},
[130] = {},
[131] = {},
[132] = {},
[133] = {},
[134] = {},
[135] = {},
[136] = {},
[137] = {},
[138] = {},
[139] = {},
[140] = {},
[141] = {},
[142] = {},
[143] = {},
[144] = {},
[145] = {},
[146] = {},
[147] = {},
[148] = {},
[149] = {},
[150] = {},
[151] = {},
[152] = {},
[153] = {},
[154] = {},
[155] = {},
[156] = {},
[157] = {},
[158] = {},
[159] = {},
[160] = {},
[161] = {},
[162] = {},
[163] = {},
[164] = {},
[165] = {},
[166] = {},
[167] = {},
[168] = {},
[169] = {},
[170] = {},
[171] = {},
[172] = {},
[173] = {},
[174] = {},
[175] = {},
[176] = {},
[177] = {},
[178] = {},
[179] = {},
[180] = {},
[181] = {},
[182] = {},
[183] = {},
[184] = {},
[185] = {},
[186] = {},
[187] = {},
[188] = {},
[189] = {},
[190] = {},
[191] = {},
[192] = {},
[193] = {},
[194] = {},
[195] = {},
[196] = {},
[197] = {},
[198] = {},
[199] = {},
[200] = {},

[201]={addtype=2, addval=35, condition={agegroup={0,1}}, eat=0},
[202]={addtype=2, addval=45, condition={agegroup={2}}, eat=0},
[203]={addtype=2, addval=45, addtype2=1, addval2=-30, condition={agegroup={0,1,2,3,4}}, eat=0},
[204]={addtype=1, addval=10, condition={agegroup={0,1,2,3,4}, wisdom=0}, eat=0},
[205]={addtype=1, addval=15, condition={agegroup={0,1,2,3,4}, wisdom=100}, eat=0},
[206]={addtype=1, addval=20, condition={agegroup={0,1,2,3,4}, wisdom=200}, eat=0},
[207]={addtype=1, addval=25, condition={agegroup={0,1,2,3,4}, wisdom=300}, eat=0},
[208]={addtype=1, addval=30, condition={agegroup={0,1,2,3,4}, wisdom=400}, eat=0},

}

Binary file added doc/img/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion mod/center/login.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ local dispatch = module.dispatch
local forward = module.forward
local event = module.event


env.users = env.users or {}
--users[uid]={
--node = skynet.getenv("nodename"),
Expand Down Expand Up @@ -101,3 +100,20 @@ function dispatch.logout(uid, key, season)
end


function module.watch(acm)
--统计在线人数
local logined = 0 --成功登陆
local logining = 0 --登陆流程
for i, v in pairs(env.users) do
if v.game then
logined = logined + 1
else
logining = logining + 1
end
end
local ret = {logined = logined, logining = logining}
--总统计
acm.logined = acm.logined and acm.logined + logined or logined
acm.logining = acm.logining and acm.logining + logining or logining
return ret, acm
end
32 changes: 26 additions & 6 deletions mod/dbproxy/dbproxy.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ function event.awake()
end

function dispatch.get(dbname, cname, select) --cname -> collection name

log.info("xxx get dbname:%s cname:%s select:%s ",dbname,cname,tool.dump(select))
return db[dbname]:findOne(cname, select)
end

Expand All @@ -41,15 +39,37 @@ function dispatch.set(dbname, cname, select, update)

end

function dispatch.incr(dbname, cname)
return db[dbname]:incr(cname)
end

function dispatch.insert(dbname, cname, data)
db[dbname]:insert(cname, data)
end




--发号器 临时方案
local maxuid = 0
function event.start()
local ret = db["account"]:findOne("tb_key", {key="account"})
if ret then
maxuid = ret.uuid
end
end

function event.exit()
db["account"]:update("tb_key", {key="account"}, {key="account", uuid=maxuid}, true)
end

--原来方案有数据竞争问题,协程中调用数据库,协程会被挂起
--中途会执行其他协程
function dispatch.incr(dbname, cname)
--return db[dbname]:incr(cname)

--这一行存储只是防止停服,也会有竞争问题
db["account"]:update("tb_key", {key="account"}, {key="account", uuid=maxuid+1}, true)
maxuid = maxuid + 1
return maxuid
end

--[[
local db
function dispatch.start(conf)
Expand Down
24 changes: 14 additions & 10 deletions mod/game/lifegame.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ local log = require "log"

local libcenter = require "libcenter"
local liblife = require "liblife"
local libqueryboard = require "libqueryboard"
local tool = require "tool"
local libsetup = require "libsetup"
local Player = require "game.player"
local runconf = require(skynet.getenv("runconfig"))
local node = skynet.getenv("nodename")

env.dispatch.life = env.dispatch.life or {}
env.forward.life = env.forward.life or {}
local D = env.dispatch.life
local F = env.forward.life
local faci = require "faci.module"
local module = faci.get_module("life")
local dispatch = module.dispatch
local forward = module.forward
local event = module.event


--进入房间
function F.enter_room(player, msg)
function forward.enter_room(player, msg)
--msg = {id=1,2,3}
player.life = player.life or {}
if player.life.room_id then
Expand All @@ -42,13 +41,13 @@ function F.enter_room(player, msg)
end

--离开房间
function F.leave_room(player, msg)
D.leave_room(player)
function forward.leave_room(player, msg)
dispatch.leave_room(player)
return
end

--离开房间
function D.leave_room(player)
function dispatch.leave_room(player)
if not player.life then
return
end
Expand All @@ -63,3 +62,8 @@ function D.leave_room(player)
player.life = nil
end
end

--离开
function event.logout(player)
dispatch.leave_room(player)
end
Loading

0 comments on commit a0b1081

Please sign in to comment.