🎂 Houdini 150   🚚 FREE FEDEX SHIPPING from 397 USD   🌎 WORLDWIDE SHIPPING for 25 USD

Poker Hands von Jordy Thys

Anleitung

MagiScript hat eine eingebaute Datenbank für mehrere Kartenstapel. Jordy Thys hat diesen Code beigesteuert, der Pokerhände berechnen und die Hände auf einem PeekSmith-Bildschirm anzeigen kann.

Die Routine

Lassen Sie einen Zuschauer den Kartenstapel abschneiden, bis er zufrieden ist, und lassen Sie ihn wählen, wie viele Pokerhände er erhalten möchte, und lassen Sie ihn wählen, welchen Stapel er haben möchte.

Der Zauberer kann alle fünf Karten des Stapels benennen.

Auf Wunsch kann der Zauberer auch die Karten von den anderen Stapeln benennen.

Der Effekt verwendet ein auswendig gelerntes Deck.

In Atom werden vier Ziffern eingegeben:

  • Die ersten beiden Ziffern: der Stapelwert der untersten Karte nach dem Ausschneiden (Blick auf die unterste Karte)
  • Dritte Ziffer: Anzahl der zu verteilenden Blätter
  • Vierte Ziffer: die gewählte Hand

Dieser Effekt basiert auf einer Idee von Craig Raley von der "TAP Users Group".

/*
    Effect:
    Have a spectator cut the deck until they are
    satisfied, let them choose how many poker hands
    they want to deal and let them choose which pile
    they want. 
    The magician can name all five cards from the pile.
    On request, the magician can also name the cards
    from the other piles.

    The effect uses a memorised deck.

    Four digits are entered into Atom:
    First two digits: the stack value of the bottom
    card after cutting (peek the bottom card)
    Third digit: number of hands to deal
    Fourth digit: the chosen hand

    This effect is based on an idea by Craig Raley
    of the "TAP Users Group".

    Hope you like it!
    Jordi Thys
*/

const STACK = 'memorandum';
/*
  'simple': simple deck: clubs, diamonds, hearts, and spades from Ace to King
  'new': a new deck order: AH->KH, AC->KC, KD->AD, KS->AS
  'sistebbins': Si Stebbins stack
  'mnemonica': Mnemonica by Juan Tamariz
  'aronson': Aronson stack by Simon Aronson
  'memorandum': Memorandum by Woody Aragón
*/

function main() {
  ps.connect('*');
  ps.print('Poker');
}

let timeout = 0;
let card = '';
let cardPosInStack = 0;
let bottomCard = -1;
let hands = -1;
let whichHand = -1;
let mapping = [
    '1', '2', '3',
    '4', '5', '6',
    '7', '8', '9',
    '<', '0', '>'
];

function search() {
    if (card === '') return;
    let cardCode = parseInt(card);
    card = ''; // reset the input

    if (cardCode === 0) {
        cardCode = -1;
        return;
    }

    bottomCard = cardCode;
}

function move(direction) {
    if (direction === '<') {
        whichHand--;
        if (whichHand < 0) {
            whichHand = hands - 1;
        }
    }
    if (direction === '>') {
        whichHand++;
        if (whichHand > hands - 1) {
            whichHand = 0;
        }
    }
    display();
}

function onButtonClick(buttonId) {
    let key = mapping[buttonId];

    if (key === '<' || key === '>') {
        move(key);
        return;
    }

    if (bottomCard !== -1) {
        if (hands === -1) {
            hands = parseInt(key);
            ps.print(`<${bottomCard} ${hands}>`);
            return;
        }
        if (whichHand === -1) {
            whichHand = parseInt(key) - 1;
            if (whichHand > hands - 1) {
                whichHand = -1;
                return;
            }
            ps.print(`<${bottomCard} ${hands} ${whichHand + 1}>`);
            display();
            return;
        }
    }

    bottomCard = -1;
    hands = -1;
    whichHand = -1;

    card = card + key;
    ps.print(`<${card}>`);

    clearTimeout(timeout);
    if (strLen(card) === 2) {
        search();
    } else {
        timeout = setTimeout(search, 3000);
    }
}

function display() {
    let cards = [];

    for (let i = 0; i < 5; i++) {
        let index = bottomCard + whichHand + hands * i;
        cards[i] = db.query('card', STACK, index);
    }

    let cardString = `${cards[4].name} ${cards[3].name} ${cards[2].name} ${cards[1].name} ${cards[0].name}`;

    ps.print(cardString);

    card = '';
}

function onEvent(e) {
  if (e.type === 'click' && e.source === 'atom:button') {
    onButtonClick(parseInt(e.value));
  }
}
ankreuzen