* Based on the Basic game of AceyDucey here * https://github.com/coding-horror/basic-computer-games/blob/main/01%20Acey%20Ducey/aceyducey.bas * Note: The idea was to create a version of the 1970's Basic game in Java, without introducing * new features - no additional text, error checking, etc has been added. */ public class AceyDucey { // Current amount of players cash private int playerAmount; // First drawn dealer card private Card firstCard; // Second drawn dealer card private Card secondCard; // Players drawn card private Card playersCard; // User to display game intro/instructions private boolean firstTimePlaying = true; // game state to determine if game over private boolean gameOver = false; // Used for keyboard input private final Scanner kbScanner; // Constant value for cards from a deck - 2 lowest, 14 (Ace) highest public static final int LOW_CARD_RANGE = 2; public static final int HIGH_CARD_RANGE = 14; public AceyDucey() { // Initialise players cash playerAmount = 100; // Initialise kb scanner kbScanner = new Scanner(System.in); } // Play again method - public method called from class invoking game // If player enters YES then the game can be played again (true returned) // otherwise not (false) public boolean playAgain() { System.out.println(); System.out.println("SORRY, FRIEND, BUT YOU BLEW YOUR WAD."); System.out.println(); System.out.println(); System.out.print("TRY AGAIN (YES OR NO) "); String playAgain = kbScanner.next().toUpperCase(); System.out.println(); System.out.println(); if (playAgain.equals("YES")) { return true; } else { System.out.println("O.K., HOPE YOU HAD FUN!"); return false; } } // game loop method public void play() { // Keep playing hands until player runs out of cash do { if (firstTimePlaying) { intro(); firstTimePlaying = false; } displayBalance(); drawCards(); displayCards(); int betAmount = getBet(); playersCard = randomCard(); displayPlayerCard(); if (playerWon()) { System.out.println("YOU WIN!!"); playerAmount += betAmount; } else { System.out.println("SORRY, YOU LOSE"); playerAmount -= betAmount; // Player run out of money? if (playerAmount <= 0) { gameOver = true; } } } while (!gameOver); // Keep playing until player runs out of cash } // Method to determine if player won (true returned) or lost (false returned) // to win a players card has to be in the range of the first and second dealer // drawn cards inclusive of first and second cards. private boolean playerWon() { // winner return (playersCard.getValue() >= firstCard.getValue()) && playersCard.getValue() <= secondCard.getValue(); } private void displayPlayerCard() { System.out.println(playersCard.getName()); } // Get the players bet, and return the amount // 0 is considered a valid bet, but better more than the player has available is not // method will loop until a valid bet is entered. private int getBet() { boolean validBet = false; int amount; do { System.out.print("WHAT IS YOUR BET "); amount = kbScanner.nextInt(); if (amount == 0) { System.out.println("CHICKEN!!"); validBet = true; } else if (amount > playerAmount) { System.out.println("SORRY, MY FRIEND, BUT YOU BET TOO MUCH."); System.out.println("YOU HAVE ONLY " + playerAmount + " DOLLARS TO BET."); } else { validBet = true; } } while (!validBet); return amount; } private void displayBalance() { System.out.println("YOU NOW HAVE " + playerAmount + " DOLLARS."); } private void displayCards() { System.out.println("HERE ARE YOUR NEXT TWO CARDS: "); System.out.println(firstCard.getName()); System.out.println(secondCard.getName()); } // Draw two dealer cards, and save them for later use. // ensure that the first card is a smaller value card than the second one private void drawCards() { do { firstCard = randomCard(); secondCard = randomCard(); } while (firstCard.getValue() >= secondCard.getValue()); } // Creates a random card private Card randomCard() { return new Card((int) (Math.random() * (HIGH_CARD_RANGE - LOW_CARD_RANGE + 1) + LOW_CARD_RANGE)); } public void intro() { System.out.println("ACEY DUCEY CARD GAME"); System.out.println("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"); System.out.println(); System.out.println(); System.out.println("ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER"); System.out.println("THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP"); System.out.println("YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING"); System.out.println("ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE"); System.out.println("A VALUE BETWEEN THE FIRST TWO."); System.out.println("IF YOU DO NOT WANT TO BET, INPUT: 0"); } } ``` Note that we have fairly complete accessibility support, so I'd be interested to hear specifically what is not working for your blind user @thresholdpeople . Also the above code block looks fine in the printed version to me. I just pressed "print" in Chrome then "save as PDF" to generate a PDF version of this very topic: [Export topic as markdown - feature - Discourse Meta.pdf|attachment](upload://mFqpiXnVXEaSlkcnZv2KYDVMEqB.pdf) (249.9 KB) I am not seeing a problem. Please point to specific areas in the PDF that aren't correct if you do see a problem. Thanks! ------------------------- thresholdpeople | 2022-01-14 12:56:52 UTC | #11 Thanks for looking into this. I'm using Vivaldi, but I've used chrome as well, various computers, not all of them with synced browser settings, but when I use print your code block gets cropped at: ``` // Players drawn card private Card playersCard; ``` which is also all I'm able to see up to when viewing your post inline (I have to scroll down inside of the code frame to see more). I'd post my version, but don't have enough posts to upload files, but you get the idea. Your printed version certainly looks better, not sure why it's any different tbh, but it's not perfect either. Code lines do not wrap and are thus cropped, and all the pages have a floating blue rectangle on the bottom left which also obscures some text. Unfortunately in that state, it's not really usable either. Someone on the SuperCollider forum provided the solution of sticking the following CSS block into either the browser's inspector, or when using a browser plugin (currently I have the chrome extension Stylish, and it's auto-adding it when I'm on that forum): ``` pre code { white-space: pre-wrap; max-height: none; background: #fafafa; } ``` Using this makes printing work just fine for me. And with the browser extension not needing to go in and fuss with adding it every I want to save something is the actual fix... otherwise it's too much work. Still I do wish there was an easier way to archive threads, or rather, I wish there was a way to not have needed those additional steps. Especially as most of the functionality already exists: either viewing a post raw or being able to print. But yeah, it's not possible to see the entire thread in raw, just a single post, and printing doesn't work great. That being said, bookmarks are an awesome forum feature and I use them all the time, but it still keeps everything contained inside of discourse. ------------------------- codinghorror | 2022-01-14 18:39:12 UTC | #12 We could add a route that returns the entire topic as raw @falco? That might be useful, though we need to be careful of megatopics.. We certainly already have this for individual posts, e.g. https://meta.discourse.org/raw/152185/12 ------------------------- Falco | 2022-01-14 18:54:29 UTC | #13 That's certainly doable, albeit it's kinda of a niche use case. Format would be something like: ``` username | timestamp | post_number post body --- username | timestamp | post_number post body --- username | timestamp | post_number post body ``` ? ------------------------- codinghorror | 2022-01-14 18:55:41 UTC | #14 Yeah I support it though. If we have a `/raw/` route for posts, why not have one for a topic? ------------------------- Falco | 2022-01-14 19:06:09 UTC | #15 Currently the route https://meta.discourse.org/raw/152185 return only the OP. Is it okay to change the behavior of that route? People will need to explicitly call https://meta.discourse.org/raw/152185/1 to get only the OP. ------------------------- codinghorror | 2022-01-14 20:04:26 UTC | #16 Whatever you think is best is fine with me. ------------------------- Falco | 2022-01-17 22:42:05 UTC | #18 This is live now: https://meta.discourse.org/raw/152185 Let me know if this is what you had in mind @here ------------------------- codinghorror | 2022-01-17 22:51:21 UTC | #19 Love it! Looks good to me! 😍 ------------------------- aschrijver | 2022-01-17 22:55:19 UTC | #20 This is really great. Thank you :pray: ------------------------- thresholdpeople | 2022-01-18 02:08:20 UTC | #21 Thanks so much! and more characters! ------------------------- Falco | 2022-01-22 08:00:37 UTC | #22 This topic was automatically closed after 4 days. New replies are no longer allowed. -------------------------