You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.8 KiB
98 lines
3.8 KiB
import { TableNames } from '../game/ConfigTableData';
|
|
import { isBasicHero } from '../battle/config/BattleHeroTable';
|
|
import { StatisticsType } from '../game/GameDataEnums';
|
|
|
|
/** PopHelp:困难模式自动合成说明 */
|
|
export const POP_HELP_TYPE_AUTO_MERGE = 1;
|
|
/** PopHelp:副本玩法说明 */
|
|
export const POP_HELP_TYPE_REPLICA = 2;
|
|
|
|
export interface BattleHelpPopupParam {
|
|
type: typeof POP_HELP_TYPE_AUTO_MERGE | typeof POP_HELP_TYPE_REPLICA;
|
|
desc?: string;
|
|
}
|
|
|
|
/** 自动合成总开关 */
|
|
export const AUTO_MERGE_FEATURE_ENABLED = true;
|
|
|
|
export function isAutoMergeFeatureEnabled(): boolean {
|
|
return AUTO_MERGE_FEATURE_ENABLED;
|
|
}
|
|
|
|
/** 自动合成:herotype === 1 的基础武器(含新增基础武器,不写死 id) */
|
|
export function isAutoMergeWeapon1(weapon1Id: number | null | undefined): boolean {
|
|
if (weapon1Id == null || weapon1Id <= 0) return false;
|
|
const w1 = gg.data.table.getTableData<ITableHero>(TableNames.Hero, weapon1Id);
|
|
return w1 != null && isBasicHero(w1);
|
|
}
|
|
|
|
/** 看视频解锁自动合成所需累计次数 */
|
|
export const AUTO_MERGE_UNLOCK_VIDEO_COUNT = 10;
|
|
|
|
export function getAutoMergeVideoUnlockCount(): number {
|
|
return gg.data.getStatistics(StatisticsType.AutoMergeVideoUnlockCount);
|
|
}
|
|
|
|
export function isAutoMergePermanentlyUnlocked(): boolean {
|
|
return getAutoMergeVideoUnlockCount() >= AUTO_MERGE_UNLOCK_VIDEO_COUNT;
|
|
}
|
|
|
|
/** 累计看视频解锁次数 +1,返回最新次数 */
|
|
export function recordAutoMergeVideoUnlock(): number {
|
|
const next = getAutoMergeVideoUnlockCount() + 1;
|
|
gg.data.setStatistics(StatisticsType.AutoMergeVideoUnlockCount, next);
|
|
return next;
|
|
}
|
|
|
|
/** 显示自动合成功能按钮 btnAutoM */
|
|
export function shouldShowAutoMergeButton(_levelId?: number): boolean {
|
|
return AUTO_MERGE_FEATURE_ENABLED;
|
|
}
|
|
|
|
/** 第一战场:点击自动合成不弹广告面板,本局直接免费激活 */
|
|
export function isLevel1DirectAutoMerge(levelId: number): boolean {
|
|
return levelId === 1;
|
|
}
|
|
|
|
/** @deprecated 使用 isLevel1DirectAutoMerge */
|
|
export function isChapter1HardDirectAutoMerge(levelId: number, _difficulty?: number): boolean {
|
|
return isLevel1DirectAutoMerge(levelId);
|
|
}
|
|
|
|
/** 第一战场:自动合成免费送一次是否仍可用 */
|
|
export function canClaimAutoMergeLevel1Free(levelId: number): boolean {
|
|
if (levelId !== 1) return false;
|
|
if (isAutoMergePermanentlyUnlocked()) return false;
|
|
return gg.data.getStatistics(StatisticsType.AutoMergeChapter1HardFreeClaimed) <= 0;
|
|
}
|
|
|
|
/** @deprecated 使用 canClaimAutoMergeLevel1Free */
|
|
export function canClaimAutoMergeChapter1HardFree(levelId: number, _difficulty?: number): boolean {
|
|
return canClaimAutoMergeLevel1Free(levelId);
|
|
}
|
|
|
|
/** 领取第一战场免费自动合成(跨局持久) */
|
|
export function claimAutoMergeChapter1HardFree(): void {
|
|
gg.data.setStatistics(StatisticsType.AutoMergeChapter1HardFreeClaimed, 1);
|
|
}
|
|
|
|
/** 第一战场首次展示 btnAutoM 时是否显示 dianji 指引 */
|
|
export function shouldShowAutoMergeGuideDianji(levelId: number, _difficulty?: number): boolean {
|
|
return canClaimAutoMergeLevel1Free(levelId);
|
|
}
|
|
|
|
/** 战斗说明按钮:第一战场自动合成说明 */
|
|
export function getBattleHelpPopupParam(levelId: number, _difficulty?: number): BattleHelpPopupParam | null {
|
|
if (!isLevel1DirectAutoMerge(levelId)) return null;
|
|
return { type: POP_HELP_TYPE_AUTO_MERGE };
|
|
}
|
|
|
|
/** 首次进入第一战场:自动弹自动合成说明 */
|
|
export function shouldAutoOpenAutoMergeHelpPopup(levelId: number, _difficulty?: number): boolean {
|
|
if (!isLevel1DirectAutoMerge(levelId)) return false;
|
|
return gg.data.getStatistics(StatisticsType.AutoMergeDeffHelpShown) <= 0;
|
|
}
|
|
|
|
export function markAutoMergeDeffHelpShown(): void {
|
|
gg.data.setStatistics(StatisticsType.AutoMergeDeffHelpShown, 1);
|
|
}
|
|
|