Git Product home page Git Product logo

ttsdeck's Introduction

ttsdeck

PHP helper class for generating custom decks for card games in Tabletop Simulator. Has been tested with the Legend of the Five Rings (L5R) Living Card Game. May or may not work with other card games.

Example usage:

require_once "ttsdeck/ttsdeck.php";

$deck = new TtsDeck();

// Game JSON resides in the mods directory of TTS
// (/path/to/Tabletop Simulator/Mods/Workshop)
$game_json = json_decode(file_get_contents("./game.json"));
$deck->import_cards($game_json);

// Create face-up pile of cards (optional)
$deck->add_pile(true, "SomeCards");

// Add cards by name (partial match)
// Returns an array of matched card names
// Success if count($result) === 1
$deck->add_card("Champion of the Gods");
$deck->add_card("Purgatory");

// Create another pile, face-down
$deck->add_pile(false, "OtherCards");

// Add a card to the new pile (exact match)
$deck->add_card("Walking Dead", null, false);

// Add a card to the new pile with custom normalization function
$deck->add_card("IDontCAREabout spaces  and case", "normalize_card_name");

// Encode the deck as TTS-importable JSON
$serialized = json_encode($deck->get_deck(),
  JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

// Loop through all available cards
foreach ($deck->get_card_sets() as $set => $cards) {
  printf("Set %s:\n", $set);
  foreach ($cards as $card) {
    printf("- Card %s\n", $card);
  }
}

function normalize_card_name($name) {
  return str_replace(" ", "", strtolower($name));
}

ttsdeck's People

Contributors

dengeki avatar

Stargazers

 avatar

Watchers

 avatar

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.