README.CONTEST
README.CONTEST · 9.0 KB
From the archive CoffeeMudEntry.zip
Download the archive « Back to the archive contents
Deck Of Cards for CoffeeMud
---------------------------
Purpose:
-------
The purpose of this code is to comply with the MudMagic.com Text Game Code
Challenge.
License:
--------
The source code for this project is distributed under the BSD license.
Compatibility:
--------------
The library will work with versions 4.7.6 (public) of the CoffeeMud code
base and higher.
Structure:
----------
The library consists of three source files and three pre-compiled files,
located in the library/com/planet_ink/coffee_mud/Items/MiscMagic folder.
Those files are
PlayingCard.java
PlayingCard.class
HandOfCards.java
HandOfCards.class
DeckOfCards.java
DeckOfCards.class
Installation:
-------------
The three files mentioned previously should be copied into the
com/planet_ink/coffee_mud/Items/MiscMagic folder, which is located
in the main CoffeeMud installation folder.
Precompiled versions of those files (*.class) are also available. Those
files should be copied into the same place as the *.java files.
After copying the source files, they may be recompiled if desired. Your
mud should be rebooted in order to make the files available to the system.
Usage:
------
The library is implemented as a set of CoffeeMud Items. This means
that there are ways of using the library in a limited way from within the
mud itself.
You can log into CoffeeMud as an Archon (builder) character and issue
the following command:
CREATE Item DeckOfCards
GET deck
The deck of cards operates as a special container, which means that the
PlayingCard items inside the deck can be removed and replaced manually
using the GET and PUT commands.
Compliance:
-----------
Due to the object-oriented nature of java, the required functionality for
compliance with the rules of the Challenge are spread among the three
aforementioned java files.
*Requirements:
*A standard 52 card deck will be created and a Hand will be assigned
*to a specific player. The final work should allow for the shuffling,
*distribution, and retrieval of a hands information.
*deck functions or class provides CoffeeMud the following functionality:
*-method for the creation of a deck of 52 cards
>File: DeckOfCards.java
>Method: public static DeckOfCards createDeck(Environmental owner)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : DeckOfCards deck=DeckOfCards.createDeck(aPlayerMob);
> : DeckOfCards deck=DeckOfCards.createDeck(aRoom);
* -method to shuffle a deck of cards
>File: HandOfCards.java (superclass of DeckOfCards.java)
>Method: public boolean shuffleDeck()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null)
> : deck.shuffleDeck();
* -method to return the top card of a deck and removes it from the deck
>File: HandOfCards.java (superclass of DeckOfCards.java)
>Method: public PlayingCard getTopCardFromDeck()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : PlayingCard card=deck.getTopCardFromDeck();
* -method to add a card to the bottom of the deck(the card should not already be in the deck)
>File: HandOfCards.java (superclass of DeckOfCards.java)
>Method: public boolean addCard(PlayingCard card)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : PlayingCard card=deck.getTopCardFromDeck();
> : deck.addCard(card);
* -method to return a value with total number of cards in deck
>File: HandOfCards.java (superclass of DeckOfCards.java)
>Method: public int numberOfCards()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : int number_of_cards=deck.numberOfCards();
* -method to reset the deck to 52 cards
>File: DeckOfCards.java
>Method: public boolean resetDeckBackTo52Cards()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : deck.resetDeckBackTo52Cards();
* -method to return values of the cards in the deck ( H6, C3, SK, etc )
>File: HandOfCards.java (superclass of DeckOfCards.java)
>Method: public String[] getContentsEncoded()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : String[] all_card_values=deck.getContentsEncoded();
>
>File: HandOfCards.java (superclass of DeckOfCards.java)
>Method: public Vector getContents()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : Vector all_playing_cards=deck.getContents();
* hand functions or class provides CoffeeMud the following functionality
* -method to add a new empty hand to a player
>File: DeckOfCards.java
>Method: public HandOfCards addPlayerHand(MOB player, HandOfCards cards)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
>
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=HandOfCards.createEmptyHand(aPlayerMob);
> : deck.addPlayerHand(aPlayerMob, hand);
* -method to add a card to a players hand
>File: HandOfCards.java
>Method: public boolean addCard(PlayingCard card)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : hand.addCard(deck.getTopCardFromDeck());
* -method to count how many cards are in a hand
>File: HandOfCards.java
>Method: public int numberOfCards()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : hand.addCard(deck.getTopCardFromDeck());
> : hand.addCard(deck.getTopCardFromDeck());
> : int number_of_cards=hand.numberOfCards();
* -method to remove a particular card from a hand.
>File: HandOfCards.java
>Method: public boolean removeCard(PlayingCard card)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : PlayingCard card=deck.deck.getTopCardFromDeck();
> : hand.addCard(card);
> : hand.removeCard(card); // card is now nowhere!
* -method that returns true if the hand contains one or more cards of a given value
>File: HandOfCards.java
>Method: public boolean containsAtLeastOneOfValue(String cardStringCode)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : hand.addCard(deck.getTopCardFromDeck());
> : hand.addCard(deck.getTopCardFromDeck());
> : if(containsAtLeastOneOfValue("Q"))
> : System.out.println("The hand has a Queen.");
>
>Method: public boolean containsAtLeastOneOfValue(int cardBitCode)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : hand.addCard(deck.getTopCardFromDeck());
> : hand.addCard(deck.getTopCardFromDeck());
> : if(containsAtLeastOneOfValue(12))
> : System.out.println("The hand has a Queen.");
* -method that returns true if the hand contains one or more cards of a given suit
>File: HandOfCards.java
>Method: public boolean containsAtLeastOneOfSuit(String cardStringCode)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : hand.addCard(deck.getTopCardFromDeck());
> : hand.addCard(deck.getTopCardFromDeck());
> : if(containsAtLeastOneOfSuit("C"))
> : System.out.println("The hand has a Club.");
>
>Method: public boolean containsAtLeastOneOfSuit(int cardBitCode)
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : hand.addCard(deck.getTopCardFromDeck());
> : hand.addCard(deck.getTopCardFromDeck());
> : if(containsAtLeastOneOfSuit(PlayingCard.suits[1]))
> : System.out.println("The hand has a Club.");
* -method to return values of the cards in a hand ( H6, C3, SK, etc )
>File: HandOfCards.java (superclass of DeckOfCards.java)
>Method: public String[] getContentsEncoded()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : hand.addCard(deck.getTopCardFromDeck());
> : hand.addCard(deck.getTopCardFromDeck());
> : String[] all_card_values=hand.getContentsEncoded();
>
>File: HandOfCards.java (superclass of DeckOfCards.java)
>Method: public Vector getContents()
>Usage: DeckOfCards deck=DeckOfCards.createDeck(null);
> : HandOfCards hand=deck.addPlayerHand(aPlayerMob, null);
> : hand.addCard(deck.getTopCardFromDeck());
> : hand.addCard(deck.getTopCardFromDeck());
> : Vector all_playing_cards=hand.getContents();
* Output Developers are encouraged to be creative. Using basic values for
* card representation is "ok". Example: Hearts 6, viewable as: H6 or an
* ascii image
* Suggestions: Keep it simple to start. Use basic suits & ranks for your cards. Example:
* suits - ['S','C','D','H']
* ranks - [ '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A' ]
> The values and suits in cards are encoded in many ways for retreival:
> by string suit and string value (the string encoded value)
> by bit encoded suit and bit encoded value (see PlayingCard.java)
> as a PlayingCard Item with English card name descriptions.