diff --git a/gen/com/swap/blackjack/BuildConfig.java b/gen/com/swap/blackjack/BuildConfig.java
index 12661e8..f1baa1b 100644
--- a/gen/com/swap/blackjack/BuildConfig.java
+++ b/gen/com/swap/blackjack/BuildConfig.java
@@ -1,6 +1,8 @@
-/** Automatically generated file. DO NOT MODIFY */
+/*___Generated_by_IDEA___*/
+
package com.swap.blackjack;
+/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
- public final static boolean DEBUG = true;
+ public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
index f166d11..bde53be 100644
--- a/res/layout/activity_main.xml
+++ b/res/layout/activity_main.xml
@@ -1,19 +1,54 @@
+ android:id="@+id/parentLayout"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@drawable/back11"
+ android:orientation="vertical">
+
+
-
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+
+
+
+
+
+ android:layout_gravity="right"
+ android:gravity="right">
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/swap/blackjack/MainActivity.java b/src/com/swap/blackjack/MainActivity.java
index 4e241ae..e3eac76 100644
--- a/src/com/swap/blackjack/MainActivity.java
+++ b/src/com/swap/blackjack/MainActivity.java
@@ -8,6 +8,7 @@
import android.media.MediaPlayer;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -69,7 +70,6 @@ public class MainActivity extends Activity implements OnClickListener,
int _splitScore;
int _splitBet = 0;
int _highestScore;
- boolean splitting;
// To make sure no card comes twice
ArrayList _alCardsTracking = new ArrayList();
@@ -100,6 +100,7 @@ public void onCreate(Bundle savedInstanceState) {
imageSwitcherStuff();
// Starting stuff
+ btnDoubleDown.setVisibility(View.GONE);
_money = 500;
tvMoney.setText(" $ " + _money);
sbBetAmount.setMax(_money);
@@ -128,12 +129,6 @@ private void imageSwitcherStuff() {
ivYourCard4.setFactory(this);
ivYourCard5.setFactory(this);
- ivSplitCard1.setFactory(this);
- ivSplitCard2.setFactory(this);
- ivSplitCard3.setFactory(this);
- ivSplitCard4.setFactory(this);
- ivSplitCard5.setFactory(this);
-
ivDealerCard1.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.slide_in_left));
ivDealerCard1.setOutAnimation(AnimationUtils.loadAnimation(this,
@@ -212,13 +207,8 @@ private void resetEveryThing() {
ivYourCard4.setImageResource(R.drawable.default_blue);
ivYourCard5.setImageResource(R.drawable.default_blue);
- ivSplitCard1.setVisibility(View.GONE);
- ivSplitCard2.setVisibility(View.GONE);
- ivSplitCard3.setVisibility(View.GONE);
- ivSplitCard4.setVisibility(View.GONE);
- ivSplitCard5.setVisibility(View.GONE);
-
btnPlaceBet.setVisibility(View.VISIBLE);
+ btnDoubleDown.setVisibility(View.GONE);
hidePlayButtons();
_dealerCardNumber = _playerCardNumber = 0;
_dealerScore = _playerScore = 0;
@@ -308,12 +298,6 @@ private void setupVariables() {
ivYourCard4 = (ImageSwitcher) findViewById(R.id.ivYourCard4);
ivYourCard5 = (ImageSwitcher) findViewById(R.id.ivYourCard5);
- ivSplitCard1 = (ImageSwitcher) findViewById(R.id.ivSplitCard1);
- ivSplitCard2 = (ImageSwitcher) findViewById(R.id.ivSplitCard2);
- ivSplitCard3 = (ImageSwitcher) findViewById(R.id.ivSplitCard3);
- ivSplitCard4 = (ImageSwitcher) findViewById(R.id.ivSplitCard4);
- ivSplitCard5 = (ImageSwitcher) findViewById(R.id.ivSplitCard5);
-
btnHit = (Button) findViewById(R.id.btnHit);
btnStand = (Button) findViewById(R.id.btnStand);
btnSurrender = (Button) findViewById(R.id.btnSurrender);
@@ -324,6 +308,8 @@ private void setupVariables() {
btnPlaceBet = (Button) findViewById(R.id.btnPlaceBet);
btnPlaceBet.setOnClickListener(this);
+ btnDoubleDown = (Button) findViewById(R.id.btnDoubleDown);
+ btnDoubleDown.setOnClickListener(this);
Button btnExit = (Button) findViewById(R.id.btnExit);
btnExit.setOnClickListener(this);
Button btnHelp = (Button) findViewById(R.id.btnHelp);
@@ -374,6 +360,11 @@ public void onClick(View v) {
Toast.LENGTH_SHORT).show();
}
+ break;
+ case R.id.btnDoubleDown:
+
+ btnDoubleDownClick();
+
break;
// Hit
@@ -429,6 +420,52 @@ public void onClick(View v) {
}
+ private void btnDoubleDownClick() {
+ Thread t = new Thread() {
+ public void run() {
+ runOnUiThread(new Runnable() {
+ public void run() {
+ try {
+ sleep(700);
+ _money = _money - _bet;
+ _bet = _bet * 2;
+ showTextViews();
+ btnDoubleDown.setVisibility(View.GONE);
+ playerCall();
+ calculatePlayerScore();
+ // If reached here player has no aces
+ // Aces count as 1
+ if (_playerScore > 21) {
+ for (int i = 0; i < 5; i++) {
+ if (_playerCardArray[i] == 'A' && _playerScoreCount[i] == 11) {
+ _playerScoreCount[i] = 1;
+ Toast.makeText(MainActivity.this,
+ "Aces will be count as 1", Toast.LENGTH_LONG)
+ .show();
+ break;
+ }
+ }
+ calculatePlayerScore();
+ }
+
+ // If reached here player has no aces
+ if (_playerScore > 21) {
+ youLose();
+ showTextViews();
+ }else {
+ btnStandClick();
+ }
+ alertBox();
+ } catch (InterruptedException e) {
+ Log.e("Check", "InterruptedException: ", e);
+ }
+ }
+ });
+ }
+ };
+ t.start();
+ }
+
private void gameStart() {
// Opening 1 Card of Dealer
@@ -441,10 +478,8 @@ private void gameStart() {
// Opening 2 Cards of Player
playerCall();
calculatePlayerScore();
-
- //Check for Split
- if (_playerCardArray[0] == _playerCardArray[1] && _money > _bet) {
- splitAlertBox();
+ if(_money >= _bet) {
+ btnDoubleDown.setVisibility(View.VISIBLE);
}
// Looking for BlackJack
if (_playerScore == 21) {
@@ -850,6 +885,7 @@ public int getIntValueFromCard(char card) {
}
private void btnHitClick() {
+ btnDoubleDown.setVisibility(View.GONE);
playerCall();
calculatePlayerScore();
@@ -897,6 +933,7 @@ public void run() {
}
public void btnStandClick() {
+ btnDoubleDown.setVisibility(View.GONE);
// Computer Play here
do {
// Opening 1 Card of Dealer
@@ -1050,10 +1087,6 @@ public void alertBox() {
alert.setCancelable(false);
String message = "Play Again";
String positive = "Next Hand";
- if (splitting) {
- message = "You previously split, continue?";
- positive = "I am ready";
- }
final String finalMessage = message;
final String finalPositive = positive;
Thread t = new Thread() {