Skip to content

Instantly share code, notes, and snippets.

@brine
Last active September 15, 2015 19:46
Show Gist options
  • Save brine/cd5d674a06c98ead1404 to your computer and use it in GitHub Desktop.
Save brine/cd5d674a06c98ead1404 to your computer and use it in GitHub Desktop.
Python 3.1.0.2 API changes

GAME EVENTS:

All event names have been changed to follow a past tense subject-verb naming convention. In addition, all events now simply pass an args argument as its only argument, which act as an object type. So instead of having many different arguments for the OnCardsMoved event, you will now do something like this:

def MoveCardsEvent(args):
    card = args.card
    x, y = args.xs, args.ys

Here is the list of all the events, and the values you can get from them (view the most up-to-date list here: https://github.com/octgn/OCTGN/blob/master/octgnFX/Octgn.Library/Scripting/GameEvents.xml#L241) :

  <eventversion version="3.1.0.2">
    <!-- Happens when the table first loads, and never again -->
    <event name="OnTableLoaded"/>
    <!-- Happens after OnTableLoaded and after each game reset -->
    <event name="OnGameStarted"/>
    <event name="OnPlayerConnected">
      <param name="player" type="Player"/>
    </event>
    <event name="OnPlayerQuit">
      <param name="player" type="Player"/>
    </event>
    <event name="OnDeckLoaded">
      <param name="player" type="Player"/>
      <!-- Groups cards are loaded into -->
      <param name="groups" type="Group[]"/>
    </event>
    <event name="OnCounterChanged">
      <param name="player" type="Player"/>
      <param name="counter" type="Counter"/>
      <param name="value" type="int"/>
      <param name="scripted" type="bool"/>
    </event>
    <event name="OnTurnPaused">
      <!-- Player who toggled the Pause Turn button -->
      <param name="player" type="Player"/>
    </event>
    <event name="OnTurnPassed">
      <!-- Triggers when the turn is passed to another player -->
      <param name="player" type="Player"/>
    </event>
    <event name="OnCardTargeted">
      <param name="player" type="Player"/>
      <param name="card" type="Card"/>
      <!-- If false, we untargeted, else we targeted -->
      <param name="targeted" type="bool"/>
      <param name="scripted" type="bool"/>
    </event>
    <event name="OnCardArrowTargeted">
      <param name="player" type="Player"/>
      <param name="fromCard" type="Card"/>
      <param name="toCard" type="Card"/>
      <!-- If false, we untargeted, else we targeted -->
      <param name="targeted" type="bool"/>
      <param name="scripted" type="bool"/>
    </event>
    <event name="OnPlayerGlobalVariableChanged">
      <param name="player" type="Player"/>
      <param name="name" type="string"/>
      <param name="oldValue" type="string"/>
      <param name="value" type="string"/>
    </event>
    <event name="OnGlobalVariableChanged">
      <param name="name" type="string"/>
      <param name="oldValue" type="string"/>
      <param name="value" type="string"/>
    </event>
    <event name="OnCardClicked">
      <param name="card" type="Card"/>
      <param name="mouseButton" type="int"/>
      <param name="keysDown" type="string[]"/>
    </event>
    <event name="OnCardDoubleClicked">
      <param name="card" type="Card"/>
      <param name="mouseButton" type="int"/>
      <param name="keysDown" type="string[]"/>
    </event>
    <event name="OnMarkerChanged">
      <param name="card" type="Card"/>
      <param name="marker" type="string"/>
      <param name="id" type="string"/>
      <param name="value" type="int"/>
      <param name="scripted" type="bool"/>
    </event>
    <event name="OnCardsMoved">
      <param name="player" type="Player"/>
      <param name="cards" type="Card[]"/>
      <param name="fromGroups" type="Group[]"/>
      <param name="toGroups" type="Group[]"/>
      <!-- index within the group -->
      <param name="indexs" type="int[]"/>
      <param name="xs" type="int[]"/>
      <param name="ys" type="int[]"/>
      <param name="highlights" type ="string[]"/>
      <param name="markers" type ="string[]"/>
      <param name="faceups" type="bool[]"/>
    </event>
    <event name="OnScriptedCardsMoved">
      <param name="player" type="Player"/>
      <param name="cards" type="Card[]"/>
      <param name="fromGroups" type="Group[]"/>
      <param name="toGroups" type="Group[]"/>
      <!-- index within the group -->
      <param name="indexs" type="int[]"/>
      <param name="xs" type="int[]"/>
      <param name="ys" type="int[]"/>
      <param name="highlights" type ="string[]"/>
      <param name="markers" type ="string[]"/>
      <param name="faceups" type="bool[]"/>
    </event>
  </eventversion>
###PYTHON CHANGES
askCard() - Removed split-functionality when a list is passed instead of a dictionary, now behaves old-school (see cardDlg)
isTableBackgroundFlipped() - RENAMED, moved to Table class (see table.invertBackground)
setTableBackgroundFlipped() - RENAMED, moved to Table class (see table.invertBackground)
group.setController() - RENAMED (see card.controller)
card.switchTo() - RENAMED (see card.alternate)
card.setController() - RENAMED (see card.controller)
card.height() - RENAMED (see card.height)
card.width() - RENAMED (see card.width)
card.size() - RENAMED (see card.size)
card.setIndex() - RENAMED (see card.index)
card.getIndex() - RENAMED(see card.index)
player.isActivePlayer - RENAMED (see player.isActive)
player.setActivePlayer() - RENAMED (see player.setActive() )
player.hasInvertedTable() - RENAMED (see player.isInverted)
table.offset() - Moved to Card class (see card.offset() )
table.isInverted() - Moved to Card class (see card.isInverted() )
table.setBoardImage() - MODIFIED FUNCTIONALITY (see table.board)
###NEW PYTHON API
cardDlg() - (SEE WIKI) A class object, retains the functionality of askCard when a list of cards is passed; adds a min and max argument to allow multi-card selections, will only allow a confirm if the number of selections falls within the range; now returns a list of card objects instead of a singular one
form.showWinForm() -- properly integrates a custom winform into OCTGN's threads
card.set - returns the name of the set that the card belongs to
card.setId returns the GUID of the set
card.alternate - Now a property get/set, setter takes card.switchTo() functionality
card.controller - Now a property get/set, setter takes card.setController() functionality
card.height - Now a property
card.width - Now a property
card.size - Now a property
card.index - a property get/set, combines card.getIndex and card.setIndex()
card.offset() - Will now default to the card's x and y position if no parameters are passed
card.isInverted() - Will now default to the card's y position if no parameter is passed
card.filter - property, get/sets a colored transparency overlay to the card, tinting its image
card.resetProperties() - Resets any alterations made to the card's custom properties
player.isActive - a property
player.setActive() - sets the active player
player.isSubscriber - A Boolean property, returns True if the player is a subscriber
player.isInverted - Now a Boolean property
table.invertBackground - Now a property get/set
table.board - property, get/set the current game board (default one is "Default"), see wiki for info on defining multiple game boards
table.boards - returns a list of all available game boards
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment