flipkarma.com€¦ · Web viewThis game is a Game developed under OOP environment using platform...

37
PART-I Project Overview 1

Transcript of flipkarma.com€¦ · Web viewThis game is a Game developed under OOP environment using platform...

PART-I

Project Overview

1

1. Introduction

World today has evolved into a more comfortable choice zones and the people have

developed a desire to demand for a more appealing features in every sectors. Anything

today has to have a specialty and compatibility in order to survive. Same goes for the

cultures and heritages. Cultures include the way of entertainments involving the games

our ancestors played. But as the computers are taking over a playing field, the games

must evolve to a computer compatible level too.

Many card games have been invented in the computers to provide a user or multiple users

to enjoy the gaming experiences which mostly exclude the card games of our own

Nepalese origins. Thus trying to save the cultural entertainment of card games, we build a

computer version of the popular card game “Call-Break” played throughout our nation.

Our project Call-Break is a multiplayer LAN game, through socket Server-Client

Networking. This game is a Game developed under OOP environment using platform

independent Programming language C#. The multiplayer feature of this game has made

the game more challenging and interesting to play. The strong support for networked

application in C# programming language and availability of high speed network

connection layer in present day computers has allowed us to build a very efficient

multiplayer version of card game.

Call Break is a card game played in Nepal from past decade of years. Making this game

in computer version became an exciting and challenging project. However this project

has leaded us to provide learning environment and platform for a first step on developing

software.

2

2. Objective2.1 Course Objective

The course objective of our project is to develop game “Call Break” card game under

OOP platform using C sharp programming tool with the functionality of multiplayer

under LAN (Local Area Network).

2.2 Specific Objective

The specific objective of our project Call Break card game is listed below:-

1. To develop culturally profound “Call-Break” card game for PCs.

2. To develop a server-client based game using LAN thus introducing

multiplayer functionality.

3. To provide a fine Graphical User Interface for attractive and user friendly

look.

4. To provide complete entertainment through the game environment.

5. To provide a common chatting interface between the players.

2.3 Optional Future Enhancement Objectives

1. To develop this into a server based web game.

2. To develop the GUI of the game by using attractive 3D Animations.

3. To provide a common chatting interface between the players.

3

3. Scope

Following are the scopes of our software

The game can be played in any Windows platform having .NET framework.

Mouse and keyboard (in special cases) is needed for playing this game.

A functional LAN connection is mandatory and sufficient so any other device is not

required to play this game.

The game can be played between four players.

Online gaming is a booming business in western countries. If we can develop this game

to deliver a thrilling experience to gamers, we can enter into the world of online gaming.

4. Project Feature

Our project “Call – Break” card game has following features:-

Multiplayer facility

Chatting interface

Client Server communication through LAN (Local Area Network)

Graphical User Interface (GUI)

4

5. Feasibility Study

This is one of the important portions within the project. The feasibility analysis of various

factors is must. A general account on feasibility study in this project is as follows:-

5.1 Operational Feasibility

Our project Call Break card game is feasible in terms of computer gaming. It is very

much user friendly. There were various errors during programming implementation. To

make the software more feasible an attractive way of graphical user interface was

implemented into it and means of animation was also implemented which made the

project to be more operationally feasible.

5.2 Economic Feasibility

Based on LOC (Lines of Code), SRS (Software Requirement Specification) and Time for

completion of this project this project can be considered being economically feasible.

Also considering the Space Complexity and Time Complexity our project seems to be

economically feasible.

5.3 Technical Feasibility

Production of this software using the platform of C sharp under the 4.5 framework

environment has made this project easier to build. The use of Windows Application form

and Windows Presentation Foundation for the development of this software made quiet

easier and more feasible.

5

6. System Requirement

System Requirement can be broadly classified under two categories:-

6.1 Software Requirement

Following are the Software that is required for the development of this software:-

Windows Platform

.NET framework 4.5

