룰렛 최대 개수 수정
AS-IS : 최대 6개 TO-BE : 최대 10개 룰렛 확률 수정 AS-IS : 소수점 없음 TO-BE : 소수점 2자리
This commit is contained in:
@@ -1474,7 +1474,8 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
||||
private func calculatePercentages(options: [RouletteItem]) -> [RoulettePreviewItem] {
|
||||
let totalWeight = options.reduce(0) { $0 + $1.weight }
|
||||
let updatedOptions = options.map { option in
|
||||
RoulettePreviewItem(title: option.title, percent: "\(Int(Float(option.weight) / Float(totalWeight) * Float(100)))%")
|
||||
let percent = floor(Double(option.weight) / Double(totalWeight) * 10000) / 100
|
||||
return RoulettePreviewItem(title: option.title, percent: "\(String(format: "%.2f", percent))%")
|
||||
}
|
||||
|
||||
return updatedOptions
|
||||
|
Reference in New Issue
Block a user