Task【新战斗版本】公会援助

back_recharge
zhangshanxue 2020-05-16 10:32:50 +08:00
parent f2e143ed45
commit 238e940beb
26 changed files with 1195 additions and 56 deletions

View File

@ -0,0 +1,46 @@
package com.ljsd.jieling.config.clazzStaticCfg;
import config.SDifferDemonsBoxSetting;
import config.SGameSetting;
import config.SGuildHelpConfig;
import manager.AbstractClassStaticConfig;
import manager.STableManager;
import manager.Table;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Description: des
* Author: zsx
* CreateDate: 2020/5/12 16:46
*/
public class GuildStaticConfig extends AbstractClassStaticConfig {
private static final Map<Integer,Integer> helpRecourseMap = new HashMap<>();
@Override
public void registConfigs(Set<String> registConfigs) {
registConfigs.add(SGameSetting.class.getAnnotation(Table.class).name());
}
@Override
public void figureConfigs() {
try {
Map<Integer, SGuildHelpConfig> config = STableManager.getConfig(SGuildHelpConfig.class);
SGuildHelpConfig sGuildHelpConfig = config.get(1);
int[][] recourseReward = sGuildHelpConfig.getRecourseReward();
for (int[] item :recourseReward) {
helpRecourseMap.put(item[1],item[0]);
}
} catch (Exception e) {
LOGGER.error("helpRecourseMap init fail",e);
}
}
public static Map<Integer, Integer> getHelpRecourseMap() {
return helpRecourseMap;
}
}

View File

