Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
567cecad79
|
|
@ -226,9 +226,8 @@ public class ArenaLogic {
|
|||
.setFightResult(fightResult)
|
||||
.build();
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.ARENA_CHALLENGE,fightResult, myscore + myscoreChange);
|
||||
if(defUser!=null) {
|
||||
// user.getUserMissionManager().onGameEvent(defUser, GameEvent.ARENA_CHALLENGE,fightResult,defScore + defScoreChange);
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(defUser, true, new AynMissionWorker(GameEvent.ARENA_CHALLENGE, fightResult^1, defScore + defScoreChange));
|
||||
if(defUser!=null && defUser.getArenaManager().getCount()>0) {
|
||||
AyyncWorker ayyncWorker = new AyyncWorker(defUser, true, new AynMissionWorker(GameEvent.ARENA_CHALLENGE, -999, defScore + defScoreChange));
|
||||
ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker);
|
||||
}
|
||||
Poster.getPoster().dispatchEvent(new ArenaChallengeEvent(user.getId()));
|
||||
|
|
|
|||
|
|
@ -114,8 +114,12 @@ public class GuildFightLogic {
|
|||
);
|
||||
Map<Integer, Integer> attribute = entry.getValue().getAttribute();
|
||||
if(status==3){
|
||||
int remainHp = attribute.get(HeroAttributeEnum.CurHP.getPropertyId())*100/attribute.get(HeroAttributeEnum.Hp.getPropertyId());
|
||||
LOGGER.info("血量为百分之{}",remainHp);
|
||||
int remainHp = attribute.get(HeroAttributeEnum.CurHP.getPropertyId())*10000/attribute.get(HeroAttributeEnum.Hp.getPropertyId());
|
||||
//如果血特别少,返回0.01%
|
||||
if(attribute.get(HeroAttributeEnum.CurHP.getPropertyId())>0&&remainHp==0){
|
||||
remainHp = 1;
|
||||
}
|
||||
LOGGER.info("血量为万分之{}",remainHp);
|
||||
oneInfo.addRemainHp(remainHp);
|
||||
}
|
||||
}
|
||||
|
|
@ -511,11 +515,12 @@ public class GuildFightLogic {
|
|||
getStar =(aliveHero-aliveCount)*maxStar/5;
|
||||
//倍数k(maxStar/5)
|
||||
// getStar = defendInfo.getStarCount()-lessStar;
|
||||
defendInfo.setStarCount(maxStar-getStar);
|
||||
defendInfo.setStarCount(defendInfo.getStarCount()-getStar);
|
||||
for(TeamPosHeroInfo attack:teamAttack){
|
||||
redisUtil.putMapEntry(RedisKey.FAMILY_ATTACK_BLOOD,String.valueOf(userAttack.getId()),attack.getHeroId(),100);
|
||||
}
|
||||
}
|
||||
LOGGER.info("获得星数{}",getStar);
|
||||
redisUtil.putMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(gid), String.valueOf(defendUid), defendInfo);
|
||||
//发送indication
|
||||
Family.DefeatResponse fightResponse = Family.DefeatResponse.newBuilder().setUid(defendUid).setTeamLostStar(getStar).build();
|
||||
|
|
|
|||
|
|
@ -445,6 +445,10 @@ public class MissionLoigc {
|
|||
if(SMainLevelConfig.config.containsKey(missionSubType[0])){
|
||||
int virtureId = SMainLevelConfig.config.get(missionSubType[0]).getVirtureId();
|
||||
SMainLevelConfig mineMainLevelConfig = SMainLevelConfig.config.get(user.getMainLevelManager().getFightId());
|
||||
if(user.getMainLevelManager().getState() == -1 ){
|
||||
int fightId = user.getMainLevelManager().getFightId();
|
||||
mineMainLevelConfig = SMainLevelConfig.fightPreMap.get(fightId);
|
||||
}
|
||||
if(mineMainLevelConfig!=null){
|
||||
count =virtureId <= mineMainLevelConfig.getVirtureId() ?1:0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,16 @@ public class ArenaChallengeManager implements BaseDataManager{
|
|||
@Override
|
||||
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
|
||||
CumulationData.Result result = null;
|
||||
int fightResult = (int) parm[0];
|
||||
if(missionType == MissionType.ARENA_FIGHTSUCCES_TIMES){
|
||||
if(fightResult==1){
|
||||
data.arenaFightsuccesTimes++;
|
||||
result = new CumulationData.Result(missionType);
|
||||
}
|
||||
}
|
||||
if(fightResult==-999){
|
||||
return result;
|
||||
}
|
||||
if(missionType == MissionType.ARENA_CHALLENEGE_NUMS){
|
||||
data.setArenaFightNums(data.getArenaFightNums()+1);
|
||||
result = new CumulationData.Result(missionType);
|
||||
|
|
@ -16,11 +26,6 @@ public class ArenaChallengeManager implements BaseDataManager{
|
|||
data.setArenaScore(myscore);
|
||||
result = new CumulationData.Result(missionType);
|
||||
}
|
||||
}else if(missionType == MissionType.ARENA_FIGHTSUCCES_TIMES){
|
||||
if((int)parm[0] == 1){
|
||||
data.arenaFightsuccesTimes++;
|
||||
result = new CumulationData.Result(missionType);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ThreadManager {
|
||||
|
|
@ -26,21 +26,25 @@ public class ThreadManager {
|
|||
private static ItemLogTask itemLogTask;
|
||||
public static int SLEEP_INTEVAL_TIME = 60; //每1分钟检查一次
|
||||
|
||||
private static Set<Future<?>> scheduledFutureSets = new HashSet<>();
|
||||
|
||||
private static volatile ScheduledThreadPoolExecutor scheduledExecutor; //管理task
|
||||
|
||||
public void init() {
|
||||
scheduledExecutor = new ScheduledThreadPoolExecutor(16, new ScheduleThreadFactory());
|
||||
}
|
||||
|
||||
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||
|
||||
platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
||||
mongoDataHandlerTask = configurableApplicationContext.getBean(MongoDataHandlerTask.class);
|
||||
dataReportTask = configurableApplicationContext.getBean(DataReportTask.class);
|
||||
itemLogTask = configurableApplicationContext.getBean(ItemLogTask.class);
|
||||
// DataReportTask dataReportTask = new DataReportTask();
|
||||
// dataReportTask.start();
|
||||
new RetrySendIndicationThread("retry-indi").start();
|
||||
mongoDataHandlerTask.start();
|
||||
dataReportTask.start();
|
||||
itemLogTask.start();
|
||||
|
||||
scheduledExecutor = new ScheduledThreadPoolExecutor(8, new ScheduleThreadFactory());
|
||||
scheduledExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
|
||||
scheduledExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
|
||||
go();
|
||||
|
||||
}
|
||||
|
||||
private ThreadManager(){}
|
||||
|
|
@ -52,18 +56,20 @@ public class ThreadManager {
|
|||
return instance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static class ScheduleThreadFactory implements ThreadFactory {
|
||||
|
||||
final ThreadGroup group;
|
||||
|
||||
final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
static AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
|
||||
final String namePrefix;
|
||||
|
||||
ScheduleThreadFactory() {
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
||||
namePrefix = "ScheduleThreadPool" + "-thread-";
|
||||
namePrefix = "ScheduleThreadPool-test" + "-thread-";
|
||||
}
|
||||
|
||||
public Thread newThread(Runnable r) {
|
||||
|
|
@ -79,29 +85,23 @@ public class ThreadManager {
|
|||
|
||||
public static void go() {
|
||||
int now = (int)(System.currentTimeMillis()/1000);
|
||||
scheduledExecutor = new ScheduledThreadPoolExecutor(16, new ScheduleThreadFactory());
|
||||
|
||||
// testTask 已秒为单位 延迟10s, 间隔30s为周期执行
|
||||
int delayForMinute = 60 - (now%60);
|
||||
LOGGER.info("delayForMinute---->>>>{}" ,delayForMinute);
|
||||
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), delayForMinute, 60, TimeUnit.SECONDS);
|
||||
scheduledExecutor.scheduleAtFixedRate(new SecondsTask(), 0, 1, TimeUnit.SECONDS);
|
||||
scheduledExecutor.scheduleAtFixedRate(new FetchBloodyEndDataThread(), 0, 1, TimeUnit.SECONDS);
|
||||
scheduledExecutor.scheduleAtFixedRate(new Thread(){
|
||||
scheduledFutureSets.add(scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS));
|
||||
scheduledFutureSets.add( scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), delayForMinute, 60, TimeUnit.SECONDS));
|
||||
scheduledFutureSets.add( scheduledExecutor.scheduleAtFixedRate(new SecondsTask(), 0, 1, TimeUnit.SECONDS));
|
||||
scheduledFutureSets.add( scheduledExecutor.scheduleAtFixedRate(new FetchBloodyEndDataThread(), 0, 1, TimeUnit.SECONDS));
|
||||
scheduledFutureSets.add( scheduledExecutor.scheduleAtFixedRate(new Thread(){
|
||||
public void run () {
|
||||
long lastMilis = System.currentTimeMillis();
|
||||
try { Thread.sleep(1000L); } catch (InterruptedException e) { }
|
||||
long millis = System.currentTimeMillis();
|
||||
if((millis - lastMilis)-10000>5000||(millis - lastMilis)-10000<-5000){
|
||||
if((millis - lastMilis)-1000>5000||(millis - lastMilis)-1000<-5000){
|
||||
reStart();
|
||||
}
|
||||
}
|
||||
}, delayForMinute, 1, TimeUnit.SECONDS);
|
||||
scheduledExecutor.execute(new RetrySendIndicationThread("retry_send"));
|
||||
scheduledExecutor.execute(dataReportTask);
|
||||
scheduledExecutor.execute(mongoDataHandlerTask);
|
||||
scheduledExecutor.execute(itemLogTask);
|
||||
}, delayForMinute, 1, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
public static ScheduledThreadPoolExecutor getScheduledExecutor() {
|
||||
|
|
@ -110,7 +110,11 @@ public class ThreadManager {
|
|||
|
||||
public static void reStart(){
|
||||
LOGGER.info("重启线程池!!");
|
||||
scheduledExecutor.shutdown();
|
||||
// scheduledExecutor.shutdown();
|
||||
for(Future future : scheduledFutureSets){
|
||||
future.cancel(false);
|
||||
}
|
||||
scheduledFutureSets.clear();
|
||||
go();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
@Component
|
||||
public class ItemLogTask extends Thread {
|
||||
public ItemLogTask(){
|
||||
super("itemLog");
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
while(true){
|
||||
|
|
|
|||
|
|
@ -43,18 +43,22 @@ public class SMainLevelConfig implements BaseConfig {
|
|||
|
||||
public static Map<Integer, SMainLevelConfig> config;
|
||||
public static Map<Integer, SMainLevelConfig> sMainLevelConfigByVirtureIdMap;
|
||||
public static Map<Integer,SMainLevelConfig> fightPreMap;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, SMainLevelConfig> configTmp = STableManager.getConfig(SMainLevelConfig.class);
|
||||
Map<Integer, SMainLevelConfig> SMainLevelConfigByVirtureIdMapTmp =new HashMap<>();
|
||||
Map<Integer, SMainLevelConfig> fightPreMapTmp =new HashMap<>();
|
||||
for(SMainLevelConfig sMainLevelConfig : configTmp.values()){
|
||||
int id = sMainLevelConfig.getId();
|
||||
sMainLevelConfig.setVirtureId(10_000_000*(id%10) + id);
|
||||
SMainLevelConfigByVirtureIdMapTmp.put(sMainLevelConfig.getVirtureId(),sMainLevelConfig);
|
||||
fightPreMapTmp.put(sMainLevelConfig.getNextLevel(),sMainLevelConfig);
|
||||
}
|
||||
config=configTmp;
|
||||
sMainLevelConfigByVirtureIdMap=SMainLevelConfigByVirtureIdMapTmp;
|
||||
fightPreMap=fightPreMapTmp;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue