From 9c847148225b2676c36e6d70e2a1d6cf3f8162f8 Mon Sep 17 00:00:00 2001
From: bossanyit <tibor.bossanyi@aitrainer.app>
Date: Wed, 3 Mar 2021 17:54:53 +0100
Subject: [PATCH] WT1.1.7+5 ExerciseControl weight changes for endurance

---
 i18n/en.json                                         |  2 +-
 ios/Runner.xcodeproj/project.pbxproj                 |  6 +++---
 lib/bloc/exercise_control/exercise_control_bloc.dart | 11 ++++++-----
 pubspec.yaml                                         |  2 +-
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/i18n/en.json b/i18n/en.json
index 53a898d..8cd6372 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -144,7 +144,7 @@
   "finished": "finished",
   "Why do you need Exercise Control?" : "Why do you need Test Exercise?",
 
-  "Your 1RM:":"Your One-Rep-Max:",
+  "Your 1RM:":"Your 1RM:",
   "Your Real 1RM:":"Your Real 1RM:",
   "Check":"Check",
   "Control Exercise:": "Test Exercise:",
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 367bb8c..21db79b 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -388,7 +388,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
-				CURRENT_PROJECT_VERSION = 4;
+				CURRENT_PROJECT_VERSION = 5;
 				DEVELOPMENT_TEAM = SFJJBDCU6Z;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -531,7 +531,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
-				CURRENT_PROJECT_VERSION = 4;
+				CURRENT_PROJECT_VERSION = 5;
 				DEVELOPMENT_TEAM = SFJJBDCU6Z;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -566,7 +566,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
-				CURRENT_PROJECT_VERSION = 4;
+				CURRENT_PROJECT_VERSION = 5;
 				DEVELOPMENT_TEAM = SFJJBDCU6Z;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
diff --git a/lib/bloc/exercise_control/exercise_control_bloc.dart b/lib/bloc/exercise_control/exercise_control_bloc.dart
index b790026..744788a 100644
--- a/lib/bloc/exercise_control/exercise_control_bloc.dart
+++ b/lib/bloc/exercise_control/exercise_control_bloc.dart
@@ -35,7 +35,7 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
     oneRepUnitQuantity = exerciseRepository.exercise.unitQuantity;
     initialRM = this.calculate1RM(percent75: false);
     unitQuantity = this.calculate1RM(percent75: true).roundToDouble();
-    quantity = percentToCalculate == 0.75 ? 12 : 30;
+    quantity = percentToCalculate == 0.75 ? 12 : 35;
     origQuantity = quantity;
 
     exerciseRepository.setUnitQuantity(unitQuantity);
@@ -66,7 +66,7 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
           this.unitQuantity = event.quantity;
           exerciseRepository.setUnitQuantity(event.quantity);
           unitQuantity = event.quantity;
-          quantity = calculateQuantityByUnitQuantity();
+          quantity = calculateQuantityByUnitQuantity().toDouble();
           exerciseRepository.setQuantity(quantity);
           origQuantity = quantity;
         }
@@ -113,7 +113,7 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
     return percent75 ? average * this.percentToCalculate : average;
   }
 
-  double calculateQuantityByUnitQuantity() {
+  int calculateQuantityByUnitQuantity() {
     double weight = oneRepUnitQuantity;
     double repeat = oneRepQuantity;
     final double rmWendler = weight * repeat * 0.0333 + weight;
@@ -125,7 +125,8 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
 
     final double repeatWendler = (rmWendler - weight) / 0.0333 / weight;
     final double repeatOconner = (rmOconner / weight - 1) * 40;
-    print("Initial 1RM: $initialRM Weight: $weight repeatWendler: $repeatWendler repeat Oconner: $repeatOconner");
-    return (repeatOconner + repeatWendler) / 2;
+    final newRepeat = ((repeatOconner + repeatWendler) / 2).ceil();
+    print("Initial 1RM: $initialRM Weight: $weight repeatWendler: $repeatWendler repeat Oconner: $repeatOconner. NEW REPEAT: $newRepeat");
+    return newRepeat;
   }
 }
diff --git a/pubspec.yaml b/pubspec.yaml
index 310fa12..763d7e8 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
 # Read more about iOS versioning at
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 1.1.8+58
+version: 1.1.9+59
 
 environment:
   sdk: ">=2.7.0 <3.0.0"