Skip to content
This repository was archived by the owner on May 2, 2026. It is now read-only.

Latest commit

 

History

History
39 lines (29 loc) · 1.07 KB

File metadata and controls

39 lines (29 loc) · 1.07 KB

Building an Interface for the Deckhandler

The interface is written in SWIG. Although these instructions are for building a python wrapper, SWIG supports building interfaces for many other languages.

To build the wrapper for python, from 'builddir':

meson configure -Dswig_lang=python
ninja

The resulting files will be in 'swig'.

After creating the wrapper, you can run it as so in python (note: make sure you launch your python console in the same directory as you built the wrapper into, or modify your sys.path to point to the wrapper's directory):

import deckhandler

# Set a seed.
deckhandler.seed()

# Create a deck.
deck = deckhandler.get_new_deck()

# Shuffle the deck.
deckhandler.DH_shuffle_deck(deck)

# Print out the whole deck.
for i in range(deckhandler.DH_CARDS_IN_DECK):
    card = deckhandler.deck_dh_get(deck, i)
    print("face: {}, suit: {}".format(deckhandler.DH_get_card_face(card), deckhandler.DH_get_card_suit(card)))