back_recharge
jiahuiwen 2019-03-01 13:40:27 +08:00
commit b06e783754
17 changed files with 165 additions and 98 deletions

View File

@ -88,7 +88,7 @@ public class LjsdMongoTemplate {
BasicDBObject update= new BasicDBObject().append("$inc",new BasicDBObject().append(key, 1));
DBObject query = cursor.next();
DBObject result = collection.findAndModify(query, update);
return Integer.valueOf(result.get(key).toString())+1;
return Integer.parseInt(result.get(key).toString())+1;
} else {
searchQuery.put(key, 1);
collection.insert(searchQuery);

View File

@ -23,7 +23,7 @@ public abstract class MongoRoot {
}
public int _getIntId() {
return Integer.valueOf(id);
return Integer.parseInt(id);
}
public void setId(String id) {

View File

@ -9,7 +9,7 @@ import java.util.List;
import java.util.Map;
public class MongoUpdateCache {
class UpdateRequest {
static class UpdateRequest {
MongoBase mongoBase;
String fullKey;
Object value;

View File

@ -47,7 +47,7 @@ public class SCHero implements BaseConfig{
private Map<Integer, Map<Integer,SCHero.ConsumeMaterialInfo>> consumeMaterialInfoOfPositionByStar;
public class ConsumeMaterialInfo{
public static class ConsumeMaterialInfo{
private int groupID;
private int nums;

View File

@ -17,6 +17,8 @@ public class SWorkShopRebuildConfig implements BaseConfig {
private int[][] secondaryCost;
private int exp;
private static Map<Integer,SWorkShopRebuildConfig> sWorkShopRebuildConfigMap;
@ -51,5 +53,7 @@ public class SWorkShopRebuildConfig implements BaseConfig {
return secondaryCost;
}
public int getExp() {
return exp;
}
}

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import com.ljsd.jieling.util.MathUtils;
import java.util.HashMap;
import java.util.Map;
@ -41,18 +42,17 @@ public class SWorkShopSetting implements BaseConfig {
Map<Integer,Integer> promoteMapTmp = new HashMap<>();
int maxExpTmp = 0;
int maxCookExpTmp = 0;
int exp =0;
for(SWorkShopSetting sWorkShopSetting : sWorkShopSettingMapTmp.values()){
exp+=sWorkShopSetting.getExp();
Map<Integer,Integer> promoteMapTmptm = new HashMap<>(promoteMapTmp);
int[] promote = sWorkShopSetting.getPromote();
if(promote!=null&&promote.length>0){
promoteMapTmp.put(promote[0],promote[1]);
sWorkShopSetting.setPromoteMap(promoteMapTmp);
promoteMapTmptm.put(promote[0],promote[1]);
sWorkShopSetting.setPromoteMap(promoteMapTmptm);
}
maxExpTmp+=sWorkShopSetting.getExp();
maxExpTmp+=sWorkShopSetting.getFoodExp();
sWorkShopSetting.setExp(exp);
maxExpTmp = MathUtils.getMaxNum(maxExpTmp,sWorkShopSetting.getExp());
maxCookExpTmp=MathUtils.getMaxNum(maxExpTmp,sWorkShopSetting.getFoodExp());
int[][] poolWeight = sWorkShopSetting.getPoolRate();
if(poolWeight!=null && poolWeight.length>0){
int totalWeight = 0;

View File

@ -716,6 +716,37 @@ public class RedisUtil {
}
return -1;
}
// ===============================set=================================
public boolean sadd(String key,String member){
try {
redisTemplate.opsForSet().add(key,member);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public boolean sremove(String key,String member){
try {
redisTemplate.opsForSet().remove(key,member);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public int getSetLength(String key){
try {
return redisTemplate.opsForSet().size(key).intValue();
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}

View File

@ -62,6 +62,8 @@ public class GMRequestHandler extends BaseHandler{
Mail mail = new Mail(uid,"GM","GM",prarm1+"#"+prarm2,nowTime,30*24*60*60,"GM", Global.MAIL_TYPE_GM);
cUser.getMailManager().addMail(mail);
break;
default:
break;
}
try {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GM_RESPONSE_VALUE, null, true);

View File

@ -89,27 +89,28 @@ public class STableManager {
LOGGER.error("file not find {}, do not find sheet with {} you need rebuild all sheet by gen sheet tool!", path, tableName);
// return null;
}
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
LOGGER.info("initMap:{}", clazz.getSimpleName());
while ((line = bufferedReader.readLine()) != null) {
if (line.isEmpty()){
continue;
try(BufferedReader bufferedReader = new BufferedReader(new FileReader(file))){
LOGGER.info("initMap:{}", clazz.getSimpleName());
while ((line = bufferedReader.readLine()) != null) {
if (line.isEmpty()){
continue;
}
T obj = clazz.newInstance();
String[] prarms = line.split("\\t");
switch (lineNum) {
case 0:
prarms = StringUtil.fieldHandle(prarms);
key.addAll(Arrays.asList(prarms));
break;
case 1:
type.addAll(Arrays.asList(prarms));
break;
default:
dealParams(clazz, map, key, type, obj, prarms);
break;
}
lineNum++;
}
T obj = clazz.newInstance();
String[] prarms = line.split("\\t");
switch (lineNum) {
case 0:
prarms = StringUtil.fieldHandle(prarms);
key.addAll(Arrays.asList(prarms));
break;
case 1:
type.addAll(Arrays.asList(prarms));
break;
default:
dealParams(clazz, map, key, type, obj, prarms);
break;
}
lineNum++;
}
} catch (Exception e) {
e.printStackTrace();
@ -139,27 +140,28 @@ public class STableManager {
List<String> key = new ArrayList<>();
List<String> type = new ArrayList<>();
int lineNum = 0;
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
LOGGER.info("initMap:{}", tableName);
while ((line = bufferedReader.readLine()) != null) {
T obj = clazz.newInstance();
String[] prarms = line.split("\\t");
switch (lineNum) {
case 0:
prarms = StringUtil.fieldHandle(prarms);
key.addAll(Arrays.asList(prarms));
break;
case 1:
type.addAll(Arrays.asList(prarms));
break;
default:
dealParams(clazz, mapConf, key, type, obj, prarms);
break;
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))){
LOGGER.info("initMap:{}", tableName);
while ((line = bufferedReader.readLine()) != null) {
T obj = clazz.newInstance();
String[] prarms = line.split("\\t");
switch (lineNum) {
case 0:
prarms = StringUtil.fieldHandle(prarms);
key.addAll(Arrays.asList(prarms));
break;
case 1:
type.addAll(Arrays.asList(prarms));
break;
default:
dealParams(clazz, mapConf, key, type, obj, prarms);
break;
}
lineNum++;
}
lineNum++;
map.put(i, mapConf);
tableName = tableName.substring(0, 3);
}
map.put(i, mapConf);
tableName = tableName.substring(0, 3);
}
return map;
}

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.logic.chat;
import com.ljsd.jieling.config.SGameSetting;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.ChatProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
@ -28,6 +29,7 @@ public class ChatLogic {
return;
}
//移除自己所在的频道。
}
public void sendChatInfo(ISession iSession, ChatProto.SendChatInfoRequest sendChatInfoRequest) {

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.util.KeyGenUtils;
import com.ljsd.jieling.util.MathUtils;
import com.ljsd.jieling.util.UUIDEnum;
@ -143,29 +144,46 @@ public class Equip extends MongoBase {
}
public void rebuildEquip(int workShopLevle){
SWorkShopSetting sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(workShopLevle);
if( null == sWorkShopSetting ){
return;
}
Map<Integer, Integer> promoteMap = sWorkShopSetting.getPromoteMap();
SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(this.equipId);
int properTyId = sEquipConfig.getPropertyMin()[0];
Integer propertyPromote = promoteMap.get(properTyId);
int properMinNum = sEquipConfig.getPropertyMin()[1];
int properMaxNum = sEquipConfig.getPropertyMax()[1];
int finalProperValue = MathUtils.random(properMinNum * (100 + propertyPromote) / 100, properMaxNum* (100 + propertyPromote) / 100);
this.propertyValueByIdMap.put(properTyId,finalProperValue);
SWorkShopSetting sWorkShopSetting = SWorkShopSetting.getsWorkShopSettingByLevel(workShopLevle);
Map<Integer, Integer> promoteMap = null;
SPropertyConfig sPropertyConfigFirst = SPropertyConfig.getsPropertyConfigByPID(properTyId);
if(sPropertyConfigFirst != null && sPropertyConfigFirst.getStyle() == GlobalsDef.ABSOLUTE_TYPE){
Integer propertyPromote = null;
if( sWorkShopSetting !=null ){
promoteMap = sWorkShopSetting.getPromoteMap();
if(promoteMap!=null){
propertyPromote = promoteMap.get(properTyId);
}
}
if(propertyPromote==null){
propertyPromote =0;
}
int properMinNum = sEquipConfig.getPropertyMin()[1];
int properMaxNum = sEquipConfig.getPropertyMax()[1];
int finalProperValue = MathUtils.random(properMinNum * (100 + propertyPromote) / 100, properMaxNum* (100 + propertyPromote) / 100);
this.propertyValueByIdMap.put(properTyId,finalProperValue);
}
List<SEquipPropertyPool> sEquipPropertyPoolList = SEquipPropertyPool.getSEquipPropertyPool(sEquipConfig.getPool());
for(SEquipPropertyPool sEquipPropertyPool : sEquipPropertyPoolList){
Integer secondPropertyId = secondValueByIdMap.get(sEquipPropertyPool.getId());
if(secondPropertyId == null ){
int secondPropertyId = sEquipPropertyPool.getPropertyId();
if(!secondValueByIdMap.containsKey(secondPropertyId)){
continue;
}
Integer secondPropertyPromote = promoteMap.get(secondPropertyId);
SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(secondPropertyId);
if(sPropertyConfig == null || sPropertyConfig.getStyle() != GlobalsDef.ABSOLUTE_TYPE){
continue;
}
Integer secondPropertyPromote =null;
if(promoteMap!=null){
secondPropertyPromote = promoteMap.get(secondPropertyId);
}
if(secondPropertyPromote == null){
continue;
secondPropertyPromote =0;
}
int value = MathUtils.random(sEquipPropertyPool.getMin() * (100 + secondPropertyPromote) / 100, sEquipPropertyPool.getMax()* (100 + secondPropertyPromote) / 100);
secondValueByIdMap.put(secondPropertyId,value);
}

View File

@ -24,11 +24,11 @@ public class WorkShopController extends MongoBase {
}
public void add(int type,int openId) throws Exception {
if(openBlueStateMap.containsKey(type)){
if(!openBlueStateMap.containsKey(type)){
openBlueStateMap.put(type,new ArrayList<>());
}
openBlueStateMap.get(type).add(openId);
updateString("openBlueStateMap." + type,1);
updateString("openBlueStateMap." + type, openBlueStateMap.get(type));
}
public void addWorkShopExp(int addExp) throws Exception {

View File

@ -193,8 +193,9 @@ public class HeroLogic {
Map<Integer, List<TeamPosHeroInfo>> teamPosForHero = teamPosManager.getTeamPosForHero();
Map<Integer, String> teamNames = teamPosManager.getTeamNames();
Map<Integer, List<TeamPosForPokenInfo>> teamPosForPoken = teamPosManager.getTeamPosForPoken();
for(Integer teamId:teamPosForHero.keySet()){
List<TeamPosHeroInfo> teamPosHeroInfoList = teamPosForHero.get(teamId);
for(Map.Entry<Integer, List<TeamPosHeroInfo>> item :teamPosForHero.entrySet()){
int teamId = item.getKey();
List<TeamPosHeroInfo> teamPosHeroInfoList = item.getValue();
List<TeamPosForPokenInfo> teamPosForPokenInfos = teamPosForPoken.get(teamId);
if(null == teamPosForPokenInfos){
teamPosForPokenInfos = new ArrayList<>(1);
@ -245,17 +246,6 @@ public class HeroLogic {
}
Set<String> cacheHeroIds = new HashSet<>();
Set<String> alreadyHeroIds = new HashSet<>();
Map<Integer, List<TeamPosHeroInfo>> teamPosForHero = user.getTeamPosManager().getTeamPosForHero();
for(Integer teamIdTmp : teamPosForHero.keySet()){
if(teamIdTmp == teamId){
continue;
}
List<TeamPosHeroInfo> teamPosHeroInfoList = teamPosForHero.get(teamIdTmp);
for(TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList){
alreadyHeroIds.add(teamPosHeroInfo.getHeroId());
}
}
for(CommonProto.TeamHeroInfo teamHeroInfo: heroIds){
String heroId = teamHeroInfo.getHeroId();
if(user.getHeroManager().getHero(heroId) == null) {
@ -266,9 +256,6 @@ public class HeroLogic {
if(cacheHeroIds.contains(heroId)){
return "card repeated";
}
if(alreadyHeroIds.contains(heroId)){
return "card repeated";
}
cacheHeroIds.add(heroId);
}
@ -580,6 +567,8 @@ public class HeroLogic {
case GlobalsDef.SPEED_TYPE:
result = scHero.getSpeed();
break;
default:
break;
}
return result;

View File

@ -114,10 +114,13 @@ public class WorkShopLogic {
}
private void times2Array(int [][] array,int times){
for(int[] a :array){
a[1] =a[1]*times;
private int[][] times2Array(int [][] array,int times){
int[][] result = new int[array.length][];
for(int i=0;i<array.length;i++){
int value = array[i][1] * times;
result[i] = new int[]{array[i][0],value};
}
return result;
}
private boolean checkIsUnlock(int optType,int type,WorkShopController workShopController,int[] openRules){
@ -216,12 +219,13 @@ public class WorkShopLogic {
User user = UserManager.getUser(uid);
SWorkShopFoundationConfig sWorkShopFoundationConfig = SWorkShopFoundationConfig.getShopFoundationConfigMap().get(materialId);
if(!checkIsUnlock(GlobalsDef.WORK_BASE_TYPE,sWorkShopFoundationConfig.getType(),user.getWorkShopController(),sWorkShopFoundationConfig.getOpenRules())){
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开");
return;
// MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开");
// return;
LOGGER.error("不匹配");
}
int[][] cost = sWorkShopFoundationConfig.getCost();
times2Array(cost,nums);
if( !ItemUtil.itemCost(user, cost)){
int[][] reallyCost = times2Array(cost, nums);
if( !ItemUtil.itemCost(user, reallyCost)){
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"道具不足");
return;
}
@ -247,8 +251,9 @@ public class WorkShopLogic {
User user = UserManager.getUser(uid);
SWorkShopEquipmentConfig sWorkShopEquipmentConfig = SWorkShopEquipmentConfig.getsWorkShopEquipmentConfigMap().get(equipTid);
if(!checkIsUnlock(GlobalsDef.WORK_CREATE_TYPE,sWorkShopEquipmentConfig.getType(),user.getWorkShopController(),sWorkShopEquipmentConfig.getOpenRules())){
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开");
return;
// MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开");
// return;
LOGGER.error("不匹配");
}
int runesNum = sWorkShopEquipmentConfig.getRunesNum();
int[][] specialRunes = sWorkShopEquipmentConfig.getSpecialRunes();
@ -318,7 +323,9 @@ public class WorkShopLogic {
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_REBUILD_RESPONSE_VALUE,err);
return;
}
SWorkShopRebuildConfig sWorkShopRebuildConfig = SWorkShopRebuildConfig.getsWorkShopRebuildConfigByQulity(sEquipConfig.getQuality());
int addExp = sWorkShopRebuildConfig.getExp();
user.getWorkShopController().addWorkShopExp(addExp);
equip.rebuildEquip(user.getWorkShopController().getWorkShopLevel());
equipManager.addEquip(equip);
PlayerInfoProto.WorkShopRebuildRespoonse build = PlayerInfoProto.WorkShopRebuildRespoonse.newBuilder().setEquip(CBean2Proto.getEquipProto(equip)).build();

View File

@ -56,8 +56,10 @@ public class RedisRecordSendThread extends Thread{
}
map.get(topic).add(new DefaultTypedTuple<String>(itemInfo,(double)increment));
}
for(String topic : map.keySet()){
RedisUtil.getInstence().zsetAddAall(topic,map.get(topic));
for(Map.Entry<String,Set<ZSetOperations.TypedTuple<String>>> item : map.entrySet()){
String topic = item.getKey();
Set<ZSetOperations.TypedTuple<String>> value = item.getValue();
RedisUtil.getInstence().zsetAddAall(topic,value);
}
}catch (Exception e){

View File

@ -94,8 +94,10 @@ public class CBean2Proto {
private static List<CommonProto.SpecialEffects> parseFromMap(Map<Integer,Integer> propertyValueByIdMap){
List<CommonProto.SpecialEffects> result = new ArrayList<>();
for(Integer propertyId:propertyValueByIdMap.keySet()){
result.add(CommonProto.SpecialEffects.newBuilder().setPropertyId(propertyId).setPropertyValue(propertyValueByIdMap.get(propertyId)).build());
for(Map.Entry<Integer,Integer> item:propertyValueByIdMap.entrySet()){
Integer propertyId = item.getKey();
Integer propertyValue = item.getValue();
result.add(CommonProto.SpecialEffects.newBuilder().setPropertyId(propertyId).setPropertyValue(propertyValue).build());
}
return result;
}
@ -104,8 +106,10 @@ public class CBean2Proto {
public static CommonProto.PokemonInfo getPokemon(Pokemon pokemon) {
Map<Integer, Integer> comonpentsLevelMap = pokemon.getComonpentsLevelMap();
List<CommonProto.Pokemoncomonpent> pokemoncomonpentList = new ArrayList<>();
for(Integer comonpentId : comonpentsLevelMap.keySet()){
pokemoncomonpentList.add(CommonProto.Pokemoncomonpent.newBuilder().setId(comonpentId).setLevel(comonpentsLevelMap.get(comonpentId)).build());
for( Map.Entry <Integer, Integer> item: comonpentsLevelMap.entrySet()){
Integer comonpentId = item.getKey();
Integer value = item.getValue();
pokemoncomonpentList.add(CommonProto.Pokemoncomonpent.newBuilder().setId(comonpentId).setLevel(value).build());
}
return CommonProto.PokemonInfo.newBuilder()
.setId(pokemon.getId())

View File

@ -112,4 +112,10 @@ public class MathUtils {
return original;
}
public static int getMaxNum(int a, int b) {
if(a>=b){
return a;
}
return b;
}
}