三连胜提交
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
export type StartBoostProp = "hourglass" | "rocket";
|
||||
|
||||
export interface StartBoostLoadout {
|
||||
streak: number;
|
||||
hourglass: boolean;
|
||||
rocket: boolean;
|
||||
spentHourglass?: boolean;
|
||||
spentRocket?: boolean;
|
||||
}
|
||||
|
||||
export function startBoostRewards(streak: number): { hourglass: number; rocket: number } {
|
||||
return { hourglass: streak >= 3 ? 3 : streak > 0 ? 2 : 0,
|
||||
rocket: streak >= 3 ? 2 : streak >= 2 ? 1 : 0 };
|
||||
}
|
||||
|
||||
export function infiniteStartBoost(info: any, prop: StartBoostProp): boolean {
|
||||
return Number(info[prop === "hourglass" ? "infiniteHourglassTime" : "infiniteRocketTime"]) > Date.now() / 1000;
|
||||
}
|
||||
|
||||
export function canCarryStartBoost(info: any, prop: StartBoostProp): boolean {
|
||||
return infiniteStartBoost(info, prop) || info[prop + "Amount"] > 0;
|
||||
}
|
||||
|
||||
/** 原配置只在未开始的重开中复用;已使用的自选道具不重复扣。 */
|
||||
export function consumeCarriedStartBoost(loadout: StartBoostLoadout, prop: StartBoostProp, info: any): boolean {
|
||||
const spent = prop === "hourglass" ? "spentHourglass" : "spentRocket";
|
||||
if (!loadout[prop] || loadout[spent]) return false;
|
||||
loadout[spent] = true;
|
||||
if (infiniteStartBoost(info, prop)) return false;
|
||||
info[prop + "Amount"] = Math.max(0, (Number(info[prop + "Amount"]) || 0) - 1);
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user