Git Product home page Git Product logo

sheepshead's Introduction

KtCards

KtCards is a game engine written in Kotlin that is focused on card games. The intention is to provide a flexible engine that can support many types of card games. This includes single, and multiple player games.

The goal is to allow the game engine to be easily wrapped multiple different UI layers. This would allow players to play games across many types of devices

Standard Deck Games:

  • Poker: 5 Card Stud, Texas Holdem
  • Solitaire

Non Standard Deck Games:

  • Sheepshead
  • Euchre
  • Hearts

Custom Deck Games similar to:

  • Uno
  • Love Letter
  • Coup

Interface Guide

GameSession

A GameSession is a long lived object where multiple games can occur. If you were to play multiple rounds of a particular game, this would be managed by a GameSession. For example, in Texas Hold'em

When creating a game session, you supply the list of players, the game type, and a map of gameConfigurations. Unknown games, invalid number of players, or invalid gameConfigurations will throw a GameException with a message describing the reason for the exception.

GameSession does not allow for duplicate players to be within the same instance.

  @Test
  fun createGameSession_sheepsheadGame_verifyType() {
    val players = listOf(
        Player("Andy"),
        Player("Brad"),
        Player("Carl"),
        Player("Deryl"),
        Player("Earl"))

    val gameSession = GameSession(
        gameType = "sheepshead",
        gameConfigurations = mapOf(
            "partnerStyle" to "calledAce"
        ),
        players = players
    )

    gameSession.startNewGame()
    
    val currentGame = gameSession.getCurrentGame()

    assertEquals("sheepshead", currentGame?.gameType())

  }

Player

Player is a basic object that is used only to identify the player within the GameSession and Game. Any authentication, and authorization would be handled by the code wrapping the GameSession.

For example, a web based UI may use an object such as AuthenticatedPlayer(id = "12345", name="Andrea") which extends Player. This could be passed directly to GameSession and Game instances.

No game state, or game session state should ever be stored on instances of the Player object. The Game and GameSession should manage all state.

Card

Card provides any game the ability to use a classical card that has a suit, and face value.

Deck

Deck is provided for games that use a classical deck of cards. You can easily customize the cards that are within it, and specify their order. Allowing cards to be in a specific makes it possible to write repeatable test scenarios when developing games. In a real game, you would pass the Deck object a pre-shuffled list.

val deck = StandardDeck()

// deal one card
deck.deal()

// deal multiple cards
deck.deal(5)

StandardDeck

Game

GameEvents

CommandParser

ConsolePlayer

sheepshead's People

Contributors

mcsnolte avatar aglassman avatar

Stargazers

Joshua Pierce avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

jkupcho mcsnolte

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.