feat(活动): 添加弹出礼包逻辑
This commit is contained in:
@@ -44,7 +44,11 @@ export class PopUpShopHandler {
|
|||||||
let { conditionType } = msg;
|
let { conditionType } = msg;
|
||||||
if(
|
if(
|
||||||
conditionType != POP_UP_SHOP_CONDITION_TYPE.GACHA_RES_NOT_ENOUGH &&
|
conditionType != POP_UP_SHOP_CONDITION_TYPE.GACHA_RES_NOT_ENOUGH &&
|
||||||
conditionType != POP_UP_SHOP_CONDITION_TYPE.TERAPH_RES_NOT_ENOUGH
|
conditionType != POP_UP_SHOP_CONDITION_TYPE.TERAPH_RES_NOT_ENOUGH &&
|
||||||
|
conditionType != POP_UP_SHOP_CONDITION_TYPE.STONE_NOT_ENOUGH &&
|
||||||
|
conditionType != POP_UP_SHOP_CONDITION_TYPE.EQUIP_STAR_NOT_ENOUGH &&
|
||||||
|
conditionType != POP_UP_SHOP_CONDITION_TYPE.FAVOR_NOT_ENOUGH &&
|
||||||
|
conditionType != POP_UP_SHOP_CONDITION_TYPE.EXP_NOT_ENOUGH
|
||||||
) {
|
) {
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,6 +218,10 @@ export enum POP_UP_SHOP_CONDITION_TYPE {
|
|||||||
AUCTION = 8, // 拍卖行
|
AUCTION = 8, // 拍卖行
|
||||||
TITLE = 9, // 爵位到达x
|
TITLE = 9, // 爵位到达x
|
||||||
TOWER = 10, // 镇念塔到达x层
|
TOWER = 10, // 镇念塔到达x层
|
||||||
|
STONE_NOT_ENOUGH = 11, // 地魄石不足
|
||||||
|
EQUIP_STAR_NOT_ENOUGH = 12, // 精炼道具不足
|
||||||
|
FAVOR_NOT_ENOUGH = 13, // 好感道具不足
|
||||||
|
EXP_NOT_ENOUGH = 14, // 经验道具不足
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum POP_UP_SHOP_REFRESH_TIME_TYPE {
|
export enum POP_UP_SHOP_REFRESH_TIME_TYPE {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ interface PopUpShopPackageInDb {
|
|||||||
id: number; // 弹出礼包id
|
id: number; // 弹出礼包id
|
||||||
conditionType: number; // 条件类型
|
conditionType: number; // 条件类型
|
||||||
canLvUp: number; // 是否可升降
|
canLvUp: number; // 是否可升降
|
||||||
|
canVipLvFirst: number; // 是否优先vip等级,当不购买的时候就降级
|
||||||
items: PopUpShopItemInDb[]; // 礼包
|
items: PopUpShopItemInDb[]; // 礼包
|
||||||
duration: number; // 礼包弹出之后,持续时间,单位小时
|
duration: number; // 礼包弹出之后,持续时间,单位小时
|
||||||
keyItem: PopUpShopKeyItemIbDb[]; // 关键资源限制,refreshDay内可以获得Y个
|
keyItem: PopUpShopKeyItemIbDb[]; // 关键资源限制,refreshDay内可以获得Y个
|
||||||
@@ -154,6 +155,7 @@ export class PopUpShopPackage {
|
|||||||
id: number; // 弹出礼包id
|
id: number; // 弹出礼包id
|
||||||
conditionType: number; // 条件类型
|
conditionType: number; // 条件类型
|
||||||
canLvUp: number; // 是否可升降
|
canLvUp: number; // 是否可升降
|
||||||
|
canVipLvFirst: number; // 是否优先vip等级,当不购买的时候就降级
|
||||||
checkPushingItem: number; // 是否在同类型礼包
|
checkPushingItem: number; // 是否在同类型礼包
|
||||||
duration: number; // 礼包弹出之后,持续时间,单位小时
|
duration: number; // 礼包弹出之后,持续时间,单位小时
|
||||||
refreshTimeType: number; // 刷新时间类型,0-不复现 1-自然日 2-自然周 3-自然月 4-从beginTime开始固定天
|
refreshTimeType: number; // 刷新时间类型,0-不复现 1-自然日 2-自然周 3-自然月 4-从beginTime开始固定天
|
||||||
@@ -170,6 +172,7 @@ export class PopUpShopPackage {
|
|||||||
// setPlayerRecord的时候处理的数据
|
// setPlayerRecord的时候处理的数据
|
||||||
hasPushCnt: number = 0; // 已经推过几次了
|
hasPushCnt: number = 0; // 已经推过几次了
|
||||||
hasPassCnt: number = 0; // 已经被连续无视过几次
|
hasPassCnt: number = 0; // 已经被连续无视过几次
|
||||||
|
latestPassItemId: number = 0; // 最近一次无视了的
|
||||||
|
|
||||||
latestItemId: number = 0; // 升降礼包,最近一次的那档id
|
latestItemId: number = 0; // 升降礼包,最近一次的那档id
|
||||||
latestBought: boolean = false; // 最近一次是否购买
|
latestBought: boolean = false; // 最近一次是否购买
|
||||||
@@ -180,6 +183,7 @@ export class PopUpShopPackage {
|
|||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
this.conditionType = data.conditionType;
|
this.conditionType = data.conditionType;
|
||||||
this.canLvUp = data.canLvUp;
|
this.canLvUp = data.canLvUp;
|
||||||
|
this.canVipLvFirst = data.canVipLvFirst;
|
||||||
this.duration = data.duration;
|
this.duration = data.duration;
|
||||||
this.checkPushingItem = data.checkPushingItem;
|
this.checkPushingItem = data.checkPushingItem;
|
||||||
this.refreshTimeType = data.refreshTimeType;
|
this.refreshTimeType = data.refreshTimeType;
|
||||||
@@ -234,8 +238,10 @@ export class PopUpShopPackage {
|
|||||||
} else if (data.beginTime < now && data.endTime < now) { // 已经结束了的
|
} else if (data.beginTime < now && data.endTime < now) { // 已经结束了的
|
||||||
if(data.hasBought) { // 是否看到了,但是没有买
|
if(data.hasBought) { // 是否看到了,但是没有买
|
||||||
this.hasPassCnt = 0;
|
this.hasPassCnt = 0;
|
||||||
|
this.latestPassItemId = 0;
|
||||||
} else {
|
} else {
|
||||||
this.hasPassCnt ++;
|
this.hasPassCnt ++;
|
||||||
|
this.latestPassItemId = data.items[0].id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,20 +283,46 @@ export class PopUpShopPackage {
|
|||||||
if(!minItem) minItem = item;
|
if(!minItem) minItem = item;
|
||||||
if(!maxItem || maxItem.id > item.id) maxItem = item;
|
if(!maxItem || maxItem.id > item.id) maxItem = item;
|
||||||
|
|
||||||
if(this.canLvUp == 1) { // 升降礼包
|
if(this.checkLvUpCanPush(item) && this.checkVipUpFirstCanPush(item)) {
|
||||||
if(this.latestBought && item.id == this.latestItemId + 1 ) { // 最近一次买了,升级
|
|
||||||
items.push(item);
|
|
||||||
} else if(!this.latestBought && item.id == this.latestItemId - 1 ) {
|
|
||||||
items.push(item);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
items.push(item);
|
items.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.canVipLvFirst == 1) {
|
||||||
|
items.sort((a, b) => a.id - b.id);
|
||||||
|
let maxItem = items[items.length - 1];
|
||||||
|
if (maxItem) {
|
||||||
|
items = items.filter(cur => cur.param == maxItem.param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!items.length && maxItem && minItem) items.push(this.latestBought? maxItem: minItem);
|
if(!items.length && maxItem && minItem) items.push(this.latestBought? maxItem: minItem);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private checkLvUpCanPush(item: PopShopItem) {
|
||||||
|
if(this.canLvUp == 1) { // 升降礼包
|
||||||
|
if(this.latestBought && item.id == this.latestItemId + 1 ) { // 最近一次买了,升级
|
||||||
|
return true
|
||||||
|
} else if(!this.latestBought && item.id == this.latestItemId - 1 ) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 优先显示vip等级,如果忽视过了就降级
|
||||||
|
private checkVipUpFirstCanPush(item: PopShopItem) {
|
||||||
|
if (this.canVipLvFirst == 1) {
|
||||||
|
let maxPassItemId = this.latestPassItemId;
|
||||||
|
let dicItem = maxPassItemId > 0 && this.findItemById(maxPassItemId);
|
||||||
|
if (dicItem && dicItem.param == item.param) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public async getEffectTime() {
|
public async getEffectTime() {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let beginTime = now;
|
let beginTime = now;
|
||||||
@@ -440,6 +472,11 @@ export class PopShopItem {
|
|||||||
return param.oldLv < this.conditionParam[0] && param.newLv >= this.conditionParam[0];
|
return param.oldLv < this.conditionParam[0] && param.newLv >= this.conditionParam[0];
|
||||||
case POP_UP_SHOP_CONDITION_TYPE.TOWER:
|
case POP_UP_SHOP_CONDITION_TYPE.TOWER:
|
||||||
return param.oldLv < this.conditionParam[0] && param.newLv >= this.conditionParam[0];
|
return param.oldLv < this.conditionParam[0] && param.newLv >= this.conditionParam[0];
|
||||||
|
case POP_UP_SHOP_CONDITION_TYPE.STONE_NOT_ENOUGH:
|
||||||
|
case POP_UP_SHOP_CONDITION_TYPE.EQUIP_STAR_NOT_ENOUGH:
|
||||||
|
case POP_UP_SHOP_CONDITION_TYPE.FAVOR_NOT_ENOUGH:
|
||||||
|
case POP_UP_SHOP_CONDITION_TYPE.EXP_NOT_ENOUGH:
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user