Skip to main content
Toby Culverwell's Blog

Designs on a new project.

Designs on a new project

For the first project to display my java programming skills, I decided to build a program that allows 2 players to play a card game of my own design. A more detailed explanation can be found in a docx file on a GitHub repository where this is found (Link Here), but I have placed key excerpts and examples from that here below.

Card Game Overview

The card game is framed as 2 castles (the players) going into battle against each other using their armies (their decks). The win condition is to lay siege to the other castle (reduce their Defence Points to 0) and to do this direct attack with creatures must be made. A direct attack can only be made when your opponent has no creatures on their front line. The card game will be called Castles of Cards.

Card Types

There are 2 categories of Cards: Creature Cards and Support Cards. Each category will be split up into 2 types, so there are 4 types of card. The card types are: Magic Creature, Melee Creature, Magic Support and Item Support. Some Creature cards will also be either ‘Ace’ or ‘Legend’ cards and these cards will be more powerful than most other creature cards, but with the caveat that you can only have 2 Ace Creatures and 1 Legend Creature in your Deck. Creatures will have 2 stats: Health and Attack, with Health relates how much damage a creature can take, while Attack relates how much damage it can inflict.

Card Game Implementation

Player Class

Players of the card game will implemented as their own object class with the same name and will have 6 attributes: Name, Defence Points, Wasteland, Front Line, Hand and Deck. The data types for the attributes are: Name will be a String, Defence Points will be an Integer, Wasteland, Hand and Deck will be ArrayLists that stores the Card object and Front Line will be a 4 element Array that stores the Card object.
The Behaviours (methods) that a Player object has are: Drawing from the Deck and Playing Cards from the Hand.

Card Classes

There will be a parent class of Card in which the 4 card types will inherit from as child classes.
The Card class will have the attributes Name and Card Type, with both being Strings. The Support Card class will have, in addition to the inherited attributes, Effect Description attribute which will be a String. The Creature Card class will have, in addition to inherited attributes, a Health attribute, a Attack attribute and a Skill attribute (the ‘Ace’ or ‘Legend’ aspect of a Creature). The first 2 attributes will be integers, while the Skill attribute will be a String.
The Support Card class will have the behaviour Effect while the Creature Card will have the behaviour Attack.

Runner

The Runner will be the java file that is used to run the program that allows the card game to be played. There will be 5 methods in the file with one of them to begin the game, while the rest relating to the 4 stages of a turn (Draw, Plan, Battle, End).

Flowcharts and Diagrams

The following images are a flowchart for the player class method Playing Cards from Hand and 2 Class diagrams which show the relationship between the Player and Card classes as well as the relationship between the Runner, the Creature Card and the Player classes.

Flowchart

Flowchart detailing the playing card from hand method of the Player class

Diagrams

Diagrams showing the relationship between the Player and Card classes as well as the relationship between the Runner, the Creature Card and the Player classes.