|
|
@@ -29,6 +29,7 @@ const HbcpreConstKey = {
|
|
|
exchangeEntryTitleList: 'HbcpreExchangeEntryTitleList',
|
|
|
exchangeEntryTitleCustom: 'HbcpreExchangeEntryTitleCustom',
|
|
|
exchangeActivityTaskMode: 'HbcpreExchangeActivityTaskMode',
|
|
|
+ exchangeRapidFrequencyCount: 'HbcpreExchangeRapidFrequencyCount',
|
|
|
};
|
|
|
|
|
|
const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1`;
|
|
|
@@ -239,6 +240,11 @@ function getHomeExchangeEntrySelectList(){
|
|
|
return retArr;
|
|
|
}
|
|
|
|
|
|
+function getRapidFrequencyCount(){
|
|
|
+ let num = magicJS.data.read(HbcpreConstKey.exchangeRapidFrequencyCount, 2);
|
|
|
+ return Number(num);
|
|
|
+}
|
|
|
+
|
|
|
async function tryAllExchange() {
|
|
|
let taskMode = getExchangeTaskMode();
|
|
|
let idsList = getWillExchangeTaskIds();
|
|
|
@@ -276,13 +282,43 @@ async function tryAllExchange() {
|
|
|
}
|
|
|
|
|
|
async function tryOneExchange(activityId){
|
|
|
- let activityData = getActivitDataCache(3, activityId);
|
|
|
- if(!isExchangeOnlyUseCache()){
|
|
|
- activityData = await getCompositeList(activityId);
|
|
|
- saveActivitDataCache(3, activityData, false);
|
|
|
+ let fCount = getRapidFrequencyCount();
|
|
|
+ let interval = 1000/fCount;
|
|
|
+ let interval2 = interval/2;
|
|
|
+ let activityData = null;
|
|
|
+ let lastTime = Date.now() - interval2;
|
|
|
+ let passTime = 0;
|
|
|
+
|
|
|
+ for(let i = 0; i < fCount; i++){
|
|
|
+ passTime = Date.now() - lastTime;
|
|
|
+ magicJS.logger.info(`Step-A PassTime:${passTime}ms[${i}]`);
|
|
|
+ if(passTime < interval2){
|
|
|
+ await magicJS.utils.sleep(interval2-passTime);
|
|
|
+ }
|
|
|
+ lastTime = Date.now();
|
|
|
+ activityData = getActivitDataCache(3, activityId);
|
|
|
+ if(activityData){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(!isExchangeOnlyUseCache()){
|
|
|
+ let tmpResult = await getCompositeList(activityId);
|
|
|
+ if(tmpResult.code == 200){
|
|
|
+ activityData = tmpResult.data;
|
|
|
+ saveActivitDataCache(3, activityData, false);
|
|
|
+ }
|
|
|
+ if(tmpResult.code == 200){
|
|
|
+ break;
|
|
|
+ } else if(tmpResult.code == 415){//活动已结束
|
|
|
+ magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData?.eventsName}#${activityId}>已结束!`);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!activityData){
|
|
|
+ magicJS.logger.info(`缺少兑换活动数据[${i}]`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
if(!activityData){
|
|
|
- magicJS.logger.info(`缺少兑换活动数据`);
|
|
|
return;
|
|
|
}
|
|
|
// magicJS.logger.error(JSON.stringify(activityData));
|
|
|
@@ -310,20 +346,32 @@ async function tryOneExchange(activityId){
|
|
|
magicJS.notification.appendNotifyInfo(`❌材料不足`);
|
|
|
return;
|
|
|
}
|
|
|
- let result = await startComposite(activityId, materials);
|
|
|
- if(!result){
|
|
|
- magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>兑换失败!`);
|
|
|
- return;
|
|
|
- }
|
|
|
- if(result.code == 200){
|
|
|
- magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>兑换成功,兑换品:${result.data?.worksName}#${result.data?.worksNo}!`);
|
|
|
- // 刷新兑换数据
|
|
|
- activityData = await getCompositeList(activityId);
|
|
|
- saveActivitDataCache(3, activityData, false);
|
|
|
- } else {
|
|
|
- magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>${result.message}`);
|
|
|
+ let cResult = null;
|
|
|
+ for(let i = 0; i < fCount; i++){
|
|
|
+ passTime = Date.now() - lastTime;
|
|
|
+ magicJS.logger.info(`Step-B PassTime:${passTime}ms[${i}]`);
|
|
|
+ if(passTime < interval2){
|
|
|
+ await magicJS.utils.sleep(interval2-passTime);
|
|
|
+ }
|
|
|
+ lastTime = Date.now();
|
|
|
+ cResult = await startComposite(activityId, materials);
|
|
|
+ if(!cResult){
|
|
|
+ magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>兑换失败[${i}]!`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(cResult.code == 200){
|
|
|
+ magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>兑换成功[${i}],兑换品:${result.data?.worksName}#${result.data?.worksNo}!`);
|
|
|
+ // 刷新兑换数据
|
|
|
+ let tmpResult = await getCompositeList(activityId);
|
|
|
+ if(tmpResult.code == 200){
|
|
|
+ activityData = tmpResult.data;
|
|
|
+ saveActivitDataCache(3, activityData, false);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>${result.message}[${i}]`);
|
|
|
+ }
|
|
|
}
|
|
|
- return result;
|
|
|
+ return cResult;
|
|
|
}
|
|
|
|
|
|
async function getActivityIdsByEntryTile(){
|
|
|
@@ -523,10 +571,10 @@ async function getCompositeList(id){
|
|
|
// 无资格
|
|
|
result.code = 200;
|
|
|
}
|
|
|
- if(result.code != 200){
|
|
|
- return null;
|
|
|
- }
|
|
|
- return result.data;
|
|
|
+ // if(result.code != 200){
|
|
|
+ // return null;
|
|
|
+ // }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
async function startComposite(id, materials){
|