6.2 Hardware Requirement

Following are the Hardware that is required for the development of this software:-

Computer System with 512 RAM

Core 2 duo processor

6

PART – II

Literature Review

7

7. Literature Review

Our project ‘Call-Break Card Game on LAN’ allowed us to focus on more advanced topic like

multiplayer functionality. We took lots of help through internet concept from existing card

game like solitaire, hearts, marriage etc. helped us a lot during our preparation of project. For

completing this project we studied and worked hard on following topics:

1. .NET Framework

The .NET Framework (pronounced dot net) is a software framework developed

by Microsoft that runs primarily on Microsoft Windows. It includes a large library and

provides language interoperability (each language can use code written in other languages)

across several programming languages. Programs written for the .NET Framework

execute in a software environment (as contrasted to hardware environment), known as

the Common Language Runtime (CLR), an application virtual machine that provides

services such as security, memory management, and exception handling. The class library

and the CLR together constitute the .NET Framework.

The .NET Framework's Base Class Library provides user interface, data access, database

connectivity, cryptography, web application development, numeric algorithms,

and network communications. Programmers produce software by combining their

own source code with the .NET Framework and other libraries. The .NET Framework is

intended to be used by most new applications created for the Windows platform.

Microsoft also produces an integrated development environment largely for .NET

software called Visual Studio.

2. Microsoft Visual Studio

Microsoft Visual Studio is an Integrated Development Environment (IDE)

from Microsoft. It is used to develop console and graphical user

interface applications along with Windows Forms or WPF applications, web sites, web

applications, and web services in both native code together with managed code for all

8

platforms supported by Microsoft Windows, Windows Mobile, Windows CE, .NET

Framework, .NET Compact Framework and Microsoft Silverlight.

Visual Studio includes a code editor supporting IntelliSense as well as code refactoring.

The integrated debugger works both as a source-level debugger and a machine-level

debugger. Other built-in tools include a forms designer for building GUI applications, web

designer, class designer, and database schema designer. It accepts plug-ins that enhance

the functionality at almost every level—including adding support for source-

control systems (like Subversion and Visual SourceSafe) and adding new toolsets like

editors and visual designers for domain-specific languages or toolsets for other aspects of

the software development lifecycle (like the Team Foundation Server client: Team

Explorer).

Visual Studio supports different programming languages by means of language services,

which allow the code editor and debugger to support (to varying degrees) nearly any

programming language, provided a language-specific service exists. Built-in languages

include C/C++ (via Visual C++), VB.NET (via Visual Basic .NET), C# (via Visual C#),

and F# (as of Visual Studio 2010). Support for other languages such as M, Python,

and Ruby among others is available via language services installed separately. It also

supports XML/XSLT, HTML/XHTML, JavaScript and CSS. Individual language-specific

versions of Visual Studio also exist which provide more limited language services to the

user: Microsoft Visual Basic, Visual J#, Visual C#, and Visual C++.

Microsoft provides "Express" editions of its Visual Studio 2010 components Visual Basic,

Visual C#, Visual C++, and Visual Web Developer at no cost. Visual Studio 2012, 2010,

