Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.11 KB

SWIG_INTERFACE.md

File metadata and controls

42 lines (31 loc) · 1.11 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.st_deck_dh()

# Initialise the deck.
deckhandler.deck_init_dh(deck)

# Shuffle the deck.
deckhandler.deck_shuffle_dh(deck)

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