Example #1
0
 /**
  * This method creates a JFrame where everything will be displayed INPUT (parameters): none OUTOUT
  * (return): none
  */
 public static void createAndShowGUI() {
   JFrame frame =
       new JFrame("Black Jack"); // title of the JFrame
   BlackJack demo = new BlackJack(); // create and set up the content pane
   frame.setContentPane(demo.createContentPane());
   frame.setDefaultCloseOperation(
       JFrame.EXIT_ON_CLOSE); // what happens if the user presses the x button
   frame.setSize(950, 760);
   frame.setVisible(true); // ensure frame is visible
 }
Example #2
0
  public static void main(String[] args) {

    int selection = 1;

    switch (selection) {
      case 1:
        War warGame = new War();
        warGame.playWarGame();
        break;
      case 2:
        BlackJack blackJack = new BlackJack();
        blackJack.playBlackJack();
        break;
    }
  }
Example #3
0
File: DNO.java Project: Tlmader/dno
  public static void levelNightmareBlackJack() {

    story(
        "After stepping into what seems to be an old, rustic casino room, the door behind you closes shut.");

    story("In front of you is a dimly lit tabletop, and behind it sits a man.");

    story("You can't quite make out his features with the poor lighting.");

    story(
        "THE DEALER: Welcome, sir. You may call me THE DEALER. May I offer you a wager you surely cannot refuse?");

    story("* Continue to LISTEN to the dealer.\n* QUESTION him about the wager.");
    c1 = "listen";
    c2 = "question";
    decision = decisionProcess(c1, c2);

    if (decision == 2) {
      story("THE DEALER: Ah good sir, I am just getting to that.");
    }

    story("THE DEALER: As you see, I hold the key to your escape.");

    story("The man slowly holds out a rusty key with his gloved hand.");

    story("THE DEALER: Similarly, you hold the key to my own escape.");

    story("THE DEALER: I am a cursed man, cursed to forever be the dealer of this forsaken place.");

    story(
        "THE DEALER: The only way to break my curse is to offer my position to another... willing.");

    story(
        "THE DEALER: So what will it be, will you PLAY?\n* You also have the option to KILL the dealer for the key.");
    c1 = "play";
    c2 = "kill";
    decision = decisionProcess(c1, c2);

    if (decision == 2) {

      if (player.getBlade() == true) {
        story("You brandish your trusty blade and slowly approach the dealer.");
      } else {
        story("You crack your knuckles and slowly approach the dealer.");
      }

      story(
          "THE DEALER: You have no power here, naive sir. Do you truly want to do this?\n* Sit down and PLAY the game.\n* FINISH the job.");
      c1 = "play";
      c2 = "finish";
      decision = decisionProcess(c1, c2);

      if (decision == 1) {
        story("Not willing to take the risk, you stand down.");

        story("THE DEALER: Smart move, sir. Hopefully it reflects in your card game.");
      } else {
        story("You call the dealer's bluff and charge at him!");

        if (player.getBlade() == true) {
          story("Ready to obtain your prize, you drive your blade into his body...");

          story("Instantly, you feel a sharp drive of metal in your own gut!");

          story("You quickly bleed to death from your self-inflicted wound.");

          story("THE DEALER: Good night... sir.");

          player.gameOver();
        } else {
          story("You crack your knuckles and slowly approach the dealer.");

          story("He only sits there as you press both you hands on the sides of his head.");

          story("With a sudden jerk, you twist his neck...");

          story("In a single motion your own neck breaks, instantly killing you!");

          story("THE DEALER: Good night... sir.");

          player.gameOver();
        }
      }
    }

    story("You take a seat, and the dealer pulls out a deck of cards.");

    story("THE DEALER: The game for tonight is Blackjack! Do you know how to play?\n* YES.\n* NO.");
    c1 = "yes";
    c2 = "no";
    decision = decisionProcess(c1, c2);

    if (decision == 1) {
      story("Good. let us begin then.");
    } else {
      story(
          "THE DEALER: The goal of blackjack is to beat the dealer's hand without going over 21.");

      story(
          "THE DEALER: Face cards are worth 10. Aces are worth 1 or 11, whichever makes a better hand.");

      story("THE DEALER: With that being said, let us begin.");
    }

    story("First to three wins the wager!");

    int playerScore = 0;
    int dealerScore = 0;

    while (playerScore < 3 && dealerScore < 3) {
      if (playerScore == 2 && dealerScore == 2) {
        story("THE DEALER: The wager of a millennium! It all goes down to this game!");
      }
      BlackJack blackJackGame = new BlackJack();
      boolean playerWin = BlackJack.playRound();
      if (playerWin == true) {
        playerScore = playerScore + 1;
        if (playerScore == 1 && dealerScore == 0) {
          story("THE DEALER: Let's hope lady luck stays faithful to you. Again!");
        } else if (playerScore == 2) {
          story("THE DEALER: Another win for you, good sir! Very good!");
        }
      } else {
        dealerScore = dealerScore + 1;
        if (dealerScore == 1) {
          story("THE DEALER: Aha! This game belongs to me!");
        } else if (dealerScore == 2) {
          story("THE DEALER: Another win for THE DEALER! I wish you the best of luck, sir.");
        }
      }
      story("SCORE:\nYou: " + playerScore + "\nTHE DEALER: " + dealerScore);
    }

    if (playerScore == 3) {
      story("You won the wager!");

      player.cunMod(1);

      story("THE DEALER: Well, a wager's a wager, and my curse bounds me to my word.");

      story("The dealer places the key upon the table.");

      story("The exit is behind me. Good luck on your further adventures, sir.");
    } else {
      story("You lost the wager!");

      story("THE DEALER: Well, a wager's a wager, and my curse belongs to you now!");

      story(
          "You suddenly lose consciousness, and your body becomes possessed of the dealer's curse!");

      story("No longer caring for gold and adventure, you take the dealer's seat.");

      story("EX-DEALER: I'm free! How long has it been...?");

      player.gameOver();
    }
  }