2008 and 2005 Professional Editions, along with language-specific versions (Visual Basic,

C++, C#, J#) of Visual Studio Express 2010 are available for free to students as

downloads via Microsoft's  DreamSpark  program.

3. LAN Connection

We observed about two types of protocol i.e. TCP (Transfer Control Protocol) and UDP

(User Datagram Protocol). Main difference between these two protocols is TCP

connection should acknowledge the client for receiving data that is transferred from client

and UDP is connection less server. TCP connection guarantees that data will reach up-to

the client at the receiving end, if it will not reached in right order then it will resend from

9

the server and vice versa. Due to this advantage we chose the TCP connection for starting

and connecting the server.

4. Multi-Threaded Program Execution

To handle the multiple services and multiple connection of client we worked on the multi-

threading concept of programming that enables us the programming concept on multi-

tasking and help us to do multiple works concurrently (but not on real).

Call Break is a card game played in Nepal from past decade of years. Before making this

game we hadn’t found the Call-Break game on computer with LAN connection and internet

too. We were motivated to do this project by seeing the similar concept of online Marriage

Game playing in bhoosh.com, where more than equal to two players and less than equal to

five players can start the marriage game. Similarly in our Call-Break game is started under

LAN connection with four players.

10

8. Problem Statement

The traditional Call-Break card game has not evolved to a computer game till now. As this is

a computer based era, all kinds of games are being presented to be played in the computer

rather than the traditional way (with physical cards). The new generation players grow less

interested while playing in the traditional manner. Hence when people hear about Call-Break

card game, they quickly form an

Image of old age sit around and hold your cards game. The absence of powerful graphical

resources and weak support for networked application in the programming language is one of

the factors that have delayed the development of an interesting and challenging version of

this card game. So we build Call Break card game.

9. An Overview of Call Break Card game

1. Call-Break Card game is a single deck card game played by not more than and not less than four players. Players in an anti-clockwise game manner take turns as dealer till 5 deals.

2. The person next to the dealer (in anti-clockwise order) starts making call on hands he can take.

3. After the deal if any of the following conditions are met then the cards are dealt again by the next person (in anti-clockwise order). If any one person has all the four aces OR If any one person has none of the trump card (a suite of card (most of the time Spades) which has higher priority to all other suites. For a 2 of Spades has higher priority than an Ace of Clubs, Diamonds or Hearts) OR If any one person has cards such that he doesn't have at least one of the four (Aces, Kings and Queens).

4. Calls are noted.

5. Order or priority of cards are natural i.e. 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace in ascending order.

11

6. A player has to play the card of the suite for which the hand was started, if he has cards of that suite otherwise he has to play trump card if he has trump cards.

7. A player has to compulsorily play a higher value/priority card than the cards already played in the hand, provided he has one. If the player doesn’t have a higher value card then he can play any card keeping in mind rule 7.

8. After one set of 13 hands is finished this is how scores are assigned:

If the player has secured exactly the number of hands he had claimed at the start of the set। He is given points 10 times that of call he had made. E.g. if the call was of 4 hands and 4 hands were secured. Then the points given would be 40.

If the player couldn’t secure the number of hands he had claimed he would. He is given negative points 10 times that of call he had made. E.g. if the call was of 4 hands and less than 4 hands were secured. Then the points given would be - 40.

If the player has secured more hands than he had claimed. He is given bonus points which are computed as follows. If the player had called X hands and secured (X + 2) hands. Then the points given would be (10X + 2). E.g. if the call was of 4 and 6 hands were secured. Then the points given would be 42.

9. After 5 sets, the respective scores are calculated and the one with the highest point is declared the winner.

12

PART – III

System Development

13

10. Project Management

Visual Studio 2012 was the development tool that was extensively used by all the team

members. Several “Developer Collaboration” features of the IDE was utilized to

communicate and to collaborate codes between the members. Different Visual Studio

supporting form such as Windows Presentation Foundation, Windows Application Form was

used. Canvas was used for the animation purpose.

Each team member was assigned with several tasks of the project on the basis of their interest

in particular portion of the game. Like one member was assigned with the portion of Server

Client Socket Connection other with graphics involved and the other with the game playing

logic. Weekly meeting was held to assess the status of each member and to facilitate

restructuring of plans when required. Every day group discussion was carried out on social

chat.

14

11. Work Scheduling

The project we have developed is overall package of Call Break card game. Working with a

perfect unity with our group member we have successfully been able to develop this game

within limited time. With the proper cooperation between our fellow members we ultimately

reached our goal of developing this game. However, following are the task that has been

completed

Layout of our screen.

Portion of graphics which includes displaying the Card.

Portion of animation that involves moving the Card from one place to another.

Portion of LAN communication where the server starts and the client are

connected in local area network in accordance to server proxy and port.

Portion where the server handles multiple clients asynchronously.

Client synchronization.

Portion of game logic which deals with how to play the game.

In more details it is shown in Gantt-Chart in Project Plan chapter.

15

12. System Analysis

Under this category we have basically included four class diagrams they are:-

12.1 Class Diagram

A class diagram in the Unified Modeling Language (UML) is a type of static structure

diagram that describes the structure of a system by showing the system's classes, their

attributes, operations (or methods), and the relationships among the classes. Below is the

class diagram of our project.

16

Fig (12.1): Class Diagram of Multiplayer Call Break card game

12.2 Sequence Diagram

A sequence diagram is a kind of interaction diagram that shows how processes operate with

one another and in what order. It shows object interactions arranged in time sequence. It

depicts the objects and classes involved in the scenario and the sequence of messages

exchanged between the objects needed to carry out the functionality of the scenario.

Following is the Sequence Diagram of Call Break Card Game on LAN.

17

Fig (12.2): Sequence Diagram of Call Break Card Game

12.3 Use case Diagram

Use case diagram is an excellent picture of the system context; it makes a good context

diagram that is, showing the boundary of a system, what lies outside of it, and how it gets

used. It serves as a communication tool that summarizes the behavior of a system and its

actors. A sample of use case diagram of Call Break Card Game on LAN is shown

below:-

18

Fig (12.3): Use Case Diagram of Call Break Card Game

13. Project Planed

13.1 Gantt Chart

19

Table (14.1): Gantt chart In Weekly Basis

As above as shown in grant chart with the proper cooperation with the group

members we finally succeeded the completion of our software within limited time.

The scheduling of software progress is as shown above in grant chart.

14. Output

20

Fig (15.1):Started Server

Fig (15.2): Game Output

The final version of the proposed involves following features:

21

1. A game that retains the simplicity of traditional card game and contain attractive graphics

and user interface to attract the players.

2. The real time experience of commercial multiplayer games that allows four players to

play a game simultaneously over a network.

3. Chat facility so that there is communication between the players as a part of

entertainment.

22

PART – IV

Epilogue

15. Problem Encountered

23

There were many problems that were encountered during the preparation of our project. Some of

the problems are listed below:

Assigning the random Cards:

We made an algorithm for assigning random card for each user in between the 52 cards.

Firstly we assigned the different values for each of the cards (from 0 to 51 (52 numbers in

total)). The algorithm that we applied is:

1. Initialize an array of 52 integer value.

2. Fill the array value with its respective array index number.

3. Generate a random number in between 1 to 51.

4. Swap the first array value with the random number generated index value.

5. Proceed on for second array value, third array value, and so on... step until we reach on

index 25.

6. Assign first 13 values for first player, next for second player and so on...

Cropping & Locating Cards:

We have a deck of card where we have 53 cards (52 cards and one closed card). As the

program needs, we will display the card by cropping it with height 100 pixels and width 80

pixels and will display on monitor via calculating its height and width in pixel.

Checking the Violation of Rule:

We faced the problem on detecting the thrown card and checks it with the rule mentioned in

above. If rule will violate the card will not be thrown, else it will throw. For checking the

rule, we made an algorithm as the rule mentioned in different class. Whose implementation

as:

1. Initialize and store the value of card thrown via player in current round.

2. You throw a card.

a. If you are the first player your card is valid.

b. Else check your current card is of greater value or not?

24

i. If your card is greater your card is valid.

ii. Else check that you have greater card or not?

1. If you have greater card then the card is not valid.

2. Else check for you have colored card or not?

a. If you haven’t colored card then the card is valid.

b. Else your card is not valid.

Animating the Card Movement:

After locating cards on different portion of screen as the different four players assigned while

the player throws the card, it checks for the violation of rule, if the player can throw that card

then program will find the correct location of that card and will throw on about the center

part of screen by moving the card in pixel-wise movement. And after scoring a point the four

thrown card should move towards the position of scoring player. For this we have to detect

the card position and move towards the scoring player position.

Client-Server connection using the socket:

We used the TCP (Transfer Control Protocol) for Client-Server communication. For doing

the communication the server is always on listing mode to receive the message from client

and also the client to receive message from server. .NET Framework has the package

System.Net and System.Net.Socket for making the communication between Client and

Server.

Synchronization problem:

We defined some critical region of data for recording the score and name temporarily, that is

shared to all client where one client modify only the data of its respective data but not the

others client content. And while one player updating its own content the other client

shouldn’t able to read the critical section data. This is managed in our program via Locking

the critical section content while one client in updating the critical region data and Unlocked

when its update be completed.

25

Data Mining:

Our program works via communicating the client with the server and vice-versa. We pass the

some command or control signal by putting the ‘/’ & ‘!’ character before the message. ‘/’ &

‘!’ character is protected symbol, which can’t use by client in chatting with other players.

When client gets the message with first character ‘!’ or ‘/’ the client check the what the

message is passed to the client and client searches its meaning and determining the meaning

it will be forwarded and vice-versa. For example: when client pass the message “!name

Binod” server extract the “!name” as the name to be changed into “Binod” then server

changes the name and passes the message to all of the clients and all the client know the

player as Binod. In this way different data should extract via Server and Client to established

the communication successfully.

Inter Process Communication (IPC):

Completing the whole game we have made lots of threads for doing different jobs over the

program for example: the client and server thread run via same program with different

control, receiving message from server, receiving message from client, doing the UI-Element

update, game control etc. Example of IPC between the receive message control thread and

UI-Element thread is: when receive message control thread receives some control message

for updating the UI-Element, it should pass message to UI-Element update thread for

updating UI-Element. Doing the communication between them, the direct communication

will not be supported due to the UI-Element thread will be running its own portion of job,

due to this reason we have to pass message via invoking event from that receive message

thread to UI-Element Update thread as:

this.Dispatcher.Invoke((Action)(()=>

{

//some procedure to be performed

}));

26

16. Limitation and Future Enhancement

Although the software has been fully developed but there are some limitation

16.1 Limitation

Following are the limitation of our project

Game doesn’t start until and unless there are four players.

Doesn’t run if any member leaves the room.

16.2 Future Enhancement

Following are the thing that can be done in our upcoming future

Can be made Online

More number of rooms so that more than a group(4 people) can play at a time.

27

17. Conclusion

As we had discussed in our proposal regarding the building of Call Break card game on

Local Area Network, we have so far successfully managed to build this game within the

limited time as proposed where our main concept was playing game on LAN via Client-

Server Socket. Client send and receives the data and the server controls the overall

operation and in this way by passing the information from one computer to another we

have put the logic of playing the game of Call-Break in LAN for Multiplayer.

From this project we are able to do the project under multiple threads for handling the

multiple jobs at a time. Not only that, we gain the knowledge about the Deadlock, Inter

Process Communication, Process Synchronization, Data Mining, Client-Server

Connection and Communication and so on...

28

18. References

Andrew, T.: “Pro C# 2010 and the .NET 4 Platform”, Second Edition, New Delhi, 2010.

Adam N.: “Windows Presentation Foundation Unleashed”, Second Edition, New York,

2012.

Christian N., Simon R., Jay G., Morgan S., Karli W. & Bill E.: “Professional C#”, Third

Edition, Wiley Publishing Inc. USA, 2003.

http://www.bhoos.com/Cards-Game-Marriage.aspx/ (Accessed 2013-02-04)

http://www.youtube.com/watch?v=PCwS7F2uK3Q/ (Accessed 2013-03-12)

29