Wednesday, June 26, 2013

All About Adroid Multiplayer “TONG-ITS” (Filipino Poker Style) Card Game

Tong-its is a three-player knock rummy card game that has become popular in the northern Philippines in recent years. Both the name and the structure of the game suggest a relationship to the American game Tonk. Tong-its appeared in the late 20th century and seems to be an extended version of Tonk, played with 12 card hands.

The object of the game is, by drawing and discarding, to form a sets or run, and to minimize the count of unmatched cards remaining in your hand. A run consists of three or more consecutive cards of the same suit, such as ♠4 ♠5 ♠6 or ♦7 ♦8 ♦9 ♦10 ♦J. (A-K-Q of a suit is not a run since aces are low in this game). A set consist of three or four cards of the same rank, such as ♥7 ♣7 ♦ 7. A card can belong to only one combination at a time – you cannot use the same card as part of both a set and a run. The game ends if one of the following happens; the deck is empty, one of the players won by tong-its (score is zero) or the player wins the game by draw.

Tong-its Card Game is one of the most popular card games in the Philippines. Using this application, one can play Tong-its with their friends anytime and anywhere using the Android mobile devices. Moreover, multiplayer Java games in computers are also very popular. These Java games can be played whether online or offline. The functionality of existing java games is extended to support multiplayer games using Bluetooth connectivity through mobile. In this case, the new java games are more portable. Tong-its multiplayer card game is one of the android application multiplayer games that could utilize Bluetooth connectivity.

Tong-Its is a card game for three players only, using one standard Anglo-American deck of 52 cards (without jokers). The cards in each suit rank Ace 2 3 4 5 6 7 8 9 10 Jack Queen King. An Ace is worth 1 point, 10, Jacks, Queens and Kings are worth 10 points each, and all other cards count their face value.


<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/startUpLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".Main" >

       <ImageView
                android:id="@+id/imageViewStartup"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/start_up"
                android:scaleType="fitXY" />
        <ProgressBar
                android:id="@+id/progressBar"
                style="?android:attr/progressBarStyleLarge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerInParent="true"
                android:gravity="center" />
</RelativeLayout>

The Start-Up interface as shown image above is written in Extensible Markup Language(XML) in relative layout format with corresponding OnClick functions that need to be clicked to proceed to the next interface which is the main menu interface. The background of the interface is a simple image in Portable Network Graphics(PNG) format. you can email me for the full source code of this simple android Multi-Player Card Game.


Main Menu interface as shown image above is coded in XML along with the different buttons. The background of the interface is an image in PNG format. The OnClick functions of the button are implemented in Java Code.


About Page interface as show image above contains the game icon, game title, and the game developer together with the version of the game. About page interface is coded in XML in relative layout format with a background image in PNG format which contains the information.




Help Page interface as shown image above contains all information about the game, such as how to play the game and the mechanics and rules of the game. Help Page interface consists of ten pages, It is written in Hypertext Markup Language(HTML) format for better display and animation.


Play Menu interface as shown image above shows the menu play's options, i.e. choosing between Single Player or Multi-Player play. Play menu interface consists of buttons coded using XML while the OnClick functions are coded using Java.


Bluetooth Permission Request interface as shown image above automatically pops up when the Bluetooth is in Off State. Bluetooth will have to be turned On in the mobile phone in order to play in MultiPlayer mode.


MultiPlayer Menu interface as shown image above allows the user to choose whether the user would like to host a game by being a server, or join a game created by another user by choosing server or client, respectively. Discoverable allows the user to advertise the Bluetooth device to make the device discoverable to clients who would like to join the game.


When there are no other Bluetooth capable devices in the vicinity, the game can still be played in single player. A Single Player Game as shown image above allows the user to play against the artificial intelligent(AI) players. The AI players are designed to serve as opponents for a Single Player Game.


If the user wants to be a server for a game, the user will have to wait until a client has discovered the device. The user will be prompted with an image which will continue to loop while waiting for a client to connect as shown image above. The user will also be notified once a client has connected or joined the game.



If a user wants to join a game that has been created, the user must scan for available Bluetooth connection to connect to the server as shown image above. When the client successfully connects to the server, the Tong-Its game will start.


When a Bluetooth connection is successful between two phones, the Tong-Its game will start. The server, who hosted the game, is automatically dealt with 13 cards and is obliged to throw a card to the discarded pile of cards to officially start of the game, as shown image above.


At the beginning of the game, the client or the player 2 will be holding 12 cards and waits for the server to throw a card to the discarded pile of cards so that the client can counter. The client side start of the game as shown image above.


Clicking a Card : When a user clicks a card, the chosen card is elevated or put on top over the other cards on hand.

Sorting a Card by Rank : By Clicking this icon or image as shown image above, it enables the user to arrange the cards by Rank from Aces to Kings.

Sorting a Card by Suit : By clicking this icon or image as shown image above, it enables the user to arrange the cards by their respective Suits.

Draw a Card : By clicking a Draw icon or image as shown image above, the card will be added into the Player's hand. After a card is drawn, the icon or image will automatically be disabled by showing a red X mark on it as only one card may be drawn.

Drop and Chow : Selecting a card from the hand and clicking on the discarded pile will drop the card. Clicking the discarded card pile without selecting a card from the hand is a Chow. When a user chows, the card will be reflected automatically to the meld area or the combination area wherein you have to throw valid cards to achieve a meld to proceed. If the card was drawn by mistake, the user may cancel the draw. When a user tries to throw a card that does not have a valid meld or combination, all the cards returns to the user hand. The different operations are shown image above.

Call Draw or "LABAN" is challenging the user's opponent to accept the challenge. In this challenge, whoever has the lower score will win the game. The score is the SUM of all the values of the cards in the user's hand. When the user challenge their opponent, if the opponent did not throw at least one meld, then the opponent will automatically lose the game. This is called "BURNED" or "SUNOG" as shown image bellow.


When a winner has been determined, either by Tong-Its or by default, the player are notified and the game ends as shown image bellow.


When a User or Player Lose the Game, the Player are notified and the game ends as shown image bellow.



Good morning guys, by the way I'm currently using Aptana Studio 3 IDE for Android and Mobile Web Application. you can also develop Ruby Projects and Rails Project etc. using Aptana Studio 3. Here is the link so that you can download and install Aptana Studio 3. Enjoy coding, have a good Day...



Hi Guy's, I have something updates for this project and the IDE that I currently using right now. I choose to used Android Studio for this kind of stuff mobile development specially on Android Application. By the way, its better to develop an application in Linux environment guys based on my experience as a developer. here's the link on how to install Android Studio via PPA on Ubuntu or Linux Mint. Enjoy Coding Guy's, have a good day.