mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-08-28 17:26:47 +08:00
feature: multiple lock, pick min max
This commit is contained in:
@@ -102,10 +102,10 @@ export interface EndResult {
|
||||
export function end(
|
||||
state: GameState,
|
||||
profile: ProfileState,
|
||||
lockedTalent?: Talent['id'],
|
||||
locked?: Talent['id'][],
|
||||
) {
|
||||
const ar = atr(Ao.End, state, profile)
|
||||
const p = nextProfile(profile, ar.state, lockedTalent)
|
||||
const p = nextProfile(profile, ar.state, locked)
|
||||
return { profile: p, achievements: ar.triggers }
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export type UniqueCharacter = Omit<Character, 'id' | 'name'>
|
||||
/** 持久化存储的数据 */
|
||||
export interface ProfileState {
|
||||
times: number // 游戏次数
|
||||
lockedTalent?: Talent['id'] // 继承的天赋
|
||||
locked?: Talent['id'][] // 锁定的天赋
|
||||
talents: Set<Talent['id']> // 拥有过的天赋
|
||||
events: Set<Event['id']> // 触发过的事件
|
||||
achievements: Set<Achievement['id']> // 达成的成就
|
||||
@@ -195,7 +195,7 @@ export function lowestProperties(a: Properties, b?: Properties): Properties {
|
||||
export function nextProfile(
|
||||
profile: ProfileState,
|
||||
state: GameState,
|
||||
lockedTalent?: Talent['id'],
|
||||
locked?: Talent['id'][],
|
||||
) {
|
||||
return {
|
||||
times: profile.times + 1,
|
||||
@@ -204,6 +204,6 @@ export function nextProfile(
|
||||
achievements: profile.achievements.union(state.achievements),
|
||||
highest: highestProperties(state.props.highest, profile.highest),
|
||||
lowest: lowestProperties(state.props.lowest, profile.lowest),
|
||||
lockedTalent: lockedTalent ?? profile.lockedTalent,
|
||||
locked,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +70,13 @@ export function pull(
|
||||
)
|
||||
const result = []
|
||||
const map = new Map(Grades.map(g => [g, new Set(GradeMap.get(g))]))
|
||||
if (profile.lockedTalent) {
|
||||
result.push(profile.lockedTalent)
|
||||
const { grade } = talents.get(profile.lockedTalent)!
|
||||
map.get(grade)!.delete(profile.lockedTalent)
|
||||
if (profile.locked) {
|
||||
result.push(...profile.locked)
|
||||
if (result.length >= options.count) return result
|
||||
for (const talent of result) {
|
||||
const { grade } = talents.get(talent)!
|
||||
map.get(grade)!.delete(talent)
|
||||
}
|
||||
}
|
||||
for (let i = options.count - result.length; i > 0; i--) {
|
||||
const grade = pickWeight(rate, rng)! ?? 0
|
||||
|
||||
Reference in New Issue
Block a user