Merge branch 'master' of 60.1.1.230:backend/jieling_server

# Conflicts:
#	serverlogic/src/main/java/com/ljsd/jieling/config/SGlobalSystemConfig.java
back_recharge
wangyuan 2019-09-27 10:21:16 +08:00
commit ac8466f081
6 changed files with 186 additions and 77 deletions

View File

@ -17,6 +17,7 @@ import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.thread.task.DataReportTask;
import com.ljsd.jieling.thrift.idl.InvalidOperException;
import com.ljsd.jieling.thrift.idl.RPCRequestGMIFace;
import com.ljsd.jieling.thrift.idl.Result;
@ -24,11 +25,13 @@ import com.ljsd.jieling.util.*;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.redis.core.ZSetOperations;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
@ -44,6 +47,16 @@ public class GmService implements RPCRequestGMIFace.Iface {
GmInterface obj;
try {
if(cmd.contains("restartthread")){
Field configurableApplicationContextField = GameApplication.class.getDeclaredField("configurableApplicationContext");
configurableApplicationContextField.setAccessible(true);
ConfigurableApplicationContext configurableApplicationContext =(ConfigurableApplicationContext) configurableApplicationContextField.get(GameApplication.class);
DataReportTask bean = configurableApplicationContext.getBean(DataReportTask.class);
bean.start();
result.setResultCode(1);
return result;
}
if(cmd.contains("hotfix")){
List<User> usersInDB = MongoUtil.getLjsdMongoTemplate().findAll("user", User.class);
List<Integer> sendIds = new ArrayList<>(usersInDB.size());
@ -70,6 +83,7 @@ public class GmService implements RPCRequestGMIFace.Iface {
} catch (Exception ex) {
result.setResultMsg("Cmd Illegal");
ex.printStackTrace();
return result;
}
try {

View File

@ -3,17 +3,29 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name ="GuildRewardConfig")
public class SGuildRewardConfig implements BaseConfig {
private int id;
private int rankMin;
private int rankMax;
private String reward;
public static Map<Integer,SGuildRewardConfig> sGuildRewardConfigMap;
public static Map<Integer,String> rewardMap;
@Override
@Override
public void init() throws Exception {
sGuildRewardConfigMap = STableManager.getConfig(SGuildRewardConfig.class);
rewardMap = new HashMap<>();
for(Map.Entry<Integer,SGuildRewardConfig> entry: sGuildRewardConfigMap.entrySet()){
SGuildRewardConfig value = entry.getValue();
for(int i = value.getRankMin(); i<= value.getRankMax(); i++){
rewardMap.put(i, value.getReward());
}
}
}
@ -21,5 +33,15 @@ public class SGuildRewardConfig implements BaseConfig {
return id;
}
public int getRankMin() {
return rankMin;
}
public int getRankMax() {
return rankMax;
}
public String getReward() {
return reward;
}
}

View File

@ -1,7 +1,9 @@
package com.ljsd.jieling.config.reportData;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ljsd.GameApplication;
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
import com.ljsd.jieling.config.json.SDK37Constans;
@ -40,46 +42,65 @@ public class DataMessageUtils {
}
public static void manageData() {
List<Object> sendDataList = new ArrayList<>(10);
logQueue.drainTo(sendDataList, 10);
try {
List<Object> sendDataList = new ArrayList<>(10);
logQueue.drainTo(sendDataList, 10);
List<Object> sendData37List = new ArrayList<>(10);
logQueue_37.drainTo(sendData37List, 10);
List<Object> sendData37List = new ArrayList<>(10);
logQueue_37.drainTo(sendData37List, 10);
if (!sendDataList.isEmpty()) {
KTSendBody sendBody = new KTSendBody(sendDataList);
HttpPool.sendPost(sendUrl, gson.toJson(sendBody));
}
if (!sendDataList.isEmpty()) {
class ExclusionStrategy implements com.google.gson.ExclusionStrategy{
if (!sendData37List.isEmpty() && GameApplication.serverProperties.isSendlog37()) {
for (Object object : sendData37List) {
String sendToUrl;
List<BasicNameValuePair> sendForm = new ArrayList<>();
if (object instanceof Report37TaskBean) {
sendToUrl = sendTaskUrl37;
sendForm = ((Report37TaskBean) object).getPairList();
} else if (object instanceof Report37RoleLeveBean) {
sendToUrl = sendRoleUrl37;
sendForm = ((Report37RoleLeveBean) object).getPairList();
} else {
sendToUrl = "";
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
return "device_id_s".equals(fieldAttributes.getName()) && "ParamEnvironmentBean".equals(fieldAttributes.getDeclaringClass().getSimpleName());
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return false;
}
}
Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy()) // <---
.create();
KTSendBody sendBody = new KTSendBody(sendDataList);
HttpPool.sendPost(sendUrl, gson.toJson(sendBody));
}
if (!sendData37List.isEmpty() && GameApplication.serverProperties.isSendlog37()) {
for (Object object : sendData37List) {
String sendToUrl;
List<BasicNameValuePair> sendForm = new ArrayList<>();
if (object instanceof Report37TaskBean) {
sendToUrl = sendTaskUrl37;
sendForm = ((Report37TaskBean) object).getPairList();
} else if (object instanceof Report37RoleLeveBean) {
sendToUrl = sendRoleUrl37;
sendForm = ((Report37RoleLeveBean) object).getPairList();
} else {
sendToUrl = "";
}
try {
HttpPool.sendPostForm(sendToUrl, new UrlEncodedFormEntity(sendForm, "utf-8"));
} catch (Exception e) {
}
}
}
if (sendDataList.isEmpty() && sendData37List.isEmpty()) {
try {
HttpPool.sendPostForm(sendToUrl, new UrlEncodedFormEntity(sendForm, "utf-8"));
} catch (Exception e) {
Thread.sleep(10);
return;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (sendDataList.isEmpty() && sendData37List.isEmpty()) {
try {
Thread.sleep(10);
return;
} catch (InterruptedException e) {
e.printStackTrace();
}
}catch (Exception e){
e.printStackTrace();
}
}

View File

@ -14,6 +14,7 @@ public interface GlobalsDef {
int MAIL_RED_TYPE = 1; // 邮件红点红点
int SHARE_BOSS_RED_TYPE =2; // 分享外敌boss红点
int ARENA_CHALLENGE_TYPE =3;// 竞技场防守记录红点
int GUILD_APPLY_TYPE = 4;//公会申请红点
int addReason = 0;
int subReason = 1;

View File

@ -1,10 +1,7 @@
package com.ljsd.jieling.logic.family;
import com.ljsd.GameApplication;
import com.ljsd.jieling.config.SArenaSetting;
import com.ljsd.jieling.config.SGuildLevelConfig;
import com.ljsd.jieling.config.SGuildScoreConfig;
import com.ljsd.jieling.config.SGuildSetting;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
@ -25,10 +22,7 @@ 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.FightDataUtil;
import com.ljsd.jieling.util.MathUtils;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.TimeUtils;
import com.ljsd.jieling.util.*;
import org.luaj.vm2.LuaValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -392,6 +386,12 @@ public class GuildFightLogic {
redisUtil.putMapEntry(RedisKey.FAMILY_FIGHT_ATTACK_COUNT,"",String.valueOf(userAttack.getId()),attackCount+1);
FamilyFightInfo defendInfo = redisUtil.getMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(gid), String.valueOf(defendUid), FamilyFightInfo.class);
Map<String, FamilyHeroInfo> heroAttribute = defendInfo.getHeroAttribute();
int aliveHero = 0;
for(Map.Entry<String, FamilyHeroInfo> entry:heroAttribute.entrySet()){
if(entry.getValue().getAttribute().get(HeroAttributeEnum.CurHP.getPropertyId())>0){
aliveHero++;
}
}
//防守血量处理
CommonProto.FightTeamInfo fightDefendTeamInfo = BloodLogic.getInstance().fightDataMakeUp(defendInfo.getHeroSkills(),heroAttribute,defendInfo.getPokenmonSkills());
//攻击者血量处理
@ -444,16 +444,16 @@ public class GuildFightLogic {
for (int i = 0; i < fightResult.length; i++) {
System.out.println(fightResult[i]);
}
int dieCount = 0;
int aliveCount = 0;
// 战斗之后数据处理
for(int i = 2 ; i <fightResult.length;i++){
if(fightResult[0]==0) {
if(fightResult[i]==0){
dieCount++;
if(fightResult[i]>=0){
aliveCount++;
}
}else{
dieCount = 5;
aliveCount=0;
}
}
@ -477,10 +477,10 @@ public class GuildFightLogic {
int memberType =player.getGuildPosition();
int maxStar = sGuildSetting.getStarNum()[memberType-1];
int lessStar = maxStar - dieCount*maxStar/5;
getStar =(aliveHero-aliveCount)*maxStar/5;
//倍数k(maxStar/5)
getStar = defendInfo.getStarCount()-lessStar;
defendInfo.setStarCount(lessStar);
// getStar = defendInfo.getStarCount()-lessStar;
defendInfo.setStarCount(maxStar-getStar);
for(TeamPosHeroInfo attack:teamAttack){
redisUtil.putMapEntry(RedisKey.FAMILY_ATTACK_BLOOD,String.valueOf(userAttack.getId()),attack.getHeroId(),100);
}
@ -762,21 +762,28 @@ public class GuildFightLogic {
}else{
guildInfo.updateExp(guildInfo.getExp()+getExp);
}
// //个人奖励
// Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FAMILY_FIGHT_STAR_RANK, String.valueOf(guildId), 0, 20);
// if(zsetreverseRangeWithScores.size()<1){
// continue;
// }
// Iterator<ZSetOperations.TypedTuple<String>> it = zsetreverseRangeWithScores.iterator();
// int userRank = 1;
// int userResultRank = 1;
//个人奖励
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FAMILY_FIGHT_STAR_RANK, String.valueOf(guildInfo.getId()), 0, 20);
if(zsetreverseRangeWithScores.size()<1){
continue;
}
Iterator<ZSetOperations.TypedTuple<String>> it = zsetreverseRangeWithScores.iterator();
int userRank = 0;
int userResultRank = 0;
int lastStar = 0;
// Family.PersonalFightResultResponse.Builder response = Family.PersonalFightResultResponse.newBuilder();
//// response.addResult(Family.PersonalFightResult.newBuilder().setRank(userRank).set.build())
// while (it.hasNext()){
// ZSetOperations.TypedTuple<String> next = it.next();
//// MailLogic.getInstance().sendMail(Integer.parseInt(next.getValue()),"公会战奖励","恭喜你在此次工会战中获得第"+userResultRank,,Global.MAIL_EFFECTIVE_TIME);
// userRank++;
// }
// response.addResult(Family.PersonalFightResult.newBuilder().setRank(userRank).set.build())
while (it.hasNext()){
ZSetOperations.TypedTuple<String> next = it.next();
userRank++;
if(next.getScore()!=lastStar){
lastStar = next.getScore().intValue();
userResultRank = userRank;
}
String title = SErrorCodeEerverConfig.getI18NMessage("family_fight_rank_reward_title");
String content = SErrorCodeEerverConfig.getI18NMessage("family_fight_rank_reward_txt",new Object[]{String.valueOf(userResultRank)});
MailLogic.getInstance().sendMail(Integer.parseInt(next.getValue()),title,content,SGuildRewardConfig.rewardMap.get(userResultRank),(int) (TimeUtils.now()/1000), Global.MAIL_EFFECTIVE_TIME);
}
}
MongoUtil.getLjsdMongoTemplate().lastUpdate();
}

View File

@ -207,6 +207,18 @@ public class GuildLogic {
continue;
}
GuilidManager.addApplyGuildInfo(guildApply);
Map<Integer, Set<Integer>> members = GuilidManager.guildInfoMap.get(applyGuildId).getMembers();
for(Map.Entry<Integer, Set<Integer>> entry: members.entrySet()){
if(entry.getValue().size()<1){
continue;
}
if (entry.getKey()==3){
continue;
}
for(Integer sendUid : entry.getValue()){
MessageUtil.sendRedIndication(sendUid,GlobalsDef.GUILD_APPLY_TYPE);
}
}
}
MessageUtil.sendMessage(session,1,msgId,null,true);
}
@ -231,7 +243,7 @@ public class GuildLogic {
return;
}
if(user.getPlayerInfoManager().getLevel()<guildInfo.getIntoLevel()){
MessageUtil.sendErrorResponse(session,0,msgId,"等级不足");
MessageUtil.sendErrorResponse(session,Global.SHOW_TIPS_ERROR,msgId,"条件不符,无法加入");
return;
}
//todo 判读人数是否已达上限
@ -352,6 +364,7 @@ public class GuildLogic {
User userTmp = UserManager.getUser(guildApply.getId());
builder.addFamilyApply(CBean2Proto.getFamilyApplyInfo(userTmp,guildApply.getCreateTime())).build();
}
user.getPlayerInfoManager().removeRed(GlobalsDef.GUILD_APPLY_TYPE);
MessageUtil.sendMessage(session,1,msgId,builder.build(),true);
}
@ -415,7 +428,9 @@ public class GuildLogic {
}
break;
case 2: //全部拒绝
Family.RefuseJoinFamily refuse = Family.RefuseJoinFamily.newBuilder().setName(guildInfo.getName()).build();
for(Map.Entry<Integer, GuildApply> entry:applyGuild.entrySet()){
MessageUtil.sendIndicationMessage(OnlineUserManager.getSessionByUid(applyId),1, MessageTypeProto.MessageType.FAMILY_REFUSE_JOIN_INDICATION_VALUE,refuse,true);
GuilidManager.removeOneApplyGuildInfos(entry.getValue().getGuildId(),entry.getValue().getId());
}
break;
@ -432,6 +447,8 @@ public class GuildLogic {
break;
case 4: //拒绝一个
GuilidManager.removeOneApplyGuildInfos(guildId,applyId);
Family.RefuseJoinFamily refuseName = Family.RefuseJoinFamily.newBuilder().setName(guildInfo.getName()).build();
MessageUtil.sendIndicationMessage(OnlineUserManager.getSessionByUid(applyId),1, MessageTypeProto.MessageType.FAMILY_REFUSE_JOIN_INDICATION_VALUE,refuseName,true);
break;
}
}catch (Exception e){
@ -499,15 +516,17 @@ public class GuildLogic {
MessageUtil.sendErrorResponse(session,0,msgId,"无权操作");
return;
}
if(GuildFightLogic.getStatus()!=0){
MessageUtil.sendErrorResponse(session,0, msgId,"公会战期间不允许踢出成员");
return;
}
Family.KickOutIndication kickIndication = Family.KickOutIndication.newBuilder().setUid(targetUid).build();
sendIndicationToMember(guildInfo,MessageTypeProto.MessageType.FAMILY_KICK_INDICATION,kickIndication);
boolean remove = guildInfo.removeMember(targetType, targetUid);
if(!remove){
MessageUtil.sendErrorResponse(session,0,msgId,"该人已被踢出");
return;
}
if(GuildFightLogic.getStatus()!=0){
MessageUtil.sendErrorResponse(session,0, msgId,"公会战期间不允许踢出成员");
return;
}
//如果有防守信息则删除
if(guildInfo.getDefendInfo().containsKey((targetUid))){
guildInfo.removeDefendInfo(targetUid);
@ -516,11 +535,14 @@ public class GuildLogic {
targetUser.getPlayerInfoManager().setGuildId(0);
targetUser.getGuildMyInfo().clearOfLevelGuild();
addGuildLog(guildInfo.getId(),GuildDef.Log.KICK,targetUser.getPlayerInfoManager().getNickName());
Family.FamilyKickIndication build = Family.FamilyKickIndication.newBuilder().setType(1).build();
ISession targetSession = OnlineUserManager.getSessionByUid(targetUid);
if(targetSession!=null){
MessageUtil.sendIndicationMessage(targetSession,1, MessageTypeProto.MessageType.FAMILY_KICK_INDICATION_VALUE,build,true);
}
// Family.FamilyKickIndication build = Family.FamilyKickIndication.newBuilder().setType(1).build();
// ISession targetSession = OnlineUserManager.getSessionByUid(targetUid);
// if(targetSession!=null){
//// MessageUtil.sendIndicationMessage(targetSession,1, MessageTypeProto.MessageType.FAMILY_KICK_INDICATION_VALUE,build,true);
// }
String title = SErrorCodeEerverConfig.getI18NMessage("family_kick_title");
String content = SErrorCodeEerverConfig.getI18NMessage("family_kick_txt",new Object[]{guildInfo.getName()});
MailLogic.getInstance().sendMail(targetUid,title,content,"",(int) (TimeUtils.now()/1000), Global.MAIL_EFFECTIVE_TIME);
MessageUtil.sendMessage(session,1,msgId,null,true);
}
@ -556,7 +578,6 @@ public class GuildLogic {
return;
}
}
guildInfo.removeMember(targetType,targetUid);
guildInfo.addMembers(position,targetUid);
PlayerInfoCache cache = RedisUtil.getInstence().getMapEntry(RedisKey.PLAYER_INFO_CACHE, "", String.valueOf(uid), PlayerInfoCache.class);
@ -691,7 +712,7 @@ public class GuildLogic {
public static void releaseGuild(GuildInfo guildInfo) throws Exception {
Map<Integer, Set<Integer>> members = guildInfo.getMembers();
Family.FamilyKickIndication build = Family.FamilyKickIndication.newBuilder().setType(2).build();
Family.KickOutIndication build = Family.KickOutIndication.newBuilder().build();
String title = SErrorCodeEerverConfig.getI18NMessage("guild_breakup_title");
Set<Integer> chairmans = guildInfo.getMembers().get(GlobalsDef.CHAIRMAN);
Integer chairmanUid = chairmans.iterator().next();
@ -766,7 +787,30 @@ public class GuildLogic {
MessageUtil.sendMessage(session,1,msgId,null,true);
}
public static void sendPositionChange(int uid,int position){
public static void sendPositionChange(int uid,int position) throws Exception {
String title = "";
String content = "";
//给玩家发邮件
switch (position){
case 1:
title = SErrorCodeEerverConfig.getI18NMessage("family_leader_title");
content = SErrorCodeEerverConfig.getI18NMessage("family_leader_txt");
break;
case 2:
title = SErrorCodeEerverConfig.getI18NMessage("family_position_title");
content = SErrorCodeEerverConfig.getI18NMessage("family_position_txt");
break;
case 3:
title = SErrorCodeEerverConfig.getI18NMessage("family_relieve_title");
content = SErrorCodeEerverConfig.getI18NMessage("family_relieve_txt");
break;
default:
break;
}
if(StringUtil.isEmpty(title)||StringUtil.isEmpty(content)){
return;
}
MailLogic.getInstance().sendMail(uid,title,content,"",(int) (TimeUtils.now()/1000), Global.MAIL_EFFECTIVE_TIME);
ISession session = OnlineUserManager.getSessionByUid(uid);
if(session!=null){
Family.FamilyPositionUpdateIndication build = Family.FamilyPositionUpdateIndication.newBuilder().setPostiion(position).build();