item flush
parent
f7f0b30645
commit
12448b77c2
|
@ -4,6 +4,7 @@ public interface Global {
|
|||
int STAMINA = 2; // 体力id
|
||||
int HEROSTORY_TICKET = 28; //精英入场券
|
||||
int GENERALSTORY_TICKET = 27; //普通入场券
|
||||
int INVASIONBOSS_TICKET = 44; //外敌挑战券
|
||||
int GOLD = 14; //金币
|
||||
int GEM = 16; // 妖精id
|
||||
int SEND_CARD_COUNT = 20; // 每页发送卡牌个数
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.ljsd.jieling.handler.map;
|
|||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.config.SGameSetting;
|
||||
import com.ljsd.jieling.config.SVipLevelConfig;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.handler.mission.Mission;
|
||||
|
@ -227,16 +229,24 @@ public class MapManager extends MongoBase {
|
|||
}
|
||||
|
||||
|
||||
public static void getHeroTicket(User user) throws Exception {
|
||||
Item item = user.getItemManager().getItemMap().get(Global.HEROSTORY_TICKET);
|
||||
public static void getTimesRecoveryTicket(User user, int itemId) throws Exception {
|
||||
Item item = user.getItemManager().getItemMap().get(itemId);
|
||||
if(item == null){
|
||||
item = user.getItemManager().newItem(Global.HEROSTORY_TICKET, 0);
|
||||
item = user.getItemManager().newItem(itemId, 0);
|
||||
}
|
||||
int itemNum = item.getItemNum();
|
||||
int updateTime = (int) (System.currentTimeMillis() / 1000);
|
||||
int lastUpdateEnergyTime = item.getEndingTime();
|
||||
int recoveryTime = SGameSetting.getGameSetting().getRecoveryTime();
|
||||
int heroTimes = SGameSetting.getGameSetting().getHeroTimes();
|
||||
|
||||
if(itemId == Global.INVASIONBOSS_TICKET){
|
||||
recoveryTime = SGameSetting.getGameSetting().getInvasionBossTimesAdd();
|
||||
SVipLevelConfig sVipLevelConfig = SVipLevelConfig.getsVipLevelConfigMap().get(user.getPlayerInfoManager().getVipLevel());
|
||||
Map<Integer, Integer> privilegeMap = sVipLevelConfig.getPrivilegeMap();
|
||||
heroTimes = privilegeMap.get(VipPrivilegeType.CHALLENGE_INVASIONBOSS_LIMIT);
|
||||
}
|
||||
|
||||
int recoveryTimes = (updateTime - lastUpdateEnergyTime)/recoveryTime;
|
||||
if(itemNum>heroTimes){
|
||||
item.setEndingTime(updateTime);
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import com.sun.org.apache.regexp.internal.RE;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -20,7 +19,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ItemLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ItemLogic.class);
|
||||
|
@ -295,12 +293,13 @@ public class ItemLogic {
|
|||
if (sItem == null){
|
||||
continue;
|
||||
}
|
||||
LOGGER.info("the item ={} will flush",itemId);
|
||||
if (itemId == Global.STAMINA){
|
||||
MapManager.getEnergy(user);
|
||||
itemList.add(itemMap.get(itemId));
|
||||
}
|
||||
if (itemId == Global.HEROSTORY_TICKET){
|
||||
MapManager.getHeroTicket(user);
|
||||
if (itemId == Global.HEROSTORY_TICKET || itemId == Global.INVASIONBOSS_TICKET ){
|
||||
MapManager.getTimesRecoveryTicket(user,itemId);
|
||||
itemList.add(itemMap.get(itemId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.ljsd.jieling.logic.dao.CumulationData;
|
|||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.mission.MissionLoigc;
|
||||
import com.ljsd.jieling.logic.mission.MissionState;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -35,18 +36,25 @@ public class TreasureMissionType extends AbstractMissionType{
|
|||
reallyTakeTimes =1;
|
||||
}
|
||||
if(reallyTakeTimes>0){
|
||||
if(sTreasureTaskConfig.getTimes()>0){
|
||||
reallyTakeTimes = MathUtils.setBetweenWithMax(reallyTakeTimes,0,sTreasureTaskConfig.getTimes() - takeTimes);
|
||||
}
|
||||
int hadTakes = takeTimes + reallyTakeTimes;
|
||||
this.takeTimes.put(missionId,takeTimes+reallyTakeTimes);
|
||||
if(sTreasureTaskConfig.getTimes()>0 && this.takeTimes.get(missionId)>sTreasureTaskConfig.getTimes()){
|
||||
if(sTreasureTaskConfig.getTimes()>0 && hadTakes>=sTreasureTaskConfig.getTimes()){
|
||||
hadTakes = sTreasureTaskConfig.getTimes();
|
||||
}
|
||||
this.takeTimes.put(missionId,hadTakes);
|
||||
if(sTreasureTaskConfig.getTimes()>0 && this.takeTimes.get(missionId)>=sTreasureTaskConfig.getTimes()){
|
||||
getRewardedMissionIds().set(missionId);
|
||||
getDoingMissionIds().remove(missionId);
|
||||
getFinishMissionIds().remove(missionId);
|
||||
MissionStateChangeInfo stateChangeInfo = new MissionStateChangeInfo(missionId, MissionState.REWARD,reallyTakeTimes,hadTakes);
|
||||
missionTypeEnumListMap.add(stateChangeInfo);
|
||||
return;
|
||||
}else{
|
||||
MissionStateChangeInfo stateChangeInfo = new MissionStateChangeInfo(missionId, MissionState.DOING,reallyTakeTimes,hadTakes);
|
||||
missionTypeEnumListMap.add(stateChangeInfo);
|
||||
}
|
||||
MissionStateChangeInfo stateChangeInfo = new MissionStateChangeInfo(missionId, MissionState.DOING,reallyTakeTimes,hadTakes);
|
||||
missionTypeEnumListMap.add(stateChangeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -628,8 +628,8 @@ public class ItemUtil {
|
|||
if ((userItem.getKey() == Global.STAMINA)){
|
||||
MapManager.getEnergy(user);
|
||||
}
|
||||
if ((userItem.getKey() == Global.HEROSTORY_TICKET)){
|
||||
MapManager.getHeroTicket(user);
|
||||
if (userItem.getKey() == Global.HEROSTORY_TICKET || userItem.getKey() == Global.INVASIONBOSS_TICKET ){
|
||||
MapManager.getTimesRecoveryTicket(user,userItem.getKey());
|
||||
}
|
||||
Item temporaryItem = temporaryItemList.get(userItem.getKey());
|
||||
int needCount = userItem.getValue();
|
||||
|
@ -684,17 +684,24 @@ public class ItemUtil {
|
|||
if (entry.getKey() ==Global.STAMINA){
|
||||
MapManager.getEnergy(user);
|
||||
}
|
||||
if (entry.getKey() ==Global.HEROSTORY_TICKET){
|
||||
MapManager.getHeroTicket(user);
|
||||
if (entry.getKey() == Global.HEROSTORY_TICKET || entry.getKey() == Global.INVASIONBOSS_TICKET ){
|
||||
MapManager.getTimesRecoveryTicket(user,entry.getKey());
|
||||
needUpdateHero = false;
|
||||
}
|
||||
itemList.add(CBean2Proto.getItem(entry.getValue(),-1));
|
||||
}
|
||||
}
|
||||
if (needUpdateHero){
|
||||
MapManager.getHeroTicket(user);
|
||||
Item item = itemMap.get(Global.HEROSTORY_TICKET);
|
||||
itemList.add(CBean2Proto.getItem(item,-1));
|
||||
if(item == null){
|
||||
MapManager.getTimesRecoveryTicket(user,Global.HEROSTORY_TICKET);
|
||||
itemList.add(CBean2Proto.getItem(item,-1));
|
||||
}
|
||||
item = itemMap.get(Global.INVASIONBOSS_TICKET);
|
||||
if(item == null){
|
||||
MapManager.getTimesRecoveryTicket(user,Global.INVASIONBOSS_TICKET);
|
||||
itemList.add(CBean2Proto.getItem(item,-1));
|
||||
}
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
|
@ -883,8 +890,8 @@ public class ItemUtil {
|
|||
if ((entry.getKey() == Global.STAMINA)){
|
||||
MapManager.getEnergy(user);
|
||||
}
|
||||
if (entry.getKey() ==Global.HEROSTORY_TICKET){
|
||||
MapManager.getHeroTicket(user);
|
||||
if (entry.getKey() == Global.HEROSTORY_TICKET || entry.getKey() == Global.INVASIONBOSS_TICKET ){
|
||||
MapManager.getTimesRecoveryTicket(user,entry.getKey());
|
||||
}
|
||||
Item item = user.getItemManager().getItem(entry.getKey());
|
||||
if (item == null) {
|
||||
|
|
Loading…
Reference in New Issue