@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
public class HandlerLogicThread extends Thread{
private static final Logger LOGGER = LoggerFactory.getLogger(HandlerLogicThread.class);
private static Set<Integer> whiteMsg = new HashSet<>();
private static ThreadLocal<SimpleTransaction> threadlocal = new ThreadLocal();
static {
whiteMsg.add(MessageTypeProto.MessageType.MAP_ENTER_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_START_EXPLORE_REQUEST_VALUE);
@ -129,7 +129,7 @@ public class HandlerLogicThread extends Thread{
return;
}
session.setLastMsgId(msgId);
SimpleTransaction transaction = setTransaction(session);
SimpleTransaction transaction = SimpleTransaction.setTransaction(session);
BaseHandler baseHandler = ProtocolsManager.getInstance().getHandler(msgId);
if(baseHandler == null){
LOGGER.info("request uid=>{} , msgId=>{}, not find the baseHandler",userId,msgId);
@ -163,11 +163,11 @@ public class HandlerLogicThread extends Thread{
}
catch (Exception e){
SimpleTransaction transaction = current();
SimpleTransaction transaction = SimpleTransaction.current();
if(null!=transaction){
ISession session = transaction.getSession();
try {
current().callback();
transaction.callback();
//内部codeErr统一处理
if(e instanceof ErrorCodeException){
int errCode = ErrorUtil.getExceptionErrorCodeValue(e);
@ -278,21 +278,10 @@ public class HandlerLogicThread extends Thread{
ayyncWorkerConcurrentLinkedQueue.offer(ayyncWorker);
}
public static SimpleTransaction current() {
return threadlocal.get();
}
private static void destroyISession() {
threadlocal.set(null);
SimpleTransaction.remove();
}
private static SimpleTransaction setTransaction(ISession session) {
SimpleTransaction var0 = threadlocal.get();
if (var0 != null && var0.getSession() != null && var0.getSession().getId().equals(session.getId())) {
var0.reset();
return var0;
} else {
threadlocal.set(new SimpleTransaction(session));
}
return threadlocal.get();
}
}

View File

@ -0,0 +1,98 @@
package com.ljsd.jieling.core;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Description:
* Author: zsx
* CreateDate: 2020/5/12 15:14
*/
public class Lockey implements Comparable<Lockey>{
private final int index;
private final Object key;
private final int hashcode;
private ReentrantReadWriteLock.ReadLock rlock;
private ReentrantReadWriteLock.WriteLock wlock;
Lockey(int id, Object key) {
this.index = id;
this.key = key;
this.hashcode = id ^ (id << 16) ^ key.hashCode();
}
Lockey alloc() {
ReentrantReadWriteLock rwlock = new ReentrantReadWriteLock();
rlock = rwlock.readLock();
wlock = rwlock.writeLock();
return this;
}
void rLock() {
rlock.lock();
}
void wLock() {
wlock.lock();
}
void rUnlock() {
rlock.unlock();
}
void wUnlock() {
wlock.unlock();
}
boolean rTryLock() {
return rlock.tryLock();
}
boolean wTryLock() {
return wlock.tryLock();
}
public int getIndex() {
return index;
}
public Object getKey() {
return key;
}
public int getHashcode() {
return hashcode;
}
public ReentrantReadWriteLock.ReadLock getRlock() {
return rlock;
}
public ReentrantReadWriteLock.WriteLock getWlock() {
return wlock;
}
@SuppressWarnings("unchecked")
@Override
public int compareTo(Lockey o) {
int x = index - o.index;
return x != 0 ? x : ((Comparable<Object>) key).compareTo(o.key);
}
@Override
public int hashCode() {
return hashcode;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj instanceof Lockey) {
Lockey o = (Lockey) obj;
return this.index == o.index && key.equals(o.key);
}
return false;
}
}

View File

@ -0,0 +1,81 @@
package com.ljsd.jieling.core;
import java.lang.ref.WeakReference;
import java.util.Set;
/**
* Description:
*
*
*
* 仿ThreadLocalMap WeakReference
* Author: zsx
* CreateDate: 2020/5/12 14:58
*/
public class Lockeys {
private static Lockeys lockeys = new Lockeys();
public static Lockeys getLockeys() {
return lockeys;
}
private Entry[] table = new Entry[1 << 10]; //默认给1024 省去扩容
static class Entry extends WeakReference<Lockey> {
private Entry next;
Entry(Lockey k, Entry v) {
super(k);
this.next = v;
}
}
Lockey getLockey( Object object ,int id) {
return get(new Lockey(id, object));
}
public synchronized Lockey get(Lockey lockey) {
SimpleTransaction current = SimpleTransaction.current();
if (current != null) {
Lockey lockey1 = current.get(lockey);
if (lockey1 != null)
return lockey1;
}
int h = lockey.hashCode();
Entry e = table[h & (1 << 10-1)];
if(e==null){
e = new Entry(null, null);
table[h & (1 << 10-1)]=e;//to fix 漏写了 查半天
}
while (e.next != null) {
Lockey _key = e.next.get();
if (_key == null)
e.next = e.next.next;
else if (_key.equals(lockey))
return _key;
else
e = e.next;
}
e.next = new Entry(lockey, null);
return lockey.alloc();
}
/**
*
* 1
* 2
*
* + id
*/
public void lock(String key , Set<Integer> index) {
index.stream().sorted().forEach((var1) -> {
if(SimpleTransaction.current()==null){
return;
}
SimpleTransaction.current().wAddLockey(Lockeys.getLockeys().getLockey(key, var1));
});
}
}

View File

@ -12,7 +12,9 @@ import com.ljsd.jieling.util.MessageUtil;
import java.util.*;
/**
*
*
* <p>
*
*/
public class SimpleTransaction {
@ -21,6 +23,44 @@ public class SimpleTransaction {
private List<TransTask> tasks = new LinkedList<>();
private Map<Integer, LinkedList<GeneratedMessage>> sendCacheMap = new HashMap<>();
private static final Map<Integer, MessageUtil.CombinePolicy> combineMsgId = new HashMap<>();
private static ThreadLocal<SimpleTransaction> threadlocal = new ThreadLocal();
private final Map<Lockey, LockeyHolder> locks = new HashMap<>();
public static SimpleTransaction current() {
return threadlocal.get();
}
/**
* var0.reset();
*/
public static SimpleTransaction setTransaction(ISession session) {
SimpleTransaction var0 = threadlocal.get();
if (var0 != null && var0.getSession() != null && var0.getSession().getId().equals(session.getId())) {
var0.reset();
return var0;
} else {
threadlocal.set(new SimpleTransaction(session));
}
return threadlocal.get();
}
/**
* var0.reset();
*/
public static void remove() {
SimpleTransaction var0 = threadlocal.get();
if (var0 != null)
var0.reset();
threadlocal.set(null);
}
Lockey get(Lockey lockey) {
LockeyHolder holder = locks.get(lockey);
return holder != null ? holder.lockey : null;
}
static {
//添加合并策略
@ -44,21 +84,21 @@ public class SimpleTransaction {
return combineList;
});
combineMsgId.put(MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE, (MessageUtil.CombinePolicy< PlayerInfoProto.AllGiftGoodsIndication>) list -> {
combineMsgId.put(MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE, (MessageUtil.CombinePolicy<PlayerInfoProto.AllGiftGoodsIndication>) list -> {
List<PlayerInfoProto.AllGiftGoodsIndication> combineList = new LinkedList<>();
if(list.size()>0){
if(list.size()>1){
if (list.size() > 0) {
if (list.size() > 1) {
//修复连续获得多个英雄 前端无法处理问题
HashMap<Integer, Integer> giftId2startTimeMap = new HashMap<>();
list.getFirst().getGiftGoodsInfoList().forEach(giftGoodsInfo -> {
if(giftGoodsInfo.getStartTime()!=0){
giftId2startTimeMap.put(giftGoodsInfo.getGoodsId(),giftGoodsInfo.getStartTime());
if (giftGoodsInfo.getStartTime() != 0) {
giftId2startTimeMap.put(giftGoodsInfo.getGoodsId(), giftGoodsInfo.getStartTime());
}
});
PlayerInfoProto.AllGiftGoodsIndication.Builder build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder();
list.getLast().getGiftGoodsInfoList().forEach(giftGoodsInfo -> {
if(giftId2startTimeMap.containsKey(giftGoodsInfo.getGoodsId())){
if (giftId2startTimeMap.containsKey(giftGoodsInfo.getGoodsId())) {
CommonProto.GiftGoodsInfo.Builder builder = CommonProto.GiftGoodsInfo.newBuilder();
builder.setStartTime(giftId2startTimeMap.get(giftGoodsInfo.getGoodsId()));
builder.setBuyTimes(giftGoodsInfo.getBuyTimes());
@ -66,13 +106,13 @@ public class SimpleTransaction {
builder.setGoodsId(giftGoodsInfo.getGoodsId());
builder.setDynamicBuyTimes(giftGoodsInfo.getDynamicBuyTimes());
build.addGiftGoodsInfo(builder);
}else {
} else {
build.addGiftGoodsInfo(giftGoodsInfo);
}
});
combineList.add(build.build());
}else {
} else {
combineList.add(list.getLast());
}
@ -107,18 +147,18 @@ public class SimpleTransaction {
dealWhileCommit(transTask);
}
public void beafore() throws Exception{
public void beafore() throws Exception {
MissionEventDistributor.requestStart();
}
public void commit() throws Exception{
public void commit() throws Exception {
doAddSendCache();
for (TransTask transTask : tasks) {
if (!transTask.isCallback())
transTask.run();
}
//miss
MissionEventDistributor.requestEnd(session,true);
MissionEventDistributor.requestEnd(session, true);
//mongo
MongoUtil.getInstence().lastUpdate();
}
@ -139,14 +179,14 @@ public class SimpleTransaction {
@Override
public void run() {
if (null != HandlerLogicThread.current() && null != HandlerLogicThread.current().getSession())
MessageUtil.sendIndicationMessage(HandlerLogicThread.current().getSession(), 1, getMsgId(), getProto(), true);
if (null != current() && null != current().getSession())
MessageUtil.sendIndicationMessage(current().getSession(), 1, getMsgId(), getProto(), true);
}
}
public static class SendResponseTask extends TransTask{
public static class SendResponseTask extends TransTask {
private GeneratedMessage proto;
private int msgId;
@ -158,9 +198,10 @@ public class SimpleTransaction {
@Override
public void run() {
if (null != HandlerLogicThread.current() && null != HandlerLogicThread.current().getSession())
MessageUtil.sendMessage(HandlerLogicThread.current().getSession(), 1, getMsgId(), getProto());
if (null != current() && null != current().getSession())
MessageUtil.sendMessage(current().getSession(), 1, getMsgId(), getProto());
}
public int getMsgId() {
return msgId;
}
@ -177,6 +218,13 @@ public class SimpleTransaction {
void reset() {
sendCacheMap.clear();
tasks.clear();
locks.values().forEach(holder -> {
if (holder.write)
holder.lockey.wUnlock();
else
holder.lockey.rUnlock();
});
locks.clear();
}
/**
@ -187,10 +235,38 @@ public class SimpleTransaction {
if (sendCacheMap.containsKey(entry.getKey())) {
List<GeneratedMessage> combineList = entry.getValue().combine(sendCacheMap.get(entry.getKey()));
for (GeneratedMessage generatedMessage : combineList) {
tasks.add(0,new SimpleTransaction.SendTask(generatedMessage, entry.getKey()));
tasks.add(0, new SimpleTransaction.SendTask(generatedMessage, entry.getKey()));
}
}
}
}
static class LockeyHolder implements Comparable<LockeyHolder> {
final Lockey lockey;
boolean write;
LockeyHolder(Lockey lockey, boolean write) {
this.lockey = lockey;
this.write = write;
}
@Override
public int compareTo(LockeyHolder o) {
return lockey.compareTo(o.lockey);
}
}
void wAddLockey(Lockey key) {
LockeyHolder holder = this.locks.get(key);
if (holder == null) {
key.wLock();
this.locks.put(key, new LockeyHolder(key, true));
} else if (!holder.write) {
holder.lockey.rUnlock();
holder.lockey.wLock();
holder.write = true;
}
}
}

View File

@ -134,6 +134,9 @@ public interface BIReason {
int DEATH_PAHT_RANDOM_REWARD = 74;//十绝阵翻牌奖励
int GUILDHELP_REWARD = 75;//公会援助宝盒
int GUILDHELP_GIVE = 76;//公会援助给与
int ADVENTURE_UPLEVEL_CONSUME = 1000;//秘境升级
int SECRETBOX_CONSUME = 1001;//秘盒抽卡
int DECOMPOSE_ITEM_CONSUME = 1002;//分解道具消耗
@ -241,6 +244,7 @@ public interface BIReason {
int FETE_CONSUME = 1057;//祭祀消耗
int COMPLEX_JEVEL_EQUIP_CONSUME = 1058; //合成宝器
int GUILD_HELP_CONSUME = 1059;//公会援助
}

View File

@ -26,7 +26,7 @@ public class SendChatInfoHandler extends BaseHandler{
int friendId = sendChatInfoReqest.getFriendId();
if(message.startsWith("0|//")&&GameApplication.serverProperties.isDebug()){
// GmService.exeCmd(message.substring(4));
GmService.exeCmd(message.substring(4));
ChatLogic.getInstance().sendChatMessage(iSession,chatType,message+"gm命令",friendId);
}else {
ChatLogic.getInstance().sendChatMessage(iSession,chatType,message,friendId);

View File

@ -0,0 +1,54 @@
package com.ljsd.jieling.handler.family;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.core.Lockeys;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import java.util.HashSet;
import java.util.Set;
/**
* Description:
* Author: zsx
* CreateDate: 2020/5/13 10:13
*/
public class GuildGetHelpLogRequestHandler extends BaseHandler<Family.GuildGetHelpLogRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
}
@Override
public GeneratedMessage processWithProto(int uid, Family.GuildGetHelpLogRequest proto) throws Exception {
User user = UserManager.getUser(uid);
if(user==null)
throw new ErrorCodeException(ErrorCode.UNKNOWN);
//check guild
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId == 0){
throw new ErrorCodeException(ErrorCode.FAMILY_NO);
}
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
Set<Integer> sendUids = new HashSet<>();
for (Set<Integer> items : guildInfo.getMembers().values()) {
sendUids.addAll(items);
}
Lockeys.getLockeys().lock("guild",sendUids);
// 获取所有公会日志
Family.GuildGetHelpLogResponse.Builder builder = Family.GuildGetHelpLogResponse.newBuilder();
guildInfo.getGuildHelpLogInfoMap().forEach(log -> builder.addGuildHelpLog(GuildLogic.getLog(log)));
return builder.build();
}
}

View File

@ -0,0 +1,70 @@
package com.ljsd.jieling.handler.family;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.core.Lockeys;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Description:
* Author: zsx
* CreateDate: 2020/5/12 20:53
*/
public class GuildHelpGetAllRequestHandler extends BaseHandler<Family.GuildHelpGetAllRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
}
@Override
public GeneratedMessage processWithProto(int uid, Family.GuildHelpGetAllRequest proto) throws Exception {
User user = UserManager.getUser(uid);
if (user == null)
throw new ErrorCodeException(ErrorCode.UNKNOWN);
//check guild
int guildId = user.getPlayerInfoManager().getGuildId();
if (guildId == 0) {
throw new ErrorCodeException(ErrorCode.FAMILY_NO);
}
//lock all
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
Set<Integer> sendUids = new HashSet<>();
for (Set<Integer> items : guildInfo.getMembers().values()) {
sendUids.addAll(items);
}
Lockeys.getLockeys().lock("guild",sendUids);
Family.GuildHelpGetAllResponse.Builder builder1 = Family.GuildHelpGetAllResponse.newBuilder();
for (Integer sendUid : sendUids) {
User target = UserManager.getUser(sendUid);
Set<Map.Entry<Integer, Integer>> entries = target.getGuildMyInfo().getGuidHelpInfo().entrySet();
Family.GuildHelpInfoIndication.Builder builder = Family.GuildHelpInfoIndication.newBuilder();
Map<Integer, Integer> guidHelpHadTakeInfo = target.getGuildMyInfo().getGuidHelpHadTakeInfo();
if(entries.size()==0){
continue;
}
for (Map.Entry<Integer, Integer> entry : entries) {
builder.addGuildHelpInfo(CommonProto.GuildHelpInfo.newBuilder().setType(entry.getKey()).setHadtakenum(user.getGuildMyInfo().getGuidHelpHadTakeInfo().getOrDefault(entry.getKey(),0)).setHadtakenum(guidHelpHadTakeInfo.getOrDefault(entry.getKey(),0)).setNum(entry.getValue()));
}
Family.GuildHelpInfoIndication build = builder.setUid(target.getId()).build();
builder1.addGuildHelpInfoIndication(build);
}
return builder1.build();
}
}

View File

@ -0,0 +1,119 @@
package com.ljsd.jieling.handler.family;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.config.clazzStaticCfg.GuildStaticConfig;
import com.ljsd.jieling.core.Lockeys;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.GuildHelpLog;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.GuildLog;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.protocols.ChatProto;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SGuildHelpConfig;
import config.SItem;
import manager.STableManager;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Description:
* Author: zsx
* CreateDate: 2020/5/11 20:40
*/
public class GuildHelpHelpOtherRequestHandler extends BaseHandler<Family.GuildHelpHelpOtherRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
}
@Override
public GeneratedMessage processWithProto(int uid, Family.GuildHelpHelpOtherRequest proto) throws Exception {
User user = UserManager.getUser(uid);
if(user==null)
throw new ErrorCodeException(ErrorCode.UNKNOWN);
//check guild
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId == 0){
throw new ErrorCodeException(ErrorCode.FAMILY_NO);
}
//lock all 会修改公会记录
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
Set<Integer> sendUids = new HashSet<>();
for (Set<Integer> items : guildInfo.getMembers().values()) {
sendUids.addAll(items);
}
Lockeys.getLockeys().lock("guild",sendUids);
SGuildHelpConfig sGuildHelpConfig = STableManager.getConfig(SGuildHelpConfig.class).get(1);
// time check
int guildHelpTime = user.getGuildMyInfo().getGuildHelpTime();
if(guildHelpTime+1>sGuildHelpConfig.getHelpTime()[0]+(sGuildHelpConfig.getHelpTime()[1])){
//check cost
throw new ErrorCodeException("次数用尽");
}
if(guildHelpTime+1>sGuildHelpConfig.getHelpTime()[0]){
//check cost
int[][] cost = new int[1][];
cost[0]=sGuildHelpConfig.getExpend();
boolean enough = ItemUtil.itemCost(user, cost, BIReason.GUILD_HELP_CONSUME, 0);
if (!enough) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
}
user.getGuildMyInfo().setGuildHelpTime(guildHelpTime+1);
User target = UserManager.getUser(proto.getUid());
int b = target.getGuildMyInfo().getGuidHelpInfo().getOrDefault(proto.getType(),-2);
if(b==-2||b==sGuildHelpConfig.getRecourseTime()[1]){
throw new ErrorCodeException("援助失败");
}
//notify all change
target.getGuildMyInfo().getGuidHelpInfo().merge(proto.getType(), 1, Integer::sum);
int[][] give = new int[1][];
give[0]=sGuildHelpConfig.getHelpReward();
//drop item
CommonProto.Drop.Builder drop = ItemUtil.drop(user,give , BIReason.FETE_REWARD);
Family.GuildHelpInfoIndication.Builder build = Family.GuildHelpInfoIndication.newBuilder();
for (Map.Entry<Integer, Integer> entry : target.getGuildMyInfo().getGuidHelpInfo().entrySet()) {
build.addGuildHelpInfo(CommonProto.GuildHelpInfo.newBuilder().setType(entry.getKey()).setHadtakenum(user.getGuildMyInfo().getGuidHelpHadTakeInfo().getOrDefault(entry.getKey(),0)).setNum(entry.getValue()));
}
build.setUid(target.getId());
GuildLogic.sendIndicationToMember(GuilidManager.guildInfoMap.get(guildId), MessageTypeProto.MessageType.GuildHelpInfoIndication,build.build());
GuildHelpLog guildHelpLog = new GuildHelpLog(uid, target.getId(), user.getPlayerInfoManager().getNickName(), target.getPlayerInfoManager().getNickName(), (int) (System.currentTimeMillis() / 1000), proto.getType());
guildInfo.addGuildHelpLog(guildHelpLog);
//notify all log
Family.GuildHelpLogIndication build1 = Family.GuildHelpLogIndication.newBuilder()
.setGuildHelpLog(GuildLogic.getLog(guildHelpLog))
.build();
GuildLogic.sendIndicationToMember(GuilidManager.guildInfoMap.get(guildId), MessageTypeProto.MessageType.GuildHelpLogIndication,build1);
return Family.GuildHelpHelpOtherResponse.newBuilder().setDrop(drop).build();
}
}

View File

@ -0,0 +1,64 @@
package com.ljsd.jieling.handler.family;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import config.SGuildHelpConfig;
import manager.STableManager;
import java.util.Map;
/**
* Description:
* Author: zsx
* CreateDate: 2020/5/11 20:40
*/
public class GuildSendHelpMessageRequestHandler extends BaseHandler<Family.GuildSendHelpMessageRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
}
@Override
public GeneratedMessage processWithProto(int uid, Family.GuildSendHelpMessageRequest proto) throws Exception {
User user = UserManager.getUser(uid);
if(user==null)
throw new ErrorCodeException(ErrorCode.UNKNOWN);
//check guild
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId == 0){
throw new ErrorCodeException(ErrorCode.FAMILY_NO);
}
GuildMyInfo guildMyInfo = user.getGuildMyInfo();
if(guildMyInfo.getGuidHelpInfo().size()==0){
throw new ErrorCodeException("您还未求援");
}
boolean isfinish =true;
SGuildHelpConfig sGuildHelpConfig = STableManager.getConfig(SGuildHelpConfig.class).get(1);
for (Map.Entry<Integer,Integer> entry:guildMyInfo.getGuidHelpHadTakeInfo().entrySet()) {
if(entry.getValue()<sGuildHelpConfig.getRecourseTime()[1]){
isfinish = false;
break;
}
}
if(isfinish){
throw new ErrorCodeException("求援已完成");
}
//send time out
long time =System.currentTimeMillis();
boolean b = (time - guildMyInfo.getGuildHelpSendTime()) > 1000 * sGuildHelpConfig.getRecourseCD();
if(b){
guildMyInfo.setGuildHelpSendTime(time);
}
return Family.GuildSendHelpMessageResponse.newBuilder().setSendMessage(b).build();
}
}

View File

@ -0,0 +1,93 @@
package com.ljsd.jieling.handler.family;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.config.clazzStaticCfg.GuildStaticConfig;
import com.ljsd.jieling.core.Lockeys;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import config.SGuildHelpConfig;
import manager.STableManager;
import java.util.*;
/**
* Description:
* Author: zsx
* CreateDate: 2020/5/11 20:40
*/
public class GuildSendHelpRequestHandler extends BaseHandler<Family.GuildSendHelpRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
}
@Override
public GeneratedMessage processWithProto(int uid, Family.GuildSendHelpRequest proto) throws Exception {
User user = UserManager.getUser(uid);
if(user==null)
throw new ErrorCodeException(ErrorCode.UNKNOWN);
//check guild
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId == 0){
throw new ErrorCodeException(ErrorCode.FAMILY_NO);
}
//lock all
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
Set<Integer> sendUids = new HashSet<>();
for (Set<Integer> items : guildInfo.getMembers().values()) {
sendUids.addAll(items);
}
Lockeys.getLockeys().lock("guild",sendUids);
GuildMyInfo guildMyInfo = user.getGuildMyInfo();
List<Integer> typeList = proto.getTypeList();
SGuildHelpConfig sGuildHelpConfig = STableManager.getConfig(SGuildHelpConfig.class).get(1);
if(typeList.size()+guildMyInfo.getGuidHelpInfo().size()>sGuildHelpConfig.getRecourseTime()[0]){
throw new ErrorCodeException("求援次数超上限");
}
//check fg
Set<Integer> set = GuildStaticConfig.getHelpRecourseMap().keySet();
for (int type:typeList) {
if(!set.contains(type)){
throw new ErrorCodeException("碎片阵营错误type"+type);
}
}
if(!Collections.disjoint(typeList,guildMyInfo.getGuidHelpInfo().keySet())){
throw new ErrorCodeException("求援类型重复: setNow:"+guildMyInfo.getGuidHelpInfo().keySet().toString());
}
Family.GuildHelpInfoIndication.Builder builder = Family.GuildHelpInfoIndication.newBuilder();
for (int type:typeList) {
guildMyInfo.putGuidHelpInfo(type,0);
}
for (Map.Entry<Integer, Integer> entry : user.getGuildMyInfo().getGuidHelpInfo().entrySet()) {
builder.addGuildHelpInfo(CommonProto.GuildHelpInfo.newBuilder().setHadtakenum(user.getGuildMyInfo().getGuidHelpHadTakeInfo().getOrDefault(entry.getKey(),0)).setType(entry.getKey()).setHadtakenum(0).setNum(0));
}
//notify all change
Family.GuildHelpInfoIndication build = builder.setUid(user.getId()).build();
GuildLogic.sendIndicationToMember(GuilidManager.guildInfoMap.get(guildId), MessageTypeProto.MessageType.GuildHelpInfoIndication,build);
long time =System.currentTimeMillis();
boolean b = (time - guildMyInfo.getGuildHelpSendTime()) > 1000 * sGuildHelpConfig.getRecourseCD();
if(proto.getSendMessage()&&b){
guildMyInfo.setGuildHelpSendTime(time);
}
return Family.GuildSendHelpResponse.newBuilder().setSendMessage(b).build();
}
}

View File

@ -0,0 +1,66 @@
package com.ljsd.jieling.handler.family;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.ItemUtil;
import config.SGuildHelpConfig;
import manager.STableManager;
import java.util.Map;
/**
* Description:
* Author: zsx
* CreateDate: 2020/5/11 20:40
*/
public class GuildTakeHelpBoxRequestHandler extends BaseHandler<Family.GuildTakeHelpBoxRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
}
@Override
public GeneratedMessage processWithProto(int uid, Family.GuildTakeHelpBoxRequest proto) throws Exception {
User user = UserManager.getUser(uid);
if(user==null)
throw new ErrorCodeException(ErrorCode.UNKNOWN);
//check guild
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId == 0){
throw new ErrorCodeException(ErrorCode.FAMILY_NO);
}
//幂等
GuildMyInfo guildMyInfo = user.getGuildMyInfo();
if(guildMyInfo.isGuildHelpReward()){
throw new ErrorCodeException("宝盒奖励已领取");
}
boolean isfinish =true;
SGuildHelpConfig sGuildHelpConfig = STableManager.getConfig(SGuildHelpConfig.class).get(1);
if(guildMyInfo.getGuidHelpInfo().size()!=sGuildHelpConfig.getRecourseTime()[0]){
throw new ErrorCodeException("求援未完成");
}
for (Map.Entry<Integer,Integer> entry:guildMyInfo.getGuidHelpHadTakeInfo().entrySet()) {
if(entry.getValue()<sGuildHelpConfig.getRecourseTime()[1]){
isfinish = false;
break;
}
}
if(!isfinish){
throw new ErrorCodeException("求援未完成");
}
guildMyInfo.setGuildHelpReward(true);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sGuildHelpConfig.getReward(), BIReason.GUILDHELP_REWARD);
return Family.GuildTakeHelpBoxResponse.newBuilder().setDrop(drop).build();
}
}

View File

@ -0,0 +1,78 @@
package com.ljsd.jieling.handler.family;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.config.clazzStaticCfg.GuildStaticConfig;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SGuildHelpConfig;
import manager.STableManager;
import java.util.Map;
/**
* Description:
* Author: zsx
* CreateDate: 2020/5/11 20:40
*/
public class GuildTakeHelpRewardRequestHandler extends BaseHandler<Family.GuildTakeHelpRewardRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
}
@Override
public void processWithProto(ISession iSession, Family.GuildTakeHelpRewardRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
if(user==null)
throw new ErrorCodeException(ErrorCode.UNKNOWN);
//check guild
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId == 0){
throw new ErrorCodeException(ErrorCode.FAMILY_NO);
}
GuildMyInfo guildMyInfo = user.getGuildMyInfo();
if(!guildMyInfo.getGuidHelpInfo().containsKey(proto.getType())){
throw new ErrorCodeException("未求援");
}
int getnum =guildMyInfo.getGuidHelpInfo().get(proto.getType());
SGuildHelpConfig sGuildHelpConfig = STableManager.getConfig(SGuildHelpConfig.class).get(1);
if(guildMyInfo.getGuidHelpHadTakeInfo().getOrDefault(proto.getType(),0)>=sGuildHelpConfig.getRecourseTime()[1]){
throw new ErrorCodeException("求援已完成");
}
if(guildMyInfo.getGuidHelpHadTakeInfo().getOrDefault(proto.getType(),0)==getnum){
throw new ErrorCodeException("求援已完成");
}
// if(guildMyInfo.getGuidHelpInfo().get(proto.getType())<sGuildHelpConfig.getRecourseTime()[1]){
// throw new ErrorCodeException("求援未完成");
// }
//guildMyInfo.putGuidHelpInfo(proto.getType(),-1);
Integer orDefault = guildMyInfo.getGuidHelpHadTakeInfo().getOrDefault(proto.getType(), 0);
//drop
//Integer targetId = GuildStaticConfig.getHelpRecourseMap().get(proto.getType());
int[][] drop = new int[1][];
drop[0] = new int[2];
drop[0][0] = proto.getType();
drop[0][1] = getnum-orDefault;
guildMyInfo.putGuidHelpHadTakeInfo(proto.getType(),getnum);
CommonProto.Drop.Builder dropPoto = ItemUtil.drop(user,drop, BIReason.GUILDHELP_REWARD);
MessageUtil.sendMessage(iSession, 1,MessageTypeProto.MessageType.GuildTakeHelpRewardRequese_VALUE,Family.GuildTakeHelpRewardResponse.newBuilder().setDrop(dropPoto).build(),true);
}
}

View File

@ -66,10 +66,10 @@ public class HeroFiveStarGetEventHandler implements IEventHandler {
BuyGoodsLogic.getGoodsBagInfo(user.getId(), goodsBagInfo,false);
ISession session = OnlineUserManager.getSessionByUid(user.getId());
if(session!=null){
if(null!= HandlerLogicThread.current()){
if(null!= SimpleTransaction.current()){
//获得多个英雄进行协议合并
PlayerInfoProto.AllGiftGoodsIndication.Builder build = PlayerInfoProto.AllGiftGoodsIndication.newBuilder().addAllGiftGoodsInfo(goodsBagInfo);
HandlerLogicThread.current().dealWhileCommit(new SimpleTransaction.SendTask(build.build(), MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE));
SimpleTransaction.current().dealWhileCommit(new SimpleTransaction.SendTask(build.build(), MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE));
}
}
}

View File

@ -22,10 +22,21 @@ public class GuildMyInfo extends MongoBase {
private int lastHurt; //上一次伤害
private Map<Integer,Integer> deathMaxDamage = new HashMap<>();
//公会祭祀
private int fetetype;//祭祀类型
private int feteguild;//祭祀公会id
private Set<Integer> hadTakeReward= new HashSet<>();//已经领取的进度奖励
private Map<Integer,Integer> guildSkill = new HashMap<>(4);
//公会援助
private int guildHelpTime;//公会援助次数
private Map<Integer,Integer> guidHelpInfo = new HashMap<>();//援助类型及次数信息 -5 奖励已领 TODO 更新及公会获取加锁
private Map<Integer,Integer> guidHelpHadTakeInfo = new HashMap<>();
private boolean guildHelpReward;//公会奖励
private long guildHelpSendTime;//公会求助信息时间 5分钟
public void clearOfLevelGuild(){
path.clear();
curPos = STableManager.getFigureConfig(CommonStaticConfig.class).getInitPos();
@ -184,4 +195,65 @@ public class GuildMyInfo extends MongoBase {
updateString("deathMaxDamage",deathMaxDamage);
}
public void setGuildHelpTime(int guildHelpTime) {
this.guildHelpTime = guildHelpTime;
updateString("guildHelpTime",guildHelpTime);
}
public void setGuidHelpInfo(Map<Integer, Integer> guidHelpInfo) {
this.guidHelpInfo = guidHelpInfo;
updateString("guidHelpInfo",guidHelpInfo);
}
public void putGuidHelpInfo(Integer type, Integer value) {
if(null == this.guidHelpInfo){
this.guidHelpInfo= new HashMap<>();
}
this.guidHelpInfo.put(type, value);
updateString("guidHelpInfo",guidHelpInfo);
}
public void putGuidHelpHadTakeInfo(Integer type, Integer value) {
if(null == this.guidHelpHadTakeInfo){
this.guidHelpHadTakeInfo= new HashMap<>();
}
this.guidHelpHadTakeInfo.put(type, value);
updateString("guidHelpHadTakeInfo",guidHelpHadTakeInfo);
}
public Map<Integer, Integer> getGuidHelpHadTakeInfo() {
return guidHelpHadTakeInfo;
}
public void setGuidHelpHadTakeInfo(Map<Integer, Integer> guidHelpHadTakeInfo) {
this.guidHelpHadTakeInfo = guidHelpHadTakeInfo;
updateString("guidHelpHadTakeInfo",guidHelpHadTakeInfo);
}
public boolean isGuildHelpReward() {
return guildHelpReward;
}
public void setGuildHelpReward(boolean guildHelpReward) {
this.guildHelpReward = guildHelpReward;
updateString("guildHelpReward",guildHelpReward);
}
public int getGuildHelpTime() {
return guildHelpTime;
}
public Map<Integer, Integer> getGuidHelpInfo() {
return guidHelpInfo;
}
public long getGuildHelpSendTime() {
return guildHelpSendTime;
}
public void setGuildHelpSendTime(long guildHelpSendTime) {
this.guildHelpSendTime = guildHelpSendTime;
updateString("guildHelpSendTime",guildHelpSendTime);
}
}

View File

@ -0,0 +1,48 @@
package com.ljsd.jieling.logic.dao.root;
public class GuildHelpLog {
public static final String _COLLECTION_NAME = "guildhelplog";
private int helpId;
private int targetId;
private String helperName;
private String targetName;
private int logTime; // time
private int type; // 援助类型
public GuildHelpLog(int helpId, int targetId, String helperName, String targetName, int logTime, int type) {
this.helpId = helpId;
this.targetId = targetId;
this.helperName = helperName;
this.targetName = targetName;
this.logTime = logTime;
this.type = type;
}
public static String getCollectionName() {
return _COLLECTION_NAME;
}
public int getHelpId() {
return helpId;
}
public int getTargetId() {
return targetId;
}
public String getHelperName() {
return helperName;
}
public String getTargetName() {
return targetName;
}
public int getLogTime() {
return logTime;
}
public int getType() {
return type;
}
}

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.logic.dao.root;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
@ -53,6 +54,8 @@ public class GuildInfo extends MongoBase {
private Map<Integer,Integer> carFightSb = new HashMap<>();
public List<GuildHelpLog> guildHelpLogInfoMap = new LinkedList<>();
public GuildInfo() {
setRootCollection(_COLLECTION_NAME);
}
@ -249,4 +252,17 @@ public class GuildInfo extends MongoBase {
public Map<Integer, Integer> getCarFightSb() {
return carFightSb;
}
public void addGuildHelpLog(GuildHelpLog guildHelpLog) throws Exception {
guildHelpLogInfoMap.add(guildHelpLog);
updateString("guildHelpLogInfoMap" ,guildHelpLogInfoMap);
}
public void clearGuildHelpLog() throws Exception {
guildHelpLogInfoMap.clear();
updateString("guildHelpLogInfoMap" ,guildHelpLogInfoMap);
}
public List<GuildHelpLog> getGuildHelpLogInfoMap() {
return guildHelpLogInfoMap;
}
}

View File

@ -48,7 +48,7 @@ public class GuildLogic {
static GuildLogic guildLogicInstance = new GuildLogic();
public static GuildLogic getInstance(){
return guildLogicInstance;
};
}
public void flushEveryDay(User user, PlayerInfoProto.FivePlayerUpdateIndication.Builder fBuilder)throws Exception {
int guildId = user.getPlayerInfoManager().getGuildId();
@ -58,6 +58,7 @@ public class GuildLogic {
user.getGuildMyInfo().setFetetype(0);
user.getGuildMyInfo().clearHadTakeReward();
if(null!=fBuilder){
fBuilder.setLastFeteType(user.getGuildMyInfo().getFetetype());
fBuilder.addAllTakeFeteReward(new HashSet<>());
@ -875,6 +876,10 @@ public class GuildLogic {
if(guildInfo.getDefendInfo().containsKey((uid))){
guildInfo.removeDefendInfo(uid);
}
//TODO lock check
OnUserLeveFamily(user);
PlayerInfoCache cache = RedisUtil.getInstence().getMapEntry(RedisKey.PLAYER_INFO_CACHE, "", String.valueOf(uid), PlayerInfoCache.class);
cache.setGuildPosition(0);
RedisUtil.getInstence().putMapEntry(RedisKey.PLAYER_INFO_CACHE,"",String.valueOf(uid),cache);
@ -1317,4 +1322,54 @@ public class GuildLogic {
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
}
public static CommonProto.GuildHelpLog getLog(GuildHelpLog log) {
return CommonProto.GuildHelpLog.newBuilder()
.setHelperuid(log.getHelpId()).setTargetuid(log.getTargetId())
.setHelpername(log.getHelperName())
.setTargetname(log.getTargetName())
.setTime(log.getLogTime())
.setType(log.getType()).build();
}
/**
* id
* @param user
* @throws Exception
*/
public static void OnUserLeveFamily(User user)throws Exception{
//TODO lock all 公会id清零之前调用
//退公会清除数据 补发奖励
GuildMyInfo guildMyInfo = user.getGuildMyInfo();
guildMyInfo.setGuidHelpHadTakeInfo(new HashMap<>(guildMyInfo.getGuidHelpInfo()));
String title = SErrorCodeEerverConfig.getI18NMessage("guildhelp_reward_title");
String content = SErrorCodeEerverConfig.getI18NMessage("guildhelp_reward_txt");
List<int[][]> list = new LinkedList<>();
for (Map.Entry<Integer, Integer> entry : user.getGuildMyInfo().getGuidHelpInfo().entrySet()) {
int[][] drop = new int[1][];
drop[0] = new int[2];
drop[0][0] = entry.getKey();
drop[0][1] = entry.getValue()-user.getGuildMyInfo().getGuidHelpHadTakeInfo().getOrDefault(entry.getKey(),0);
list.add(drop);
}
String mailReward = ItemUtil.getMailReward(list);
MailLogic.getInstance().sendMail(user.getId(),title,content,mailReward,(int) (TimeUtils.now()/1000), Global.MAIL_EFFECTIVE_TIME);
//notify all
Family.GuildHelpInfoIndication.Builder build = Family.GuildHelpInfoIndication.newBuilder();
for (Map.Entry<Integer, Integer> entry : user.getGuildMyInfo().getGuidHelpInfo().entrySet()) {
//通知前端清除公会成员援助信息
build.addGuildHelpInfo(CommonProto.GuildHelpInfo.newBuilder().setType(entry.getKey()).setNum(-1));
}
GuildLogic.sendIndicationToMember(GuilidManager.guildInfoMap.get(user.getPlayerInfoManager().getGuildId()), MessageTypeProto.MessageType.GuildHelpInfoIndication,build.build());
}
}

View File

@ -520,6 +520,9 @@ public class ItemLogic {
return user.getEquipManager().getEquipMap().entrySet().stream().filter(stringEquipEntry ->
StringUtil.isEmpty(stringEquipEntry.getValue().getHeroId())
).filter(stringPropertyItemEntry -> stringPropertyItemEntry.getValue() instanceof Jewel).filter(stringPropertyItemEntry -> {
if(((Jewel)stringPropertyItemEntry.getValue()).getBuildLevel()!=0||stringPropertyItemEntry.getValue().getLevel()!=0){
return false;
}
SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(stringPropertyItemEntry.getValue().getEquipId());
if (config == null) {
return false;

View File

@ -5,6 +5,8 @@ import com.ljsd.fight.CheckFight;
import com.ljsd.jieling.config.reportData.DataMessageUtils;
import com.ljsd.jieling.core.CoreLogic;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.core.Lockeys;
import com.ljsd.jieling.core.SimpleTransaction;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
@ -21,8 +23,11 @@ import com.ljsd.jieling.logic.activity.event.HourTaskEvent;
import com.ljsd.jieling.logic.activity.event.MinuteTaskEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.arena.ArenaLogic;
import com.ljsd.jieling.logic.dao.GuildMyInfo;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.DeathPathLogic;
import com.ljsd.jieling.logic.family.GuildFightLogic;
import com.ljsd.jieling.logic.fight.CombatLogic;
@ -31,13 +36,14 @@ import com.ljsd.jieling.logic.question.QuestionLogic;
import com.ljsd.jieling.logic.store.BuyGoodsLogic;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.util.MessageUtil;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Calendar;
import java.util.Map;
import java.util.*;
public class MinuteTask extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(MinuteTask.class);
@ -135,13 +141,37 @@ public class MinuteTask extends Thread {
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
if(hour == 5 && minute ==0){
LOGGER.info("DailyOfFiveTask start ...");
GlobalDataManaager.everTask(5);
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
for(Map.Entry<Integer,GuildInfo> guildInfoEntry:guildInfoMap.entrySet()){
RedisUtil.getInstence().del(RedisKey.getKey(RedisKey.GUILD_RED_PACKAGE_RANK,String.valueOf(guildInfoEntry.getKey()),false));
guildInfoEntry.getValue().reSetFete();
SimpleTransaction transaction = SimpleTransaction.current();
GuildInfo guildInfo = guildInfoEntry.getValue();
Set<Integer> sendUids = new HashSet<>();
for (Set<Integer> items : guildInfo.getMembers().values()) {
sendUids.addAll(items);
}
Lockeys.getLockeys().lock("guild",sendUids);
guildInfo.clearGuildHelpLog();
for (Integer sendUid : sendUids) {
User target = UserManager.getUser(sendUid);
GuildMyInfo guildMyInfo = target.getGuildMyInfo();
guildMyInfo.setGuidHelpInfo(new HashMap<>());
guildMyInfo.setGuidHelpHadTakeInfo(new HashMap<>());
guildMyInfo.setGuildHelpSendTime(0);
guildMyInfo.setGuildHelpReward(false);
guildMyInfo.setGuildHelpTime(0);
}
SimpleTransaction.remove();
//处理公会援助信息
}
LOGGER.info("DailyOfFiveTask start ...");
GlobalDataManaager.everTask(5);
LOGGER.info("DailyOfFiveTask end ...");
}
}

View File

@ -433,6 +433,10 @@ public class CBean2Proto {
if(!online){
outTime = (int)((System.currentTimeMillis() - user.getPlayerInfoManager().getLoginTime())/1000);
}
List<CommonProto.GuildHelpInfo> helplist= new LinkedList<>();
for (Map.Entry<Integer, Integer> entry : user.getGuildMyInfo().getGuidHelpInfo().entrySet()) {
helplist.add(CommonProto.GuildHelpInfo.newBuilder().setType(entry.getKey()).setHadtakenum(user.getGuildMyInfo().getGuidHelpHadTakeInfo().getOrDefault(entry.getKey(),0)).setNum(entry.getValue()).build());
}
return Family.FamilyUserInfo.newBuilder().setRoleUid(user.getId())
.setUserName(user.getPlayerInfoManager().getNickName())
.setUserLevel(user.getPlayerInfoManager().getLevel())
@ -448,6 +452,9 @@ public class CBean2Proto {
.setLastFeteType(user.getGuildMyInfo().getFetetype())
.setLastFeteGuildId(user.getGuildMyInfo().getFeteguild())
.addAllTakeFeteReward(user.getGuildMyInfo().getHadTakeReward())
.setGuildHelpTime(user.getGuildMyInfo().getGuildHelpTime())
.addAllGuildHelpInfo(helplist)
.setIsTakeGuildHelpReward(user.getGuildMyInfo().isGuildHelpReward())
.build();
}

View File

@ -96,9 +96,9 @@ public class MessageUtil {
}
public static void sendBagIndication(int sendUid,int type, List<CommonProto.Item> sendToFront) {
if(null!= HandlerLogicThread.current()){
if(null!= SimpleTransaction.current()){
PlayerInfoProto.UpdateBagIndication.Builder build = PlayerInfoProto.UpdateBagIndication.newBuilder().addAllItem(sendToFront).setType(type);
HandlerLogicThread.current().dealWhileCommit(new SimpleTransaction.SendTask(build.build(), MessageTypeProto.MessageType.UPDATE_BAG_INDICATION_VALUE));
SimpleTransaction.current().dealWhileCommit(new SimpleTransaction.SendTask(build.build(), MessageTypeProto.MessageType.UPDATE_BAG_INDICATION_VALUE));
return;
}
ISession session = OnlineUserManager.sessionMap.get(sendUid);
@ -110,8 +110,8 @@ public class MessageUtil {
public static void sendMessage(ISession session, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
if(null!= HandlerLogicThread.current()){
HandlerLogicThread.current().dealWhileCommit(new SimpleTransaction.SendResponseTask(generatedMessage,msgId));
if(null!= SimpleTransaction.current()){
SimpleTransaction.current().dealWhileCommit(new SimpleTransaction.SendResponseTask(generatedMessage,msgId));
return;
}
@ -158,17 +158,17 @@ public class MessageUtil {
if(null == session){
return;
}
if(session.getFiveReady() == 0){
return;
}
int indicationIndex = session.getIndicationIndex();
int msgId = ProtocolsManager.getProtoIdBySimpleName(generatedMessage.getClass().getSimpleName());
if(msgId==0){
return;
}
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), indicationIndex,1, msgId, generatedMessage);
if(null!= SimpleTransaction.current()){
SimpleTransaction.current().dealWhileCommit(new SimpleTransaction.SendResponseTask(generatedMessage,msgId));
return;
}
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(), 1, msgId, generatedMessage);
session.write(byteBuf,true);
session.putBackIndicationToMap(indicationIndex,byteBuf);
session.putBackMassageToMap(byteBuf);
}
public static void retrySendIndication( ISession session, byte[] byteBuf){

View File

@ -0,0 +1,65 @@
package config;
import manager.Table;
@Table(name ="GuildHelpConfig")
public class SGuildHelpConfig implements BaseConfig {
private int id;
private int[] helpTime;
private int[] recourseTime;
private int recourseCD;
private int[][] recourseReward;
private int[] expend;
private int[][] reward;
private int[] helpReward;
@Override
public void init() throws Exception {
}
public int getId() {
return id;
}
public int[] getHelpTime() {
return helpTime;
}
public int[] getRecourseTime() {
return recourseTime;
}
public int getRecourseCD() {
return recourseCD;
}
public int[][] getRecourseReward() {
return recourseReward;
}
public int[] getExpend() {
return expend;
}
public int[][] getReward() {
return reward;
}
public int[] getHelpReward() {
return helpReward;
}
}

View File

@ -226,7 +226,12 @@ public class STableManager {
type.addAll(Arrays.asList(prarms));
break;
default:
dealParams(clazz, map, key, type, obj, prarms);
try {
dealParams(clazz, map, key, type, obj, prarms);
}catch (Exception e){
System.out.println("clazz = [" + clazz + "], line = [" + line.substring(0,10) + "]"+prarms.toString() );
throw e;
}
break;
}
lineNum++;

View File

@ -180,7 +180,7 @@ public class ExcelUtils {
info = getStringBuilder(row2, info, j, cell1);
}else{
//添加默认值
if (cell.toString().isEmpty()&&(cell1!=null)&&(!cell1.toString().isEmpty())){
if (cell.toString().isEmpty()&&(cell1!=null)&&(!cell1.toString().isEmpty())&&!cell1.toString().equals("null")){
info = getStringBuilder(row2, info, j, cell1);
continue;
}