Skip to content

Commit

Permalink
Filter out slots where the character doesn't have any available slots.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Nov 6, 2023
1 parent d6b7faa commit eab9ff6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Spellbook/HigherLevelSlotController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,21 @@ class HigherLevelSlotController: UIViewController {
let maxLevel = status.maxLevelWithSlots()
let range = baseLevel...maxLevel

// TODO: It's kind of gross to need to use this dummy type
// It feels like a refactor of the delegate is necessary
let initialLevel = status.minLevelWithCondition(condition: { level in
return status.hasAvailableSlots(level: level) && level >= baseLevel
})

// TODO: It's kind of gross to need to use this dummy type
// It feels like a refactor of the delegate is necessary
self.textDelegate = TextFieldChooserDelegate<GenericSpellbookAction, Int>(
items: Array(range),
title: "Select Slot Level",
itemProvider: {
() in return initialLevel
},
itemProvider: { () in return initialLevel },
nameGetter: ordinal,
textSetter: ordinal,
nameConstructor: { valueFrom(ordinal: $0) ?? 0 })
nameConstructor: { valueFrom(ordinal: $0) ?? 0 },
itemFilter: { level in return status.hasAvailableSlots(level: level) }
)

slotLevelChooser.text = ordinal(number: initialLevel)
slotLevelChooser.delegate = self.textDelegate!
Expand Down

0 comments on commit eab9ff6

Please sign in to comment.