=========
py-slippi
=========

Py-slippi is a Python parser for `.slp <https://github.com/JLaferri/project-slippi/wiki/Replay-File-Spec>`_ game replay files for `Super Smash Brothers Melee <https://en.wikipedia.org/wiki/Super_Smash_Bros._Melee>`_ for the Nintendo GameCube. These replays are generated by Jas Laferriere's `Slippi <https://github.com/JLaferri/project-slippi>`_ recording code, which runs on a GameCube or the `Dolphin <https://dolphin-emu.org/>`_ emulator.

Usage
=====

**Reading from a replay file**::

    >>> from slippi import Game
    >>> game = Game('path/to/game.slp')
    >>> game.metadata
    <Game.Metadata: date: 2018-06-22 07:52:59+00:00, duration: 5086, platform: Platform.DOLPHIN, players: (<Game.Metadata.Player: characters: {<InGameCharacter.MARTH: 18>: 5086}>, <Game.Metadata.Player: characters: {<InGameCharacter.FOX: 1>: 5086}>, None, None)>
    >>> game.start
    <Start: is_teams: False, players: (<Start.Player: character: CSSCharacter.MARTH, costume: 3, stocks: 4, team: None, type: Type.HUMAN, ucf: <Start.Player.UCF: dash_back: False, shield_drop: False>>, <Start.Player: character: CSSCharacter.FOX, costume: 0, stocks: 4, team: None, type: Type.CPU, ucf: <Start.Player.UCF: dash_back: False, shield_drop: False>>, None, None), random_seed: 3803194226, slippi: <Start.Slippi: version: 1.0.0.0>, stage: Stage.YOSHIS_STORY>
    >>> game.end
    <End: method: Method.CONCLUSIVE>
    >>> game.frames[0]
    <Frame: ports: (<Frame.Port: follower: None, leader: <Frame.Port.Data: post: <Frame.Port.Data.Post: character: InGameCharacter.MARTH, combo_count: 0, damage: 0.0, direction: Direction.RIGHT, last_attack_landed: None, last_hit_by: None, position: <slippi.event.Position object at 0x7f6f41f47710>, shield: 59.6619873046875, state: ActionState.LANDING, state_age: 7.0, stocks: 4>, pre: <Frame.Port.Data.Pre: buttons: <Buttons: logical: Logical.NONE, physical: Physical.NONE>, cstick: <slippi.event.Position object at 0x7f6f41f47320>, direction: Direction.RIGHT, joystick: <slippi.event.Position object at 0x7f6f41f47470>, position: <slippi.event.Position object at 0x7f6f41f474e0>, random_seed: 1373931959, state: ActionState.LANDING, triggers: <Triggers: logical: 0.0, physical: <Triggers.Physical: l: 0.0, r: 0>>>>>, <Frame.Port: follower: None, leader: <Frame.Port.Data: post: <Frame.Port.Data.Post: character: InGameCharacter.FOX, combo_count: 0, damage: 0.0, direction: Direction.LEFT, last_attack_landed: None, last_hit_by: None, position: <slippi.event.Position object at 0x7f6f41f47780>, shield: 60.0, state: ActionState.JUMP_F, state_age: 19.0, stocks: 4>, pre: <Frame.Port.Data.Pre: buttons: <Buttons: logical: Logical.NONE, physical: Physical.NONE>, cstick: <slippi.event.Position object at 0x7f6f41f473c8>, direction: Direction.LEFT, joystick: <slippi.event.Position object at 0x7f6f41f47358>, position: <slippi.event.Position object at 0x7f6f41f47550>, random_seed: 1373931959, state: ActionState.JUMP_F, triggers: <Triggers: logical: 0.0, physical: <Triggers.Physical: l: 0.0, r: 0>>>>>, None, None)>

**Iterating over frame data**::

    for frame_index, frame in enumerate(game.frames):
        data = frame.ports[0].leader # see also: port.follower (ICs)
        print(data.post.state) # character's post-frame action state

API Docs
========

See the `Module Index <https://py-slippi.readthedocs.io/en/latest/py-modindex.html>`_ for detailed API docs, starting with `slippi.game <https://py-slippi.readthedocs.io/en/latest/source/slippi.html#module-slippi.game>`_.
