This project is read-only.

Creating a New Game

A quick overview of the steps for creating a new game is given below. For additional information you can look at the implementation of the sample games included in the solution.

Derive your game from a suitable base class

public class Canfield : StandardCardGame
{
}

Use the Game attribute to provide metadata

The metadata is used by the Game Browser.

[Game("9E7BC9AC-63E4-48B4-8B51-BFD35BBE1D30",  LevelOfDifficulty.Easy, 
    LevelOfSkill.MostlyChance, DurationOfPlay.Within5To10Minutes, Family = FamilyName)]
public class Canfield : StandardCardGame
{
}

Specify the components (piles) of the game together with their layout

The game layout approach was designed to be independent of the target presentation technology (WPF, WinForms, etc). However, it is conceptually similar to the WPF 'UIElement' model.

public override ILayoutSite CreatePresentation(IPresentationContext presentation)
{
}

Specify the deal instructions for setting up the game

protected override void PrepareDealScript(DealScript script)
{
    script.DealCardTo(Foundation1);
    script.Deal("12 down,1 up").To(Reserve);
    script.DealCardToEach(NamesOfTableaus);
    script.DealRemainingFaceDownTo(Stock);
}

Override the playing rules

The StandardCardGame class defines a default set of playing rules common to many Solitaire games. You have the option of overriding the default rules through the following override:

protected override void OverridePlayingRules(PlayingRules playingRules)
{
    playingRules.At(AnyReserve)
        .Permit<RemovePileAction>().When(Action.IsActingOnFaceUpTopCard);
}

Alternatively, you can provide your own playing rules through the following method:

protected abstract IPlayingRules CreateRegulations();

Where necessary, override the 'game status' checks

These include checks for: Game Won; Game Over; Percent Complete. By default, a game is considered to be won when all cards have been played to the foundation piles:

protected virtual bool IsComplete
{
    get { return CardsAt(AnyFoundation).Count() == CardsAtStart; }
}

Last edited Mar 11, 2012 at 2:54 AM by badscooter, version 5

Comments

No comments yet.