#include "Behaviors/StateMachine.h"

$nodeclass ParallelProgramming : StateNode {
  $setupmachine{
    launch: StateNode =N=>{power, barklow}
   //lights
    power: LedNode [getMC()->flash(RobotInfo::PowerRedLEDMask, 1.0, 1000)] 
    play: LedNode [getMC()->flash(RobotInfo::PlayLEDMask, 1.0, 1000)] 
    advance: LedNode [getMC()->flash(RobotInfo::AdvanceLEDMask, 1.0, 1000)] 

    power2: LedNode [getMC()->flash(RobotInfo::PowerRedLEDMask, 1.0, 1000)] 
    play2: LedNode [getMC()->flash(RobotInfo::PlayLEDMask, 1.0, 1000)] 
    advance2: LedNode [getMC()->flash(RobotInfo::AdvanceLEDMask, 1.0, 1000)]

    power =C=>play
    play =C=>advance
    advance =C=>power

    power2=C=>advance2
    advance2=C=>play2
    play2=C=>power2

    power=B(RobotInfo::BumpLeftButOffset)=>advance2
    advance2=B(RobotInfo::BumpLeftButOffset)=>power

    play=B(RobotInfo::BumpLeftButOffset)=>power2
    power2=B(RobotInfo::BumpLeftButOffset)=>play

    advance=B(RobotInfo::BumpLeftButOffset)=>play2
    play2=B(RobotInfo::BumpLeftButOffset)=>advance


    //sounds
    barklow: SoundNode("barklow.wav")
    barkmed: SoundNode("barkmed.wav")
    yipper: SoundNode("yipper.wav")

    barklow2: SoundNode("barklow.wav")
    barkmed2: SoundNode("barkmed.wav")
    yipper2: SoundNode("yipper.wav")
    
    barklow =C=> barkmed
    barkmed =C=> yipper
    yipper =C=> barklow


    yipper2 =C=>barkmed2
    barkmed2=C=>barklow2
    barklow2=C=>yipper2

    barklow =B(RobotInfo::BumpLeftButOffset)=>yipper2
    yipper2 =B(RobotInfo::BumpLeftButOffset)=>barklow

    barkmed =B(RobotInfo::BumpLeftButOffset)=>barklow2
    barklow2 =B(RobotInfo::BumpLeftButOffset)=> barkmed

    yipper =B(RobotInfo::BumpLeftButOffset)=>barkmed2
    barkmed2=B(RobotInfo::BumpLeftButOffset)=>yipper
  }
}

REGISTER_BEHAVIOR(ParallelProgramming);
