---@class KunDunInfo KunDunInfo = class() local this = KunDunInfo function this:ctor() end function this:Reset() self.data = nil self.KunDunInfo={} self.kunDunFaction = {} end function this:Init() self.KunDunInfo={} self.kunDunFaction = {} self:RegistMessages() end function this:RegistMessages() SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_KUN_DUN_AUCTION_PANEL_INFO,self.RES_KUN_DUN_AUCTION_PANEL_INFO,self) -- 响应昆顿竞拍面板信息 SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_PLAYER_ENTER_VIEW_INFO, self.RES_PLAYER_ENTER_VIEW_INFO, self) -- 响应玩家进入视野 SL:RegisterLUAEvent(LUA_EVENT_CREATE_PLAYER_SUCCESS, self.LUA_EVENT_CREATE_PLAYER_SUCCESS , self) SL:RegisterTrigger(LUA_TRIGGER_CHECK_PKMODE_RELATION, self.LUA_TRIGGER_CHECK_PKMODE_RELATION , self) SL:RegisterTrigger(LUA_TRIGGER_CHECK_PKMODE_IS_ATTACK, self.LUA_TRIGGER_CHECK_PKMODE_IS_ATTACK , self) end -- 响应昆顿竞拍面板信息 function this:RES_KUN_DUN_AUCTION_PANEL_INFO(_,_data) if _data and _data.isOpen and _data.goods then local all_list = {} for k, v in pairs(_data.goods) do table.insert(all_list,v) end table.sort(all_list,function(a,b) return tonumber(a.id) < tonumber(b.id) end) self.data = {goods=all_list,isOpen=_data.isOpen} else self.data = nil end end -- 响应玩家进入视野 function this:RES_PLAYER_ENTER_VIEW_INFO(_,message) --SL:LogTable(message,true) if message.kunDunFaction then self.kunDunFaction[message.rid] = message.kunDunFaction local rank = self:GetFactionRank(message.kunDunFaction) -- SL:LogError(message.rid) -- SL:LogError(message.kunDunFaction) -- SL:LogError(rank) SL:SetRoleActivityCamp(tonumber(message.rid),message.kunDunFaction,rank) end end function this:KunDunTrade_IsOpen() if self.data and self.data.isOpen then local server_time = SL:GetMetaValue(EMetaVarGetKey.SERVER_TIME) if self.data.goods then for k, v in ipairs(self.data.goods) do if v.endTime > server_time then return true end end end end return false end --- 筛选跨服拍卖物品 function this:KunDunTrade_GetInfo(select_type,sub_type,sortType,careerType) local jinengshu = 3 local select_list = {} if self.data and self.data.isOpen then local server_time = SL:GetMetaValue(EMetaVarGetKey.SERVER_TIME) if self.data.goods then for k, v in ipairs(self.data.goods) do if v.endTime > server_time then local is_add = false if not select_type then is_add = true elseif select_type == jinengshu then local item = SL:GetConfig("cfg_stall",v.cfgid) if item.type == jinengshu then is_add = true end else local item = SL:GetConfig("cfg_stall",v.cfgid) if item.type == select_type and item.subType == sub_type then is_add = true end end if is_add then table.insert(select_list,v) end end end end end return select_list end function this:SetRankList(message) self.team_rankList = {} if message.factionRank then for i = 1, 3, 1 do local id = tostring(i) if message.factionRank[id] then self.team_rankList[message.factionRank[id]] = i else break end end end end function this:GetFactionRank(faction) if not self.team_rankList or not self.team_rankList[faction] then return 0 end return self.team_rankList[faction] end function this:LUA_EVENT_CREATE_PLAYER_SUCCESS(_,rid) if not self.kunDunFaction[tostring(rid)] then return end local faction = self.kunDunFaction[tostring(rid)] local rank = self:GetFactionRank(faction) SL:SetRoleActivityCamp(rid,faction,rank) end --判断当前模式玩家之间的关系 function this:LUA_TRIGGER_CHECK_PKMODE_RELATION(pk_mode,player1,player2) local pkMode = SL:GetMetaValue(EMetaVarGetKey.PKMODE) if pkMode == EPKMode.Camp then SL:LogError("玩家之间的关系") SL:LogError(pk_mode) -- SL:LogError(bb.id) -- SL:LogError(cc.id) local faction_1 = self.kunDunFaction[tostring(player1.id)] local faction_2 = self.kunDunFaction[tostring(player2.id)] SL:LogError(faction_1) SL:LogError(faction_2) if faction_1 == faction_2 then SL:LogError("Friend") return ERelationshipType.Friend else SL:LogError("Enemy") return ERelationshipType.Enemy end end end --判断当前模式玩家是否能被攻击 function this:LUA_TRIGGER_CHECK_PKMODE_IS_ATTACK(message) --SL:LogTable(message,true) local pkMode = SL:GetMetaValue(EMetaVarGetKey.PKMODE) if pkMode == EPKMode.Camp then local my_rid = SL:GetMetaValue(EMetaVarGetKey.USER_ID) local faction_1 = self.kunDunFaction[my_rid] local faction_2 = self.kunDunFaction[tostring(message.id)] SL:LogError("是否能被攻击"..faction_1 .. " " .. faction_2) if faction_1 == faction_2 then SL:LogError("不攻击") return false else SL:LogError("攻击") return true end end end