活动结束补发奖励
parent
f6e25e2bae
commit
b2d3f59164
|
@ -34,6 +34,8 @@ public class SGlobalActivity implements BaseConfig {
|
|||
|
||||
private int isSaving;
|
||||
|
||||
private int isMail;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
@ -111,4 +113,8 @@ public class SGlobalActivity implements BaseConfig {
|
|||
public int getIsSaving() {
|
||||
return isSaving;
|
||||
}
|
||||
|
||||
public int getIsMail() {
|
||||
return isMail;
|
||||
}
|
||||
}
|
|
@ -119,4 +119,6 @@ public interface BIReason {
|
|||
int CREATE_GUILD_CONSUME = 1031; // 创建宗门消耗
|
||||
int ENDLESS_CONSUME_EXECUTION = 1032; //无尽副本消耗行动力
|
||||
|
||||
int EMAIL_AUTO_TAKE_REWARD = 1033 ;// 活动结束邮件补发未领取奖
|
||||
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.jieling.config.SActivityRewardConfig;
|
||||
import com.ljsd.jieling.config.SErrorCodeEerverConfig;
|
||||
import com.ljsd.jieling.config.SGlobalActivity;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
|
@ -11,12 +14,14 @@ import com.ljsd.jieling.logic.dao.ActivityMission;
|
|||
import com.ljsd.jieling.logic.dao.ActivityProgressInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -45,7 +50,8 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* 子类重写
|
||||
* 子类重写
|
||||
*
|
||||
* @param user
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -85,41 +91,75 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 领奖默认方法 走统一奖励配置表
|
||||
* 重写此类 记得重写onActivityEndOnMySelf 否者活动结束走默认配置表发邮件奖
|
||||
*/
|
||||
@Override
|
||||
public boolean takeReward(ISession session, int missionId) throws Exception {
|
||||
public boolean takeReward(ISession session, int id) throws Exception {
|
||||
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
//check cfg
|
||||
SActivityRewardConfig sActivityRewardConfig = SActivityRewardConfig.getsActivityRewardConfigByMissionId(missionId);
|
||||
if (sActivityRewardConfig == null || sActivityRewardConfig.getActivityId() != id) {
|
||||
MessageUtil.sendErrorResponse(session, 0, rewardResponseValue, "");
|
||||
return false;
|
||||
List<Integer> misssIds = new LinkedList<>();
|
||||
|
||||
if (id == -1) {
|
||||
List<SActivityRewardConfig> cfgs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
|
||||
if (null == cfgs) {
|
||||
return false;
|
||||
}
|
||||
for (SActivityRewardConfig sActivityRewardConfig : cfgs) {
|
||||
misssIds.add(sActivityRewardConfig.getId());
|
||||
}
|
||||
}
|
||||
//check state
|
||||
ActivityManager activityManager = user.getActivityManager();
|
||||
ActivityMission activityMission = activityManager.getActivityMissionMap().get(id);
|
||||
if (activityMission == null || activityMission.getActivityState() != ActivityType.OPEN_STATE || activityMission.getOpenType() == 0) {
|
||||
MessageUtil.sendErrorResponse(session, 0, rewardResponseValue, "activity_close");
|
||||
return false;
|
||||
|
||||
|
||||
List<int[][]> itemArrs = new LinkedList<>();
|
||||
for (Integer missionId : misssIds) {
|
||||
//check cfg
|
||||
SActivityRewardConfig sActivityRewardConfig = SActivityRewardConfig.getsActivityRewardConfigByMissionId(missionId);
|
||||
if (sActivityRewardConfig == null || sActivityRewardConfig.getActivityId() != id) {
|
||||
MessageUtil.sendErrorResponse(session, 0, rewardResponseValue, "");
|
||||
return false;
|
||||
}
|
||||
//check state
|
||||
ActivityManager activityManager = user.getActivityManager();
|
||||
ActivityMission activityMission = activityManager.getActivityMissionMap().get(id);
|
||||
if (activityMission == null || activityMission.getActivityState() != ActivityType.OPEN_STATE || activityMission.getOpenType() == 0) {
|
||||
MessageUtil.sendErrorResponse(session, 0, rewardResponseValue, "activity_close");
|
||||
return false;
|
||||
}
|
||||
ActivityProgressInfo activityProgressInfo = activityMission.getActivityProgressInfoMap().get(missionId);
|
||||
if (activityProgressInfo == null || activityProgressInfo.getState() == ActivityType.HAD_TAKED) {
|
||||
MessageUtil.sendErrorResponse(session, 0, rewardResponseValue, "had taked");
|
||||
return false;
|
||||
}
|
||||
//take rewards check
|
||||
if (!takeRewardsProcess(session, sActivityRewardConfig, activityProgressInfo)) {
|
||||
return false;
|
||||
}
|
||||
//up miss
|
||||
int[][] reward = sActivityRewardConfig.getReward();
|
||||
if (id == -1) {
|
||||
itemArrs.add(reward);
|
||||
continue;
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, BIReason.TAKE_ACTIVITY_REWARD);
|
||||
checkAndSetProgress(activityMission, activityProgressInfo, sActivityRewardConfig, missionId);
|
||||
//send
|
||||
sendActivityProgress(session, activityMission, Collections.singleton(missionId));
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserActivityEvent, id, missionId);
|
||||
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
|
||||
return true;
|
||||
}
|
||||
ActivityProgressInfo activityProgressInfo = activityMission.getActivityProgressInfoMap().get(missionId);
|
||||
if (activityProgressInfo == null || activityProgressInfo.getState() == ActivityType.HAD_TAKED) {
|
||||
MessageUtil.sendErrorResponse(session, 0, rewardResponseValue, "had taked");
|
||||
return false;
|
||||
}
|
||||
//take rewards check
|
||||
if (!takeRewardsProcess(session, sActivityRewardConfig, activityProgressInfo)) {
|
||||
return false;
|
||||
}
|
||||
//up miss
|
||||
int[][] reward = sActivityRewardConfig.getReward();
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, BIReason.TAKE_ACTIVITY_REWARD);
|
||||
checkAndSetProgress(activityMission, activityProgressInfo, sActivityRewardConfig, missionId);
|
||||
//send
|
||||
sendActivityProgress(session, activityMission, Collections.singleton(missionId));
|
||||
KtEventUtils.onKtEvent(user, ParamEventBean.UserActivityEvent, id, missionId);
|
||||
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
|
||||
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("receive_activity_title",new Object[]{sGlobalActivity.getSesc()});
|
||||
String content = SErrorCodeEerverConfig.getI18NMessage("receive_activity_txt", new Object[]{sGlobalActivity.getSesc()});
|
||||
|
||||
String mailReward = ItemUtil.getMailReward(itemArrs);
|
||||
int nowTime = (int) (TimeUtils.now() / 1000);
|
||||
MailLogic.getInstance().sendMail(user.getId(), title, content, mailReward, nowTime, Global.MAIL_EFFECTIVE_TIME);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -158,6 +198,14 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void onActivityEndSelfWithDealReward(User user) throws Exception {
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
if (sGlobalActivity.getIsMail() == 1)
|
||||
onActivityEndDealReward(user);
|
||||
onActivityEndOnMySelf(user);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityEnd() throws Exception {
|
||||
|
||||
|
@ -165,9 +213,24 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
|
|||
|
||||
@Override
|
||||
public void onActivityEndOnMySelf(User user) throws Exception {
|
||||
|
||||
List<SActivityRewardConfig> cfgs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
|
||||
if (null == cfgs) {
|
||||
return;
|
||||
}
|
||||
for (SActivityRewardConfig sActivityRewardConfig : cfgs) {
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
|
||||
takeReward(sessionByUid, sActivityRewardConfig.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动结束邮件 有比较多的潜规则 单号1003747体现
|
||||
*/
|
||||
@Override
|
||||
public void onActivityEndDealReward(User user) throws Exception {
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
|
||||
takeReward(sessionByUid, -1);
|
||||
}
|
||||
|
||||
public List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(ActivityMission activityMission) {
|
||||
return getAllMissInfo(activityMission, null);
|
||||
|
|
|
@ -158,7 +158,7 @@ public class ActivityLogic {
|
|||
ActivityMission activityMission = activityMissionMap.get(activityId);
|
||||
if (activityMission != null) {
|
||||
activityManager.removeActivity(activityId);
|
||||
ActivityTypeEnum.getActicityType(sGlobalActivity.getId()).onActivityEndOnMySelf(user);
|
||||
ActivityTypeEnum.getActicityType(sGlobalActivity.getId()).onActivityEndSelfWithDealReward(user);
|
||||
LOGGER.info("the uid={},remove the activity id ={}", user.getId(), activityId);
|
||||
if (builder != null) {
|
||||
builder.addCloseActivityId(activityId);
|
||||
|
@ -178,7 +178,7 @@ public class ActivityLogic {
|
|||
ActivityMission activityMission = activityMissionMap.get(activityId);
|
||||
if (activityMission != null) {
|
||||
activityManager.removeActivity(activityId);
|
||||
ActivityTypeEnum.getActicityType(sGlobalActivity.getId()).onActivityEndOnMySelf(user);
|
||||
ActivityTypeEnum.getActicityType(sGlobalActivity.getId()).onActivityEndSelfWithDealReward(user);
|
||||
LOGGER.info("the uid={},remove the activity id ={}", user.getId(), activityId);
|
||||
if (builder != null) {
|
||||
builder.addCloseActivityId(activityId);
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.ljsd.jieling.logic.activity;
|
||||
|
||||
import com.ljsd.jieling.config.SActivityRewardConfig;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.ActivityManager;
|
||||
import com.ljsd.jieling.logic.dao.ActivityMission;
|
||||
import com.ljsd.jieling.logic.dao.ActivityProgressInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
|
||||
/**
|
||||
|
@ -14,6 +17,15 @@ class DailyRechargeActivity extends AbstractActivity {
|
|||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(User user) throws Exception {
|
||||
super.onResume(user);
|
||||
//每日充值 补发前日未领取的奖
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
|
||||
takeReward(sessionByUid, -1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
void updateProgress(ActivityMission activityMission, int count) {
|
||||
activityMission.setValue(count + activityMission.getValue());
|
||||
|
@ -24,4 +36,7 @@ class DailyRechargeActivity extends AbstractActivity {
|
|||
return checkValue(session, sActivityRewardConfig, activityProgressInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityEndDealReward(User user) throws Exception {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,4 +58,13 @@ public class DefaultEmptyActivity extends AbstractActivity{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityEndDealReward(User user) throws Exception {
|
||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||
if(sGlobalActivity.getType() == ActivityType.SERVERHAPPY){
|
||||
return;
|
||||
}
|
||||
super.onActivityEndDealReward(user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,5 +116,10 @@ class ForceRankActivity extends AbstractActivity {
|
|||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityEndDealReward(User user) throws Exception {
|
||||
//没有奖励
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,9 @@ public interface IActivity {
|
|||
*/
|
||||
void onActivityEnd() throws Exception;
|
||||
|
||||
public void onActivityEndOnMySelf(User user) throws Exception;
|
||||
void onActivityEndDealReward(User user) throws Exception;
|
||||
|
||||
void onActivityEndOnMySelf(User user) throws Exception;
|
||||
|
||||
List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(ActivityMission activityMission, Set<Integer> filter);
|
||||
|
||||
|
|
|
@ -208,6 +208,21 @@ public class ItemUtil {
|
|||
return getReward(itemMap,cardMap,equipMap,randomMap);
|
||||
}
|
||||
|
||||
|
||||
//指定道具掉落(如:邮件,初始化物品)
|
||||
public static String getMailReward (List<int[][]> itemArrs) throws Exception {
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
Map<Integer, Integer> cardMap = new HashMap<>();
|
||||
Map<Integer,Integer> equipMap = new HashMap<>();
|
||||
Map<Integer,Integer> randomMap = new HashMap<>();
|
||||
for(int[][] itemArr : itemArrs){
|
||||
selectItemArr(itemArr,cardMap,itemMap,equipMap,randomMap);
|
||||
}
|
||||
return getReward(itemMap,cardMap,equipMap,randomMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void combineReward(User user,int[] dropGroupIds,float dropRatio, Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap, Map<Integer, Integer> equipMap, Map<Integer, Integer> randomMap){
|
||||
combineRewardDropGroup(user, dropGroupIds, dropRatio, itemMap, cardMap, equipMap, randomMap);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue