correction on mise calculation

This commit is contained in:
OnlyPapy98
2025-12-16 16:22:43 +01:00
parent b3d94ad038
commit 2fc21fd433
2 changed files with 45 additions and 19 deletions

View File

@@ -159,7 +159,7 @@ public class BetValidation extends Fragment {
private void setupNumberGrid(GridLayout grid) { private void setupNumberGrid(GridLayout grid) {
binding.gridNumbers.removeAllViews(); binding.gridNumbers.removeAllViews();
int columns = 7; int columns = 8;
grid.setColumnCount(columns); grid.setColumnCount(columns);
if(shared.selectedCourse.getValue() != null){ if(shared.selectedCourse.getValue() != null){
for (int i = 1; i <= shared.selectedCourse.getValue().getPartants(); i++) { for (int i = 1; i <= shared.selectedCourse.getValue().getPartants(); i++) {
@@ -238,6 +238,7 @@ public class BetValidation extends Fragment {
AppCompatActivity activity = (AppCompatActivity) getActivity(); AppCompatActivity activity = (AppCompatActivity) getActivity();
if(activity != null){ if(activity != null){
MaterialToolbar toolbar = activity.findViewById(R.id.toolbar); MaterialToolbar toolbar = activity.findViewById(R.id.toolbar);
toolbar.setBackgroundColor( getResources().getColor(R.color.primary_green));
activity.setSupportActionBar(toolbar); activity.setSupportActionBar(toolbar);
if(activity.getSupportActionBar() != null){ if(activity.getSupportActionBar() != null){
activity.getSupportActionBar().setTitle("Pari "+shared.selectedCourse.getValue().getNom()); activity.getSupportActionBar().setTitle("Pari "+shared.selectedCourse.getValue().getNom());
@@ -268,16 +269,30 @@ public class BetValidation extends Fragment {
@Override @Override
public void onChanged(List<String> horses) { public void onChanged(List<String> horses) {
calculateMise(horses); calculateMise(horses);
if(horses.size() > shared.typeOfBet.getValue().getNumberOfHorse()){
binding.elargie.setVisibility(View.VISIBLE);
}else{
binding.elargie.setVisibility(View.GONE);
}
if(shared.typeOfBet.getValue().getNumberOfHorse() > 2 && horses.size() >= shared.typeOfBet.getValue().getNumberOfHorse()){ if(shared.typeOfBet.getValue().getNumberOfHorse() > 2 && horses.size() >= shared.typeOfBet.getValue().getNumberOfHorse()){
binding.order.setVisibility(View.VISIBLE); binding.order.setVisibility(View.VISIBLE);
}else{ }else{
binding.order.setVisibility(View.GONE); binding.order.setVisibility(View.GONE);
} }
if(horses.contains("X")){
if(selectedHorses.getValue().size() == shared.typeOfBet.getValue().getNumberOfHorse()){
binding.elargie.setVisibility(View.VISIBLE);
binding.elargie.setText("Champ total");
return;
}else{
if(selectedHorses.getValue().size() > shared.typeOfBet.getValue().getNumberOfHorse()){
binding.elargie.setVisibility(View.VISIBLE);
binding.elargie.setText("Champ partiel");
return;
}
}
}
if(horses.size() > shared.typeOfBet.getValue().getNumberOfHorse()){
binding.elargie.setVisibility(View.VISIBLE);
binding.elargie.setText("Elargi");
}else{
binding.elargie.setVisibility(View.GONE);
}
} }
}); });
binding.order.setOnCheckedChangeListener((buttonView, isChecked) -> { binding.order.setOnCheckedChangeListener((buttonView, isChecked) -> {
@@ -302,6 +317,10 @@ public class BetValidation extends Fragment {
return; return;
} }
if(this.mise == 0){
Toast.makeText(getContext(), "Pari non valide", Toast.LENGTH_SHORT).show();
return;
}
Pari pari = new Pari( Pari pari = new Pari(
@@ -486,6 +505,12 @@ public class BetValidation extends Fragment {
} }
mise = mise * coeff; mise = mise * coeff;
if(nombreX>0){ if(nombreX>0){
if(nombreChevauxSelectionnes - typeOfBetHorses == 1){
mise = 0;
this.mise = mise;
binding.mise.setText(mise+" CFA");
return;
}
if(nombreChevauxSelectionnes == typeOfBetHorses){ if(nombreChevauxSelectionnes == typeOfBetHorses){
mise = mise * _calculateArrangement((partants - (typeOfBetHorses-nombreX)), nombreX); mise = mise * _calculateArrangement((partants - (typeOfBetHorses-nombreX)), nombreX);
}else{ }else{
@@ -498,8 +523,9 @@ public class BetValidation extends Fragment {
binding.mise.setText(mise+" CFA"); binding.mise.setText(mise+" CFA");
return; return;
} }
mise = mise * _calculateCombinaison(nombreChevauxSelectionnes, typeOfBetHorses); if(!order){
if(order){ mise = mise * _calculateCombinaison(nombreChevauxSelectionnes, typeOfBetHorses);
}else{
mise = mise * _calculateArrangement(nombreChevauxSelectionnes, typeOfBetHorses); mise = mise * _calculateArrangement(nombreChevauxSelectionnes, typeOfBetHorses);
} }
this.mise = mise; this.mise = mise;

View File

@@ -12,27 +12,27 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/gray" android:background="@color/gray"
android:paddingHorizontal="5dp" android:paddingHorizontal="10dp"
android:layout_above="@+id/bottom_buttons"> android:layout_above="@+id/bottom_buttons">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="30dp"> android:paddingBottom="10dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="3dp"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/ic_type_of_bet" android:id="@+id/ic_type_of_bet"
android:layout_width="120dp" android:layout_width="100dp"
android:layout_height="90dp" /> android:layout_height="40dp"
android:src="@drawable/ic_tierce"
/>
<View <View
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
@@ -73,11 +73,11 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:layout_marginVertical="13dp"> android:layout_marginVertical="5dp">
<GridLayout <GridLayout
android:id="@+id/grid_numbers" android:id="@+id/grid_numbers"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:useDefaultMargins="true" /> android:useDefaultMargins="true" />
</LinearLayout> </LinearLayout>
@@ -87,8 +87,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp"> android:layout_marginBottom="10dp"
>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"