Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //на отрисовке предикшенов
- if predictionsInfo[i].number == 1 || predictionsInfo[i].number == 2 || predictionsInfo[i].defaultType! != .normal {
- predictionableView.makeBestChoice()
- }
- predictionableView.updateBet(OBGlobalConstants.minBet)
- //когда жмем next
- @IBAction private func didTapNext(_ sender: UIButton) {
- var indexesWithoutChoice = Array<Int>()
- var indexesWithoutBet = Array<Int>()
- for i in 0..<pageControl.numberOfPages {
- let predictionView = predictionsView[i]
- if let predictionTwoOptionsView = predictionView as? OBPredictionTwoOptionsView, predictionTwoOptionsView.currentOptionType == nil {
- indexesWithoutChoice.append(i)
- }
- else if let predictionThreeOptionsView = predictionView as? OBPredictionThreeOptionsView, predictionThreeOptionsView.currentOptionType == nil {
- indexesWithoutChoice.append(i)
- }
- if predictionBets[i] < OBGlobalConstants.minBet {
- indexesWithoutBet.append(i)
- }
- }
- if indexesWithoutChoice.contains(pageControl.currentPage) {
- OBAlertManager.showMessage(NSLocalizedString("validation_prediction_make_your_choice", comment: ""), handler: nil)
- return
- }
- else if indexesWithoutBet.contains(pageControl.currentPage) {
- let message = String(format: NSLocalizedString("validation_prediction_min_bet", comment: ""), OBGlobalConstants.minBet)
- OBAlertManager.showMessage(message, handler: nil)
- return
- }
- else {
- for i in 0..<pageControl.currentPage {
- if indexesWithoutChoice.contains(i) {
- OBAlertManager.showMessage(NSLocalizedString("validation_prediction_make_your_choice", comment: ""), handler: nil)
- showPage(i)
- return
- }
- else if indexesWithoutBet.contains(i) {
- let message = String(format: NSLocalizedString("validation_prediction_min_bet", comment: ""), OBGlobalConstants.minBet)
- OBAlertManager.showMessage(message, handler: nil)
- showPage(i)
- return
- }
- }
- }
- if let index = predictionsView.index(where: {type(of: $0) == OBPredictionScoreView.self}), index <= pageControl.currentPage, verifyScore() == false {
- OBAlertManager.showMessage(NSLocalizedString("validation_predictions_wrong_score_value", comment: ""), handler: nil)
- showPage(index)
- return
- }
- let nextPage = pageControl.currentPage + 1
- nextPage == pageControl.numberOfPages ?
- showConfirmPredictionsAlert() :
- showPage(nextPage)
- }
- //проверка счета
- private func verifyScore() -> Bool {
- var result = true
- if let scoreView = predictionsView.first(where: {type(of: $0) == OBPredictionScoreView.self}) as? OBPredictionScoreView, match.type! == .tennis {
- let countMaxScore = scoreView.currentScore.map { String($0) }.filter { $0 == String(scoreView.maxScore) }.count
- result = countMaxScore == 1 ? true : false
- }
- return result
- }
- //после загрузки предикшенов
- if self?.predictionsInfo[0].defaultType! == .luxe {
- self?.showPage((self?.pageControl.numberOfPages)! - 1)
- self?.showConfirmPredictionsAlert()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement