Merge branch 'master' of 60.1.1.230:backend/jieling_server
commit
69d2ba019d
|
@ -13,9 +13,9 @@ int mut,int#int,1
|
|||
100011 100013
|
||||
100012 100014
|
||||
100013 null
|
||||
100014 100015#100016#100017#100018
|
||||
100015 100019#100020#100035#100036
|
||||
100016 null
|
||||
100014 100015#100016
|
||||
100015 100017#100018
|
||||
100016 100019
|
||||
100017 null
|
||||
100018 null
|
||||
100019 100021
|
||||
|
@ -32,6 +32,14 @@ int mut,int#int,1
|
|||
100030 100032
|
||||
100031 100033
|
||||
100032 100034
|
||||
100033 100035#100036
|
||||
100034 100037#100038
|
||||
100035 100039#100040#100041#100042
|
||||
100036 100043#100044#100045#100046
|
||||
100037 100047#100048
|
||||
100038 100049#100050
|
||||
100039 100051
|
||||
0 null
|
||||
101001 10101
|
||||
101002 10102
|
||||
101003 10103
|
||||
|
|
|
@ -14,12 +14,12 @@ int int int mut,int#int,2 mut,int#int,1 int mut,int#int,2
|
|||
100012 0 1 10001 null 1 100011
|
||||
100013 0 13 1 null 1 100012
|
||||
100014 0 15 100004 null 4 null
|
||||
100015 0 32 10101#100005|101#14#12#100006 null 4 null
|
||||
100016 0 34 3#100005 null 4 null
|
||||
100017 0 30 100#5#18#100006 null 4 null
|
||||
100015 0 0 null null 1 100033
|
||||
100016 0 0 null null 5 100035
|
||||
100017 0 0 null null 4 null
|
||||
100018 0 0 null null 4 null
|
||||
100019 0 20 10101#100006 null 4 null
|
||||
100020 0 33 10101#100006|100#14#13#100005 null 4 null
|
||||
100019 0 15 100006 null 4 null
|
||||
100020 0 0 null null 4 null
|
||||
100021 0 0 null null 1 100020
|
||||
100022 0 0 null null 5 100021
|
||||
100023 0 0 null null 5 100022
|
||||
|
@ -34,10 +34,24 @@ int int int mut,int#int,2 mut,int#int,1 int mut,int#int,2
|
|||
100032 0 0 null null 4 null
|
||||
100033 0 0 null null 1 null
|
||||
100034 0 0 null null 4 null
|
||||
100035 0 30 100#5#17#100005 null 4 null
|
||||
100036 0 0 null null 4 null
|
||||
100037 0 0 null null 0 null
|
||||
100038 0 0 null null 0 null
|
||||
100035 0 0 null null 1 100034
|
||||
100036 0 0 null null 5 100035
|
||||
100037 0 0 null null 5 100035
|
||||
100038 0 0 null null 5 100035
|
||||
100039 0 1 10110 null 1 100036
|
||||
100040 0 6 2 null 1 100036
|
||||
100041 1 2 1503#1 null 1 100036
|
||||
100042 0 0 null null 1 100036
|
||||
100043 0 0 null 700001 5 100037
|
||||
100044 0 30 101#14#13#100006 null 5 100037
|
||||
100045 0 13 2 null 5 100037
|
||||
100046 0 0 null null 5 100014
|
||||
100047 0 0 null null 1 100038
|
||||
100048 0 15 100005 null 4 null
|
||||
100049 0 0 null null 1 100039
|
||||
100050 0 15 100005 null 4 null
|
||||
100051 0 15 100005 null 4 null
|
||||
0 0 0 null null 0 null
|
||||
101001 0 18 2#10110#101007 null 4 null
|
||||
101002 0 0 null null 4 null
|
||||
101003 0 0 null null 1 101009
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
Id Number RefreshItem RefreshType StoreOpenRule StartTime EndTime
|
||||
int int mut,int#int,2 mut,int#int,1 int string string
|
||||
1 3 14|0#0#0#10000 2#5 1 0 0
|
||||
2 3 14|0#0#0#10000 3#2 1 0 0
|
||||
3 3 14|0#0#0#10000 1#0 2 0 30
|
||||
Id Number RefreshItem RefreshType IfManualRefresh StoreOpenRule StartTime EndTime
|
||||
int int mut,int#int,2 mut,int#int,1 int int string string
|
||||
1 3 14|0#0#0#10000 2#5 1 1 0 0
|
||||
2 3 14|0#0#0#10000 3#2 1 1 0 0
|
||||
3 3 14|0#0#0#10000 1#0 1 2 0 30
|
||||
|
|
|
@ -87,6 +87,7 @@ function BuffManager:AddBuff(target, buff)
|
|||
--end
|
||||
|
||||
buff.frameInterval = floor(buff.interval * BattleLogic.GameFrameRate)
|
||||
buff.caster.Event:DispatchEvent(BattleEventName.BuffCaster, buff)
|
||||
end
|
||||
|
||||
function BuffManager:HasBuff(target, type, checkFunc)
|
||||
|
|
|
@ -121,7 +121,7 @@ local passivityList = {
|
|||
for i=1, skill.effectList.size do
|
||||
duration = max(duration, skill.effectList.buffer[i].duration)
|
||||
end
|
||||
role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], duration)
|
||||
role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], duration + BattleLogic.GameDeltaTime * 2)
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast)
|
||||
|
@ -187,7 +187,7 @@ local passivityList = {
|
|||
|
||||
local OnSkillCastEnd = function(skill)
|
||||
BattleUtil.RandomAction(f1, function ()
|
||||
local arr = chooseTarget(role, 10111)
|
||||
local arr = chooseTarget(role, 10321)
|
||||
if arr[1] then
|
||||
arr[1]:AddBuff(Buff.Create(role, BuffName.HOT, f3, 1, floor(role:GetRoleData(propertyList[pro]) * f2)))
|
||||
end
|
||||
|
@ -302,7 +302,7 @@ local passivityList = {
|
|||
damagingFunc(floor(role:GetRoleData(propertyList[pro]) * f2))
|
||||
end)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
|
||||
role.Event:AddEvent(BattleEventName.PassiveBeDamaging, OnPassiveDamaging)
|
||||
end,
|
||||
|
||||
--受击后,有[a]的概率对敌方全体造成攻击*[c]的[d]伤害
|
||||
|
@ -351,7 +351,7 @@ local passivityList = {
|
|||
BattleUtil.RandomAction(f1, function ()
|
||||
local arr = chooseTarget(role, 20001)
|
||||
if arr[1] then
|
||||
BattleUtil.ApplyDamage(role, atkRole, floor(role:GetRoleData(propertyList[pro]) * f2))
|
||||
BattleUtil.ApplyDamage(role, arr[1], floor(role:GetRoleData(propertyList[pro]) * f2))
|
||||
end
|
||||
end)
|
||||
lastTrigger = 0
|
||||
|
@ -521,7 +521,7 @@ local passivityList = {
|
|||
[22] = function(role, args)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
local f3 = args[2]
|
||||
local f3 = args[3]
|
||||
|
||||
local triggerCount = 0
|
||||
local OnDamaged = function(atkRole)
|
||||
|
@ -634,12 +634,12 @@ local passivityList = {
|
|||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
|
||||
local OnRoleDamageBefore = function(defRole, factorFunc)
|
||||
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
|
||||
if BattleUtil.GetHPPencent(defRole) > f1 then
|
||||
factorFunc(f2)
|
||||
damagingFunc(-floor(f2 * damage))
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore)
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
|
||||
end,
|
||||
|
||||
--对血量低于[a]的敌人伤害提高[b]。
|
||||
|
@ -648,12 +648,12 @@ local passivityList = {
|
|||
local f1 = args[1]
|
||||
local f2 = args[2]
|
||||
|
||||
local OnRoleDamageBefore = function(defRole, factorFunc)
|
||||
local OnPassiveDamaging = function(damagingFunc, defRole, damage)
|
||||
if BattleUtil.GetHPPencent(defRole) < f1 then
|
||||
factorFunc(f2)
|
||||
damagingFunc(-floor(f2 * damage))
|
||||
end
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore)
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
|
||||
end,
|
||||
|
||||
--发动技能后,[d]改变敌方全体[a]属性[b],持续[c]秒
|
||||
|
@ -725,7 +725,7 @@ local passivityList = {
|
|||
local OnPassiveDamaging = function(damagingFunc)
|
||||
damagingFunc(-f1)
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging)
|
||||
role.Event:AddEvent(BattleEventName.PassiveBeDamaging, OnPassiveDamaging)
|
||||
end,
|
||||
|
||||
--进入战斗[a]秒后,造成的伤害提升[b],持续[c]秒
|
||||
|
@ -825,10 +825,10 @@ local passivityList = {
|
|||
[41] = function(role, args)
|
||||
local f1 = args[1]
|
||||
|
||||
local OnDamaged = function(atkRole, damage, bCrit, finalDmg)
|
||||
local OnDamage = function(defRole, damage, bCrit, finalDmg)
|
||||
BattleUtil.CalTreat(role, role, floor(f1 * finalDmg))
|
||||
end
|
||||
role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnDamaged)
|
||||
role.Event:AddEvent(BattleEventName.RoleDamage, OnDamage)
|
||||
end,
|
||||
|
||||
--造成暴击伤害时,有[a]的概率造成[b]的暴击伤害。
|
||||
|
|
|
@ -35,6 +35,7 @@ BattleEventName = {
|
|||
SkillCastEnd = indexAdd(),
|
||||
|
||||
PassiveTreating = indexAdd(),
|
||||
PassiveBeDamaging = indexAdd(),
|
||||
PassiveDamaging = indexAdd(),
|
||||
PassiveCriting = indexAdd(),
|
||||
|
||||
|
|
|
@ -75,20 +75,12 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType)
|
|||
|
||||
--加入被动效果
|
||||
local damagingFunc = function(dmgDeduction) damage = damage - dmgDeduction end
|
||||
defRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc)
|
||||
atkRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc, defRole, damage)
|
||||
defRole.Event:DispatchEvent(BattleEventName.PassiveBeDamaging, damagingFunc, atkRole, damage)
|
||||
|
||||
if damage > 0 then
|
||||
local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage)
|
||||
if finalDmg > 0 then
|
||||
if atkRole then
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit, finalDmg, damageType)
|
||||
end
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, bCrit, finalDmg, damageType)
|
||||
if bCrit then
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole)
|
||||
end
|
||||
|
||||
if defRole:GetRoleData(RoleDataName.Hp) <= 0 then
|
||||
defRole.isDead = true
|
||||
BattleLogic.BuffMgr:ClearBuff(defRole)
|
||||
|
@ -100,6 +92,15 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType)
|
|||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if atkRole then
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit, finalDmg, damageType)
|
||||
end
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, bCrit, finalDmg, damageType)
|
||||
if bCrit then
|
||||
atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole)
|
||||
defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole)
|
||||
end
|
||||
end
|
||||
return finalDmg
|
||||
else
|
||||
|
@ -190,8 +191,8 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
|
|||
baseFactor = baseFactor or 1
|
||||
local maxHp = targetRole:GetRoleData(RoleDataName.MaxHp)
|
||||
local hp = targetRole:GetRoleData(RoleDataName.Hp)
|
||||
local factor = castRole:GetRoleData(RoleDataName.TreatFacter) + 1
|
||||
local factor2 = targetRole:GetRoleData(RoleDataName.CureFacter) + 1
|
||||
local factor = castRole:GetRoleData(RoleDataName.TreatFacter)
|
||||
local factor2 = targetRole:GetRoleData(RoleDataName.CureFacter)
|
||||
local baseTreat = floor(value * baseFactor * factor * factor2 + 0.5)
|
||||
|
||||
--加入被动效果
|
||||
|
|
|
@ -154,7 +154,6 @@ function RoleLogic:AddBuff(buff)
|
|||
return
|
||||
end
|
||||
end
|
||||
buff.caster.Event:DispatchEvent(BattleEventName.BuffCaster, buff)
|
||||
BattleLogic.BuffMgr:AddBuff(self, buff)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,17 +20,18 @@ public class SStoreTypeConfig implements BaseConfig {
|
|||
|
||||
private String endTime;
|
||||
|
||||
private int ifManualRefresh;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sStoreTypeConfigMap = STableManager.getConfig(SStoreTypeConfig.class);
|
||||
}
|
||||
|
||||
public static Map<Integer, SStoreTypeConfig> getSstoreTypeConfigMap (){
|
||||
public static Map<Integer, SStoreTypeConfig> getsStoreTypeConfigMap() {
|
||||
return sStoreTypeConfigMap;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -57,4 +58,7 @@ public class SStoreTypeConfig implements BaseConfig {
|
|||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
public int getIfManualRefresh() {
|
||||
return ifManualRefresh;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.ljsd.jieling.logic.activity.ActivityLogic;
|
|||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
@ -50,6 +51,8 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
MapLogic.getInstance().resetDayInfo(user);
|
||||
//活动刷新
|
||||
ActivityLogic.getInstance().flushEveryDay(user);
|
||||
//商店刷新次数重置
|
||||
StoreLogic.resetStoreRefreshNum(userId);
|
||||
}
|
||||
user.getPlayerInfoManager().setLoginTime(TimeUtils.now());
|
||||
Map<Integer, Integer> guidePoints = user.getPlayerInfoManager().getGuidePoints();
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.ljsd.jieling.handler.store;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BuyStoreItemHandler extends BaseHandler {
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.BUY_STORE_ITEM_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
PlayerInfoProto.BuyStoreItemRequest buyStoreItemRequest
|
||||
= PlayerInfoProto.BuyStoreItemRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
StoreLogic.buyStoreItem(iSession,buyStoreItemRequest.getStoreId(),buyStoreItemRequest.getItemId(),buyStoreItemRequest.getItemNum());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.ljsd.jieling.handler.store;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class StoreRefreItemHandler extends BaseHandler {
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.BUY_STORE_ITEM_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
PlayerInfoProto.StoreGoodsRefreshRequest buyStoreItemRequest
|
||||
= PlayerInfoProto.StoreGoodsRefreshRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
int type = buyStoreItemRequest.getType();
|
||||
int storeId = buyStoreItemRequest.getStoreId();
|
||||
if (type ==0){
|
||||
StoreLogic.handRefreStore(iSession,storeId);
|
||||
}else if (type ==1){
|
||||
StoreLogic.automaticRefreStore(iSession,storeId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.dao;
|
|||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StoreInfo extends MongoBase {
|
||||
|
@ -38,6 +39,7 @@ public class StoreInfo extends MongoBase {
|
|||
}
|
||||
|
||||
public void setItemNumMap(Map<Integer, Integer> itemNumMap) {
|
||||
updateString("itemNumMap", itemNumMap);
|
||||
this.itemNumMap = itemNumMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -254,5 +254,6 @@ public class MailLogic {
|
|||
User user = UserManager.getUser(uid);
|
||||
Mail mail = new Mail(uid,title,content,reward,sendTime, mailEffectiveTime,"system",Global.MAIL_TYPE_SYS);
|
||||
user.getMailManager().addMail(mail);
|
||||
LOGGER.info("sendMail==>uid={},title={},reward:{}",uid,title,reward);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.ljsd.jieling.logic.store;
|
|||
import ch.qos.logback.core.util.TimeUtil;
|
||||
import com.ljsd.jieling.config.SStoreConfig;
|
||||
import com.ljsd.jieling.config.SStoreTypeConfig;
|
||||
import com.ljsd.jieling.handler.store.GetAllStoreHandler;
|
||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.StoreInfo;
|
||||
import com.ljsd.jieling.logic.dao.StoreManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
|
@ -12,7 +12,9 @@ import com.ljsd.jieling.network.session.ISession;
|
|||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.StringUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -33,42 +35,62 @@ public class StoreLogic {
|
|||
User user = UserManager.getUser(uid);
|
||||
StoreManager storeManager = user.getStoreManager();
|
||||
if (storeManager.getStoreInfoMap().size() == 0){
|
||||
initStoreInfo(storeManager);
|
||||
initStoreInfo(user,storeManager);
|
||||
}
|
||||
PlayerInfoProto.GetStoreInfos.Builder builder = PlayerInfoProto.GetStoreInfos.newBuilder();
|
||||
PlayerInfoProto.GetStoreInfosResponse.Builder builder = PlayerInfoProto.GetStoreInfosResponse.newBuilder();
|
||||
Map<Integer, StoreInfo> storeInfoMap = storeManager.getStoreInfoMap();
|
||||
checkStoreRefresh(storeManager,storeInfoMap);
|
||||
List<CommonProto.StoreInfo> storeInfos = new CopyOnWriteArrayList<>();
|
||||
for (Map.Entry<Integer, StoreInfo> entry: storeInfoMap.entrySet()){
|
||||
CommonProto.StoreInfo.Builder storeBuilder = CommonProto.StoreInfo.newBuilder();
|
||||
StoreInfo storeInfo = entry.getValue();
|
||||
storeBuilder.setId(storeInfo.getId());
|
||||
storeBuilder.setLastRefreshTime(storeInfo.getLastRefreshTime());
|
||||
storeBuilder.setRefreshNum(storeInfo.getRefreshNum());
|
||||
storeBuilder.setStartTime(storeInfo.getStartTime());
|
||||
storeBuilder.setEndTime(storeInfo.getEndTime());
|
||||
Map<Integer, Integer> itemNumMap = storeInfo.getItemNumMap();
|
||||
List<CommonProto.StoreItem> builderList = new CopyOnWriteArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry1: itemNumMap.entrySet()){
|
||||
int itemId = entry1.getKey();
|
||||
int buyNum = entry1.getValue();
|
||||
CommonProto.StoreItem.Builder storeItemBuilder = CommonProto.StoreItem.newBuilder();
|
||||
storeItemBuilder.setId(itemId);
|
||||
storeItemBuilder.setBuyNum(buyNum);
|
||||
builderList.add(storeItemBuilder.build());
|
||||
}
|
||||
storeBuilder.addAllStoreItem(builderList);
|
||||
CommonProto.StoreInfo.Builder storeBuilder = getBuilder(entry.getValue());
|
||||
storeInfos.add(storeBuilder.build());
|
||||
}
|
||||
builder.addAllStoreInfo(storeInfos);
|
||||
MessageUtil.sendMessage(iSession, 1,msgId, builder.build(), true);
|
||||
}
|
||||
|
||||
private static CommonProto.StoreInfo.Builder getBuilder(StoreInfo storeInfo) {
|
||||
CommonProto.StoreInfo.Builder storeBuilder = CommonProto.StoreInfo.newBuilder();
|
||||
storeBuilder.setId(storeInfo.getId());
|
||||
storeBuilder.setLastRefreshTime(storeInfo.getLastRefreshTime());
|
||||
storeBuilder.setRefreshNum(storeInfo.getRefreshNum());
|
||||
storeBuilder.setStartTime(storeInfo.getStartTime());
|
||||
storeBuilder.setEndTime(storeInfo.getEndTime());
|
||||
Map<Integer, Integer> itemNumMap = storeInfo.getItemNumMap();
|
||||
List<CommonProto.StoreItem> builderList = new CopyOnWriteArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry1: itemNumMap.entrySet()){
|
||||
int itemId = entry1.getKey();
|
||||
int buyNum = entry1.getValue();
|
||||
CommonProto.StoreItem.Builder storeItemBuilder = CommonProto.StoreItem.newBuilder();
|
||||
storeItemBuilder.setId(itemId);
|
||||
storeItemBuilder.setBuyNum(buyNum);
|
||||
builderList.add(storeItemBuilder.build());
|
||||
}
|
||||
storeBuilder.addAllStoreItem(builderList);
|
||||
return storeBuilder;
|
||||
}
|
||||
|
||||
//检测商店刷新
|
||||
private static void checkStoreRefresh(StoreManager storeManager,Map<Integer, StoreInfo> storeInfoMap) {
|
||||
long nowTime = System.currentTimeMillis();
|
||||
for (Map.Entry<Integer, StoreInfo> entry:storeInfoMap.entrySet()){
|
||||
StoreInfo storeInfo = entry.getValue();
|
||||
SStoreTypeConfig sStoreTypeConfig = SStoreTypeConfig.getsStoreTypeConfigMap().get(storeInfo.getId());
|
||||
if (sStoreTypeConfig.getStoreOpenRule() ==2){
|
||||
if ((nowTime - storeInfo.getEndTime()) > Integer.parseInt(sStoreTypeConfig.getEndTime()) * 60 *1000){
|
||||
storeManager.removeStoreInfo(storeInfo.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//初始化商店
|
||||
private static void initStoreInfo(StoreManager storeManager) throws Exception {
|
||||
Map<Integer, SStoreTypeConfig> sstoreTypeConfigMap = SStoreTypeConfig.getSstoreTypeConfigMap();
|
||||
private static void initStoreInfo(User user,StoreManager storeManager) throws Exception {
|
||||
Map<Integer, SStoreTypeConfig> sstoreTypeConfigMap = SStoreTypeConfig.getsStoreTypeConfigMap();
|
||||
for ( Map.Entry<Integer, SStoreTypeConfig> entry :sstoreTypeConfigMap.entrySet()){
|
||||
SStoreTypeConfig sStoreTypeConfig = entry.getValue();
|
||||
if (sStoreTypeConfig.getStoreOpenRule() == 1){ //固定商店
|
||||
Map<Integer, Integer> itemNumMap = getStoreItem(sStoreTypeConfig.getId(),sStoreTypeConfig.getNumber());
|
||||
Map<Integer, Integer> itemNumMap = getStoreItem(sStoreTypeConfig.getId(),sStoreTypeConfig,user);
|
||||
long startTime = 0;
|
||||
long endTime = 0;
|
||||
if (!sStoreTypeConfig.getStartTime().equals("0")){
|
||||
|
@ -85,16 +107,17 @@ public class StoreLogic {
|
|||
/**
|
||||
* 随机获得商店物品
|
||||
*/
|
||||
private static Map<Integer,Integer> getStoreItem(int storeId,int itemNum) {
|
||||
private static Map<Integer,Integer> getStoreItem(int storeId, SStoreTypeConfig sStoreTypeConfig ,User user) {
|
||||
Map<Integer, Integer> itemNumMap = new ConcurrentHashMap<>();
|
||||
for (int i = 1; i <= itemNum; i ++){
|
||||
int rewardId = getRewardId(storeId,i);
|
||||
for (int i = 1; i <= sStoreTypeConfig.getNumber(); i ++){
|
||||
int rewardId = getRewardId(storeId,i,user);
|
||||
itemNumMap.put(rewardId, 0);
|
||||
}
|
||||
return itemNumMap;
|
||||
}
|
||||
|
||||
private static int getRewardId(int storeId,int sort) {
|
||||
private static int getRewardId(int storeId,int sort,User user) {
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
List<SStoreConfig> sstoreConfigBuyStore = SStoreConfig.getSstoreConfigBuyStore(storeId);
|
||||
List<SStoreConfig> randomSstoreConfigList = new CopyOnWriteArrayList<>();
|
||||
int totalWeight = 0;
|
||||
|
@ -102,8 +125,12 @@ public class StoreLogic {
|
|||
if (sort != sStoreConfig.getSort()){
|
||||
continue;
|
||||
}
|
||||
totalWeight += sStoreConfig.getWeight();
|
||||
randomSstoreConfigList.add(sStoreConfig);
|
||||
int minLv = sStoreConfig.getOpenLv()[0];
|
||||
int maxLv = sStoreConfig.getOpenLv()[1];
|
||||
if (minLv <= playerInfoManager.getLevel() && maxLv >= playerInfoManager.getLevel()){
|
||||
totalWeight += sStoreConfig.getWeight();
|
||||
randomSstoreConfigList.add(sStoreConfig);
|
||||
}
|
||||
}
|
||||
int weight = 0;
|
||||
int rewardId = 0;
|
||||
|
@ -118,4 +145,156 @@ public class StoreLogic {
|
|||
}
|
||||
return rewardId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 购买商店物品
|
||||
* @param iSession
|
||||
* @param storeId
|
||||
* @param itemId
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void buyStoreItem(ISession iSession,int storeId, int itemId,int itemNum) throws Exception {
|
||||
int msgId = MessageTypeProto.MessageType.BUY_STORE_ITEM_RESPONSE_VALUE;
|
||||
int uid = iSession.getUid();
|
||||
if (itemNum < 0|| itemNum >999){
|
||||
LOGGER.info("buyStoreItem==> uid={},itemNum={}",uid,itemNum);
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
}
|
||||
User user = UserManager.getUser(uid);
|
||||
Map<Integer, StoreInfo> storeInfoMap = user.getStoreManager().getStoreInfoMap();
|
||||
if (!storeInfoMap.containsKey(storeId)){
|
||||
LOGGER.info("buyStoreItem==> uid={},storeId={}",uid,storeId);
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
}
|
||||
StoreInfo storeInfo = storeInfoMap.get(storeId);
|
||||
Map<Integer, Integer> itemNumMap =storeInfo.getItemNumMap();
|
||||
if (!itemNumMap.containsKey(itemId)){
|
||||
LOGGER.info("buyStoreItem==> uid={},itemId={}",uid,itemId);
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
}
|
||||
int buyTimes = itemNumMap.get(itemId);
|
||||
SStoreConfig sStoreConfig = SStoreConfig.getSstoreConfigMap().get(itemId);
|
||||
String cost = getCost(buyTimes,sStoreConfig.getCost());
|
||||
boolean result = ItemUtil.itemCost(user, StringUtil.parseFiledInt2(cost));
|
||||
if (!result){
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"道具不足");
|
||||
return;
|
||||
}
|
||||
itemNumMap.put(itemId,buyTimes +1);
|
||||
storeInfo.setItemNumMap(itemNumMap);
|
||||
int goodsId = sStoreConfig.getGoods()[0];
|
||||
int goodsNum = sStoreConfig.getGoods()[0]*itemNum;
|
||||
String reward = goodsId +"#"+goodsNum;
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, StringUtil.parseFiledInt2(reward));
|
||||
PlayerInfoProto.BuyStoreItemResponse builder = PlayerInfoProto.BuyStoreItemResponse.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendMessage(iSession, 1,msgId, builder, true);
|
||||
}
|
||||
|
||||
private static String getCost(int buyTimes, int[][] costs) {
|
||||
int costItemId = costs[0][0];
|
||||
int[] ints = costs[1];
|
||||
int costNum = (int) (Math.ceil(Math.pow(ints[0], 3)) *buyTimes) + (int) (Math.ceil(Math.pow(ints[1], 2)) *buyTimes) +(int) (Math.ceil(Math.pow(ints[2], 1)) *buyTimes) + ints[3];
|
||||
String cost = costItemId +"#"+costNum;
|
||||
return cost;
|
||||
}
|
||||
|
||||
//手动刷新商店
|
||||
public static void handRefreStore(ISession iSession,int storeId) throws Exception {
|
||||
int msgId = MessageTypeProto.MessageType.STORE_GOODS_REFRESH_RESPONSE_VALUE;
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
StoreManager storeManager = user.getStoreManager();
|
||||
Map<Integer, StoreInfo> storeInfoMap = storeManager.getStoreInfoMap();
|
||||
if (!storeInfoMap.containsKey(storeId)){
|
||||
LOGGER.info("handRefreStore==> uid={},storeId={}",uid,storeId);
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
}
|
||||
StoreInfo storeInfo = storeInfoMap.get(storeId);
|
||||
SStoreTypeConfig sStoreTypeConfig = SStoreTypeConfig.getsStoreTypeConfigMap().get(storeId);
|
||||
if (sStoreTypeConfig.getIfManualRefresh() != 1){
|
||||
LOGGER.info("handRefreStore==> uid={},storeId={},ifManualRefresh={}",uid,storeId,sStoreTypeConfig.getIfManualRefresh());
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
}
|
||||
int refreshNum = storeInfo.getRefreshNum();
|
||||
String cost = getCost(refreshNum, sStoreTypeConfig.getRefreshItem());
|
||||
boolean result = ItemUtil.itemCost(user, StringUtil.parseFiledInt2(cost));
|
||||
if (!result){
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"道具不足");
|
||||
return;
|
||||
}
|
||||
Map<Integer, Integer> itemNumMap = getStoreItem(sStoreTypeConfig.getId(),sStoreTypeConfig,user);
|
||||
storeInfo.setRefreshNum(storeInfo.getRefreshNum() +1);
|
||||
storeInfo.setItemNumMap(itemNumMap);
|
||||
CommonProto.StoreInfo.Builder storeBuilder = getBuilder(storeInfo);
|
||||
PlayerInfoProto.StoreGoodsRefreshResponse builder = PlayerInfoProto.StoreGoodsRefreshResponse.newBuilder().setStoreInfo(storeBuilder).build();
|
||||
MessageUtil.sendMessage(iSession, 1,msgId, builder, true);
|
||||
}
|
||||
//自动刷新商店
|
||||
public static void automaticRefreStore(ISession iSession,int storeId) throws Exception {
|
||||
int msgId = MessageTypeProto.MessageType.STORE_GOODS_REFRESH_RESPONSE_VALUE;
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
StoreManager storeManager = user.getStoreManager();
|
||||
Map<Integer, StoreInfo> storeInfoMap = storeManager.getStoreInfoMap();
|
||||
if (!storeInfoMap.containsKey(storeId)){
|
||||
LOGGER.info("handRefreStore==> uid={},storeId={}",uid,storeId);
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
}
|
||||
StoreInfo storeInfo = storeInfoMap.get(storeId);
|
||||
SStoreTypeConfig sStoreTypeConfig = SStoreTypeConfig.getsStoreTypeConfigMap().get(storeId);
|
||||
int type = sStoreTypeConfig.getRefreshType()[0];
|
||||
if (type == 1){
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
LOGGER.info("automaticRefreStore==>uid={},storeid={},type={}",uid,storeId,type);
|
||||
return;
|
||||
}
|
||||
Map<Integer, Integer> itemNumMap = null;
|
||||
long nowTime = System.currentTimeMillis();
|
||||
switch (type){
|
||||
case 2:
|
||||
boolean overTime = TimeUtils.isOverTime(5, storeInfo.getLastRefreshTime());
|
||||
if (overTime){
|
||||
itemNumMap = getStoreItem(sStoreTypeConfig.getId(),sStoreTypeConfig,user);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if ((nowTime - storeInfo.getEndTime()) > Integer.parseInt(sStoreTypeConfig.getEndTime()) *60 *1000){
|
||||
itemNumMap = getStoreItem(sStoreTypeConfig.getId(),sStoreTypeConfig,user);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (itemNumMap == null){
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
LOGGER.info("automaticRefreStore==>uid={},storeid={},type={}",uid,storeId,type);
|
||||
return;
|
||||
}
|
||||
storeInfo.setItemNumMap(itemNumMap);
|
||||
storeInfo.setLastRefreshTime(nowTime);
|
||||
storeInfo.setRefreshNum(storeInfo.getRefreshNum() +1);
|
||||
CommonProto.StoreInfo.Builder storeBuilder = getBuilder(storeInfo);
|
||||
PlayerInfoProto.StoreGoodsRefreshResponse builder = PlayerInfoProto.StoreGoodsRefreshResponse.newBuilder().setStoreInfo(storeBuilder).build();
|
||||
MessageUtil.sendMessage(iSession, 1,msgId, builder, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置商店刷新次数
|
||||
* @param uid
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void resetStoreRefreshNum(int uid) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
StoreManager storeManager = user.getStoreManager();
|
||||
Map<Integer, StoreInfo> storeInfoMap = storeManager.getStoreInfoMap();
|
||||
for (Map.Entry<Integer, StoreInfo> entry: storeInfoMap.entrySet()){
|
||||
StoreInfo storeInfo = entry.getValue();
|
||||
storeInfo.setRefreshNum(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -537,7 +537,7 @@ public class ItemUtil {
|
|||
for (Map.Entry<Integer, Integer> entry : equipMap.entrySet()) {
|
||||
int count = entry.getValue();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (user.getEquipManager().getEquipMap().size() > gameSetting.getEquipNumlimit()) {
|
||||
if (user.getEquipManager().getEquipMap().size() >= gameSetting.getEquipNumlimit()) {
|
||||
if (reward.length() == 0){
|
||||
reward = new StringBuilder(entry.getKey() + "#1");
|
||||
}else{
|
||||
|
@ -587,13 +587,36 @@ public class ItemUtil {
|
|||
if (cardMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
SGameSetting gameSetting = SGameSetting.getGameSetting();
|
||||
int hasHeroNum = user.getHeroManager().getHeroMap().size();
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("card_bag_limit_title");
|
||||
String content = SErrorCodeEerverConfig.getI18NMessage("card_bag_limit_txt");
|
||||
if (hasHeroNum >= gameSetting.getHeroNumlimit()){
|
||||
String reward = getLimitReward(cardMap);
|
||||
int nowTime =(int) (TimeUtils.now()/1000);
|
||||
MailLogic.getInstance().sendMail(Integer.parseInt(user.getId()),title,content,reward,nowTime,Global.MAIL_EFFECTIVE_TIME);
|
||||
return;
|
||||
}
|
||||
List<CommonProto.Hero> heroList = new CopyOnWriteArrayList<>();
|
||||
StringBuilder reward = new StringBuilder();
|
||||
for (Map.Entry<Integer, Integer> entry : cardMap.entrySet()) {
|
||||
int count = entry.getValue();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (user.getHeroManager().getHeroMap().size() >= gameSetting.getHeroNumlimit()) {
|
||||
if (reward.length() == 0){
|
||||
reward = new StringBuilder(entry.getKey() + "#1");
|
||||
}else{
|
||||
reward.append("|").append(entry.getKey()).append("#1");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
addCard(user, entry.getKey(),heroList);
|
||||
}
|
||||
}
|
||||
if (reward.length() > 0) {
|
||||
int nowTime = (int) (TimeUtils.now() / 1000);
|
||||
MailLogic.getInstance().sendMail(Integer.parseInt(user.getId()), title, content, reward.toString(), nowTime, Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
dropBuilder.addAllHero(heroList);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#server info
|
||||
server.id = 10215
|
||||
server.id = 10212
|
||||
server.openTime = 20190101000101
|
||||
server.num = 1
|
||||
|
||||
|
||||
# redis config
|
||||
# Redis数据库索引(默认为0)
|
||||
spring.redis.database=0
|
||||
spring.redis.database=1
|
||||
# Redis服务器地址
|
||||
spring.redis.host=60.1.1.14
|
||||
# Redis服务器连接端口
|
||||
|
@ -30,7 +30,7 @@ spring.redis.expireTime = -1
|
|||
#spring.data.mongodb.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/ysj_wx_1
|
||||
#spring.data.mongodb2.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/develop_ysj_wx_1
|
||||
#mongodb2 develop
|
||||
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10215
|
||||
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10212
|
||||
mongodb.options.maxWaitTime = 120000
|
||||
mongodb.options.connectTimeout = 1000
|
||||
mongodb.options.socketTimeout = 0
|
||||
|
|
Loading…
Reference in New Issue