门票校验
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) {
|
if (user.getPlayerInfoManager().getMapId() < mapId) {
|
||||||
user.getPlayerInfoManager().setMapId(mapId);
|
user.getPlayerInfoManager().setMapId(mapId);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +137,26 @@ public class MapLogic {
|
||||||
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
|
||||||
return;
|
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.setDayFightCount(mapManager.getDayFightCount() + 1);
|
||||||
mapManager.setCurMapId(mapId);
|
mapManager.setCurMapId(mapId);
|
||||||
initMap(mapManager, user);
|
initMap(mapManager, user);
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class MapManager extends MongoBase {
|
||||||
public static void getHeroTicket(User user) throws Exception {
|
public static void getHeroTicket(User user) throws Exception {
|
||||||
Item item = user.getItemManager().getItemMap().get(Global.HEROSTORY_TICKET);
|
Item item = user.getItemManager().getItemMap().get(Global.HEROSTORY_TICKET);
|
||||||
if(item == null){
|
if(item == null){
|
||||||
return;
|
item = user.getItemManager().newItem(Global.HEROSTORY_TICKET, 0);
|
||||||
}
|
}
|
||||||
int itemNum = item.getItemNum();
|
int itemNum = item.getItemNum();
|
||||||
int updateTime = (int) (System.currentTimeMillis() / 1000);
|
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.common.mogodb.MongoBase;
|
||||||
import com.ljsd.jieling.db.mongo.MongoKey;
|
import com.ljsd.jieling.db.mongo.MongoKey;
|
||||||
|
import com.ljsd.jieling.globals.Global;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ItemManager extends MongoBase {
|
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<>();
|
private Map<Integer, Item> itemMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@ -34,6 +43,9 @@ public class ItemManager extends MongoBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeItem(Integer key) {
|
public void removeItem(Integer key) {
|
||||||
|
if(notDelete.contains(key)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
Item item = itemMap.get(key);
|
Item item = itemMap.get(key);
|
||||||
if (item!=null){
|
if (item!=null){
|
||||||
itemMap.remove(key);
|
itemMap.remove(key);
|
||||||
|
|
|
@ -323,6 +323,7 @@ public class ItemUtil {
|
||||||
case GlobalItemType.RUNNE:
|
case GlobalItemType.RUNNE:
|
||||||
case GlobalItemType.CARD_FRAGMENT:
|
case GlobalItemType.CARD_FRAGMENT:
|
||||||
case GlobalItemType.BLUE_IMAGE:
|
case GlobalItemType.BLUE_IMAGE:
|
||||||
|
case GlobalItemType.MINERAL:
|
||||||
itemType = GlobalItemType.ITEM;
|
itemType = GlobalItemType.ITEM;
|
||||||
break;
|
break;
|
||||||
case GlobalItemType.RANDOM_ITME:
|
case GlobalItemType.RANDOM_ITME:
|
||||||
|
@ -518,6 +519,9 @@ public class ItemUtil {
|
||||||
if ((userItem.getKey() == Global.STAMINA)){
|
if ((userItem.getKey() == Global.STAMINA)){
|
||||||
MapManager.getEnergy(user);
|
MapManager.getEnergy(user);
|
||||||
}
|
}
|
||||||
|
if ((userItem.getKey() == Global.HEROSTORY_TICKET)){
|
||||||
|
MapManager.getHeroTicket(user);
|
||||||
|
}
|
||||||
Item temporaryItem = temporaryItemList.get(userItem.getKey());
|
Item temporaryItem = temporaryItemList.get(userItem.getKey());
|
||||||
int needCount = userItem.getValue();
|
int needCount = userItem.getValue();
|
||||||
if (temporaryItem != null) {
|
if (temporaryItem != null) {
|
||||||
|
@ -553,6 +557,9 @@ public class ItemUtil {
|
||||||
if (entry.getKey() ==Global.STAMINA){
|
if (entry.getKey() ==Global.STAMINA){
|
||||||
MapManager.getEnergy(user);
|
MapManager.getEnergy(user);
|
||||||
}
|
}
|
||||||
|
if (entry.getKey() ==Global.HEROSTORY_TICKET){
|
||||||
|
MapManager.getHeroTicket(user);
|
||||||
|
}
|
||||||
itemList.add(CBean2Proto.getItem(entry.getValue(),-1));
|
itemList.add(CBean2Proto.getItem(entry.getValue(),-1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -720,6 +727,9 @@ public class ItemUtil {
|
||||||
if ((entry.getKey() == Global.STAMINA)){
|
if ((entry.getKey() == Global.STAMINA)){
|
||||||
MapManager.getEnergy(user);
|
MapManager.getEnergy(user);
|
||||||
}
|
}
|
||||||
|
if (entry.getKey() ==Global.HEROSTORY_TICKET){
|
||||||
|
MapManager.getHeroTicket(user);
|
||||||
|
}
|
||||||
Item item = user.getItemManager().getItem(entry.getKey());
|
Item item = user.getItemManager().getItem(entry.getKey());
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue