Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
c8965f70cd
|
@ -101,4 +101,6 @@ public interface BIReason {
|
|||
|
||||
int TIME_REWARD=1026;
|
||||
|
||||
int TEMPORARY_REWARD=1027;
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.ljsd.jieling.ktbeans;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import com.ljsd.jieling.config.SGlobalActivity;
|
||||
import com.ljsd.jieling.config.SRechargeCommodityConfig;
|
||||
import com.ljsd.jieling.config.reportData.DataMessageUtils;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.ktbeans.BeanBuilder.ParamBuilder;
|
||||
|
@ -80,7 +81,8 @@ public class KtEventUtils {
|
|||
String orderId = (String)parm[1];
|
||||
String payValid = payResult[(int)parm[2]];
|
||||
String amount = String.valueOf( ((int)parm[3]/10));
|
||||
paramEventBean.add(String.valueOf(goodsId));
|
||||
SRechargeCommodityConfig sRechargeCommodityConfig = SRechargeCommodityConfig.rechargeCommodityConfigMap.get(goodsId);
|
||||
paramEventBean.add("IN_GAME_"+sRechargeCommodityConfig.getType());
|
||||
paramEventBean.add(orderId);
|
||||
paramEventBean.add(payValid);
|
||||
paramEventBean.add(amount);
|
||||
|
@ -98,7 +100,7 @@ public class KtEventUtils {
|
|||
|
||||
KTParam ktParam = ParamBuilder.paramBuild(user, eventType, paramEventBean);
|
||||
DataMessageUtils.addLogQueue(ktParam);
|
||||
LOGGER.info("ktparm -- > {}",gson.toJson(ktParam));
|
||||
// LOGGER.info("ktparm -- > {}",gson.toJson(ktParam));
|
||||
}
|
||||
public static ParamEnvironmentBean enviromentBuild(int uid){
|
||||
return KTEnvironmentUtil.getUserEnviromentInfoById(uid);
|
||||
|
|
|
@ -190,6 +190,7 @@ public class ArenaLogic {
|
|||
defScoreChange = calScore(defScore, myscore,fightResult==1?0:1);
|
||||
|
||||
}
|
||||
LOGGER.info("the uid={},the defUid={},myscore={},defScore={},fightResult={},myScoreChange={},defScoreChange={}",uid,challengeUid,myscore,defScore,fightResult,myscoreChange,defScoreChange);
|
||||
if(arenaManager.getCount() == 0){
|
||||
RedisUtil.getInstence().incrementZsetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason),Integer.toString(uid),myscoreChange + myscore);
|
||||
}else{
|
||||
|
@ -534,11 +535,12 @@ public class ArenaLogic {
|
|||
R'b = Rb + K(Sb-Eb)
|
||||
*
|
||||
*/
|
||||
public int calScore(int myScore,int defScore,int result){
|
||||
public int calScore(int myScore,int defScore,int result){
|
||||
SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
|
||||
int k = sArenaSetting.getK();
|
||||
double ea = 1.0/(1 + Math.pow(10,(defScore - myScore)/400.0f));
|
||||
return (int)(k*(result-ea));
|
||||
int parm = result == 1?1:-1;
|
||||
return (int)(k*(result-ea) + 0.5*parm);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,14 @@ public class BuyGoodsLogic {
|
|||
return;
|
||||
}
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.TEST_BUY_GIGT_GOODS_RESPONSE_VALUE,null,true);
|
||||
sendGoods(uid,goodsId,"gm-test","111111",System.currentTimeMillis(),-1);
|
||||
Result result = sendGoods(uid, goodsId, "gm-test", "111111", System.currentTimeMillis(), -1);
|
||||
User user = UserManager.getUser(uid);
|
||||
int price =sRechargeCommodityConfig.getPrice();
|
||||
int isDiscount = sRechargeCommodityConfig.getIsDiscount();
|
||||
if(isDiscount!=0){
|
||||
price=(int)(sRechargeCommodityConfig.getPrice() * (10 + isDiscount)/10f);
|
||||
}
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserPayEvent,goodsId,System.currentTimeMillis()+"",result.getResultCode(),price*10);
|
||||
}
|
||||
|
||||
public static Result sendGoods(int uid, int goodsId, String openId, String orderId, long orderTime, int amount) throws Exception {
|
||||
|
|
|
@ -248,7 +248,12 @@ public class StoreLogic {
|
|||
if(limit!=0){
|
||||
boolean check =true;
|
||||
if(relatedtoVIP == 1){
|
||||
check = playerInfoManager.check(limit, itemNum);
|
||||
if(limit == 6){
|
||||
int goodsNum = sStoreConfig.getGoods()[1]*itemNum;
|
||||
check = playerInfoManager.check(limit, goodsNum);
|
||||
}else{
|
||||
check = playerInfoManager.check(limit, itemNum);
|
||||
}
|
||||
}else{
|
||||
check = limit > buyTimes;
|
||||
}
|
||||
|
@ -262,7 +267,11 @@ public class StoreLogic {
|
|||
return "道具不足";
|
||||
}
|
||||
if(relatedtoVIP == 1 && limit!=0){
|
||||
playerInfoManager.updateVipPrivilage(limit,itemNum);
|
||||
int updateValue = itemNum;
|
||||
if(limit == 6){
|
||||
updateValue= sStoreConfig.getGoods()[1]*itemNum;
|
||||
}
|
||||
playerInfoManager.updateVipPrivilage(limit,updateValue);
|
||||
}
|
||||
itemNumMap.put(itemId,buyTimes +itemNum);
|
||||
storeInfo.setItemNumMap(itemNumMap);
|
||||
|
|
|
@ -405,6 +405,7 @@ public class ItemUtil {
|
|||
}
|
||||
List<CommonProto.Item> itemProtoList = new CopyOnWriteArrayList<>();
|
||||
ItemManager itemManager = user.getItemManager();
|
||||
List<CommonProto.Item> sendToFront = new CopyOnWriteArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
|
||||
SItem sItem = SItem.getsItemMap().get (entry.getKey());
|
||||
if (sItem == null){
|
||||
|
@ -442,10 +443,14 @@ public class ItemUtil {
|
|||
String message = SErrorCodeEerverConfig.getI18NMessage("lamp_lottery_differ_content", new Object[]{nickName,sItem.getName()});
|
||||
ChatLogic.getInstance().sendSysChatMessage(message,Global.LUCKY_LUCK,sItem.getId(),0,0,0,0,0);
|
||||
}
|
||||
sendToFront.add(CBean2Proto.getItem(item,-1));
|
||||
}
|
||||
if (dropBuilder != null) {
|
||||
dropBuilder.addAllItemlist(itemProtoList);
|
||||
}
|
||||
if(!sendToFront.isEmpty()){
|
||||
MessageUtil.sendBagIndication(user.getId(),0,sendToFront);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,6 +469,7 @@ public class ItemUtil {
|
|||
temporaryItems = new TemporaryItems();
|
||||
}
|
||||
Map<Integer, Item> items = temporaryItems.items;
|
||||
List<CommonProto.Item> sendToFront = new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
|
||||
SItem sItem = SItem.getsItemMap().get(entry.getKey());
|
||||
if (sItem == null) {
|
||||
|
@ -477,6 +483,8 @@ public class ItemUtil {
|
|||
item.setItemNum(item.getItemNum() + entry.getValue());
|
||||
}
|
||||
itemProtoList.add(CBean2Proto.getItem(item,entry.getValue()));
|
||||
sendToFront.add(CBean2Proto.getItem(item,-1));
|
||||
LOGGER.info("the uid={},the curMapId={},add item={},addItemNum={},totalItemNum={}",user.getId(),user.getMapManager().getCurMapId(),entry.getKey(),entry.getValue(),item.getItemNum());
|
||||
}
|
||||
Set<Equip> equips = temporaryItems.equips;
|
||||
for (Map.Entry<Integer, Integer> entry : equipMap.entrySet()) {
|
||||
|
@ -487,12 +495,17 @@ public class ItemUtil {
|
|||
Equip equip = new Equip(user.getId(), entry.getKey());
|
||||
equips.add(equip);
|
||||
equipProtoList.add(CBean2Proto.getEquipProto(equip));
|
||||
LOGGER.info("the uid={},the curMapId={},add equip={},equipNum={},totalEquipNum={}",user.getId(),user.getMapManager().getCurMapId(),entry.getKey(),1,equips.size());
|
||||
}
|
||||
mapManager.setTemporaryItems(temporaryItems);
|
||||
if (dropBuilder != null) {
|
||||
dropBuilder.addAllItemlist(itemProtoList);
|
||||
dropBuilder.addAllEquipId(equipProtoList);
|
||||
}
|
||||
|
||||
if(!sendToFront.isEmpty()){
|
||||
MessageUtil.sendBagIndication(user.getId(),1,sendToFront);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -510,6 +523,7 @@ public class ItemUtil {
|
|||
Map<Integer, Item> itemMap = user.getItemManager().getItemMap();
|
||||
StringBuilder rewardStr = new StringBuilder();
|
||||
boolean isFirst = true;
|
||||
List<CommonProto.Item> sendToFront = new CopyOnWriteArrayList<>();
|
||||
for (Map.Entry<Integer, Item> entry : items.entrySet()) {
|
||||
SItem sItem = SItem.getsItemMap().get (entry.getKey());
|
||||
if (sItem == null){
|
||||
|
@ -535,9 +549,19 @@ public class ItemUtil {
|
|||
} else {
|
||||
item = user.getItemManager().newItem(temporaryItem.getItemId(), temporaryItem.getItemNum());
|
||||
}
|
||||
int eventType = ParamEventBean.UserItemEvent;
|
||||
if(currencyMap.contains(entry.getKey())){
|
||||
eventType = ParamEventBean.UserCurrencyEvent;
|
||||
}
|
||||
sendToFront.add(CBean2Proto.getItem(item,-1));
|
||||
KtEventUtils.onKtEvent(user, eventType,BIReason.TEMPORARY_REWARD,GlobalsDef.addReason,temporaryItem.getItemId(),temporaryItem.getItemNum(),item.getItemNum());
|
||||
itemMap.put(entry.getKey(), item) ;
|
||||
|
||||
}
|
||||
user.getItemManager().setItemMap(itemMap);
|
||||
if(!sendToFront.isEmpty()){
|
||||
MessageUtil.sendBagIndication(user.getId(),0,sendToFront);
|
||||
}
|
||||
for (Equip equip : equips) {
|
||||
SItem sItem = SItem.getsItemMap().get (equip.getEquipId());
|
||||
if (sItem == null){
|
||||
|
@ -556,6 +580,7 @@ public class ItemUtil {
|
|||
continue;
|
||||
}
|
||||
user.getEquipManager().addEquip(user,equip);
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserItemEvent,BIReason.TEMPORARY_REWARD,GlobalsDef.addReason,sItem.getId(),1,-1);
|
||||
}
|
||||
user.getMapManager().setTemporaryItems(null);
|
||||
if(!isVictory){
|
||||
|
@ -577,6 +602,8 @@ public class ItemUtil {
|
|||
if (temporaryItems != null) {
|
||||
temporaryItemList = temporaryItems.items;
|
||||
}
|
||||
List<CommonProto.Item> sendToFront = new ArrayList<>();
|
||||
List<CommonProto.Item> sendTemToFront = new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> userItem : useItemMap.entrySet()) {
|
||||
if ((userItem.getKey() == Global.STAMINA)){
|
||||
MapManager.getEnergy(user);
|
||||
|
@ -590,10 +617,12 @@ public class ItemUtil {
|
|||
int leftNum = temporaryItem.getItemNum() - needCount;
|
||||
if (leftNum >= 0) {
|
||||
temporaryItem.setItemNum(leftNum);
|
||||
sendTemToFront.add(CBean2Proto.getItem(temporaryItem,-1));
|
||||
continue;
|
||||
} else {
|
||||
temporaryItemList.remove(userItem.getKey());
|
||||
needCount = Math.abs(leftNum);
|
||||
sendTemToFront.add(CBean2Proto.getItem(temporaryItem,0));
|
||||
}
|
||||
}
|
||||
Item myItem = itemManager.getItem(userItem.getKey());
|
||||
|
@ -606,12 +635,20 @@ public class ItemUtil {
|
|||
}
|
||||
|
||||
if (myItem.getItemNum() <= needCount && !notDelete.contains(userItem.getKey())) {
|
||||
myItem.setItemNum(0);
|
||||
itemManager.removeItem(userItem.getKey());
|
||||
KtEventUtils.onKtEvent(user, eventType,reason,GlobalsDef.subReason,myItem.getItemId(),needCount,0);
|
||||
} else {
|
||||
myItem.setItemNum(myItem.getItemNum() - needCount);
|
||||
KtEventUtils.onKtEvent(user, eventType,reason,GlobalsDef.subReason,myItem.getItemId(),needCount,myItem.getItemNum());
|
||||
}
|
||||
sendToFront.add(CBean2Proto.getItem(myItem,-1));
|
||||
}
|
||||
if(!sendToFront.isEmpty()){
|
||||
MessageUtil.sendBagIndication(user.getId(),0,sendToFront);
|
||||
}
|
||||
if(!sendTemToFront.isEmpty()){
|
||||
MessageUtil.sendBagIndication(user.getId(),1,sendTemToFront);
|
||||
}
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.CONSUMER_MATERIAL,useItemMap);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,14 @@ public class MessageUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void sendBagIndication(int sendUid,int type, List<CommonProto.Item> sendToFront) {
|
||||
ISession session = OnlineUserManager.sessionMap.get(sendUid);
|
||||
if(session!=null){
|
||||
PlayerInfoProto.UpdateBagIndication build = PlayerInfoProto.UpdateBagIndication.newBuilder().addAllItem(sendToFront).setType(type).build();
|
||||
MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.UPDATE_BAG_INDICATION_VALUE,build,true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMessage(ISession session, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
||||
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(), result, msgId, generatedMessage);
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue