门票校验
parent
5afccd1843
commit
e0237b7a93
|
@ -128,12 +128,6 @@ public class MapLogic {
|
|||
}
|
||||
}
|
||||
}
|
||||
/* SChallengeSetting sChallengeSetting = SChallengeSetting.challengeSetting;
|
||||
if (mapManager.getDayFightCount() >= sChallengeSetting.getLimit() + mapManager.getBuyFightCount()) {
|
||||
LOGGER.info("enterMap() uid=>{} max fight count =>{} ", uid, mapManager.getDayFightCount());
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "请购买挑战次数");
|
||||
return;
|
||||
}*/
|
||||
if (user.getPlayerInfoManager().getMapId() < mapId) {
|
||||
user.getPlayerInfoManager().setMapId(mapId);
|
||||
}
|
||||
|
@ -143,6 +137,26 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int type = sChallengeConfig.getType();
|
||||
Map<Integer, CrossInfo> crossInfoMap = mapManager.getCrossInfoMap();
|
||||
if(type == 1){
|
||||
if(crossInfoMap.containsKey(mapId)){
|
||||
if(crossInfoMap.get(mapId).getStars().contains(STAR_1)){
|
||||
boolean enough = ItemUtil.itemCost(user, new int[][]{{Global.GENERALSTORY_TICKET, 1}});
|
||||
if(!enough){
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "no ticket");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(type == 2){
|
||||
boolean enough = ItemUtil.itemCost(user, new int[][]{{Global.HEROSTORY_TICKET, 1}});
|
||||
if(!enough){
|
||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "no ticket");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mapManager.setDayFightCount(mapManager.getDayFightCount() + 1);
|
||||
mapManager.setCurMapId(mapId);
|
||||
initMap(mapManager, user);
|
||||
|
|
|
@ -179,7 +179,7 @@ public class MapManager extends MongoBase {
|
|||
public static void getHeroTicket(User user) throws Exception {
|
||||
Item item = user.getItemManager().getItemMap().get(Global.HEROSTORY_TICKET);
|
||||
if(item == null){
|
||||
return;
|
||||
item = user.getItemManager().newItem(Global.HEROSTORY_TICKET, 0);
|
||||
}
|
||||
int itemNum = item.getItemNum();
|
||||
int updateTime = (int) (System.currentTimeMillis() / 1000);
|
||||
|
|
|
@ -2,12 +2,21 @@ package com.ljsd.jieling.logic.dao;
|
|||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.db.mongo.MongoKey;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ItemManager extends MongoBase {
|
||||
private static Set<Integer> notDelete = new HashSet<>();
|
||||
static {
|
||||
notDelete.add(Global.STAMINA);
|
||||
notDelete.add(Global.HEROSTORY_TICKET);
|
||||
notDelete.add(Global.GENERALSTORY_TICKET);
|
||||
}
|
||||
|
||||
private Map<Integer, Item> itemMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
@ -34,6 +43,9 @@ public class ItemManager extends MongoBase {
|
|||
}
|
||||
|
||||
public void removeItem(Integer key) {
|
||||
if(notDelete.contains(key)){
|
||||
return;
|
||||
}
|
||||
Item item = itemMap.get(key);
|
||||
if (item!=null){
|
||||
itemMap.remove(key);
|
||||
|
|
|
@ -323,6 +323,7 @@ public class ItemUtil {
|
|||
case GlobalItemType.RUNNE:
|
||||
case GlobalItemType.CARD_FRAGMENT:
|
||||
case GlobalItemType.BLUE_IMAGE:
|
||||
case GlobalItemType.MINERAL:
|
||||
itemType = GlobalItemType.ITEM;
|
||||
break;
|
||||
case GlobalItemType.RANDOM_ITME:
|
||||
|
@ -518,6 +519,9 @@ public class ItemUtil {
|
|||
if ((userItem.getKey() == Global.STAMINA)){
|
||||
MapManager.getEnergy(user);
|
||||
}
|
||||
if ((userItem.getKey() == Global.HEROSTORY_TICKET)){
|
||||
MapManager.getHeroTicket(user);
|
||||
}
|
||||
Item temporaryItem = temporaryItemList.get(userItem.getKey());
|
||||
int needCount = userItem.getValue();
|
||||
if (temporaryItem != null) {
|
||||
|
@ -553,6 +557,9 @@ public class ItemUtil {
|
|||
if (entry.getKey() ==Global.STAMINA){
|
||||
MapManager.getEnergy(user);
|
||||
}
|
||||
if (entry.getKey() ==Global.HEROSTORY_TICKET){
|
||||
MapManager.getHeroTicket(user);
|
||||
}
|
||||
itemList.add(CBean2Proto.getItem(entry.getValue(),-1));
|
||||
}
|
||||
}
|
||||
|
@ -720,6 +727,9 @@ public class ItemUtil {
|
|||
if ((entry.getKey() == Global.STAMINA)){
|
||||
MapManager.getEnergy(user);
|
||||
}
|
||||
if (entry.getKey() ==Global.HEROSTORY_TICKET){
|
||||
MapManager.getHeroTicket(user);
|
||||
}
|
||||
Item item = user.getItemManager().getItem(entry.getKey());
|
||||
if (item == null) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue