system "Fibonacci_Progression"

{Fibonacci Progression 0,1,1,2,3,5,8,13,21,55, etc.
 where each number is a sum of the previous two numbers
 For each loss, step up one in the progression
 Basic idea is to get two Wins in a row
 For each win, make the same bet again
 If win again, start the progression over.  If lose, advance one step
 A flag # 1 is used to hold bets at the current level.
}
method "main"
begin
    While Starting a New Session
    begin
        Clear All Records;
        Clear Record "1st previous bet" data;
        Clear Record "2nd previous bet" data;
        Clear Record "# of times complete progression is lost" data;
        Clear Record "Size of each betting unit" data;
        Clear Record "# of steps in the progression" data;
        Clear Record "Current step #" data;
        Clear Record "Current Layout to Bet" data;
        Put 0  on Record "1st previous bet" data;
        Put 0  on Record "2nd previous bet" data;
        Put 0  on Record "# of times complete progression is lost" data;
        Put 1  on Record "Size of each betting unit" data;
        Put 11  on Record "# of steps in the progression" data;
        Put 1  on Record "Current step #" data;
        
        call "Input Layout";
        call "Make Bets";
    end
    

    If Record "Current Layout to Bet" layout has lost each time
    begin
        Put 100 % of Record "2nd previous bet" data on Record "1st previous bet" data;
        Put 100 % of the last Record "Current Layout to Bet" layout on Record "2nd previous bet" data;
        Add 1  on Record "Current step #" data;
        Set Flag "1" to False;
    end

    If Record "Current step #" data > Record "# of steps in the progression" data
    begin
        Put 0  on Record "1st previous bet" data;
        Put 0  on Record "2nd previous bet" data;
        Add 1  on Record "# of times complete progression is lost" data;
        Put 1  on Record "Current step #" data;
        Display "The end of Progression was reached with no
                  double wins.  The Progression will start over now.";
        call "Make Bets";
        exit;
    end

    If Record "Current Layout to Bet" layout has won each time
    And  Flag "1" is True
    begin
        Put 0  on Record "1st previous bet" data;
        Put 0  on Record "2nd previous bet" data;
        Put 1  on Record "Current step #" data;
        Set Flag "1" to False;
        Display "Yea!  You have two wins in a row.
                  The progression will start over now.";

        call "Make Bets";
        exit;
    end

    If Record "Current Layout to Bet" layout has won each time
    begin
        Set Flag "1" to True;
        Display "We have one win.  Now we need on more win
                  on the next Bet to win the Progression.";
    end

    call "Make Bets";
end

method "Input Layout"
begin
    Input DropDown "Make a Layout Selection
              
              1:=Even
              2:=Odd
              3:=Red
              4:=Black
              5:=High (19-36)
              6:=Low (1-18)" to Record "Current Layout to Bet" data;

    Call "Setup Layout";
end

method "Make Bets"
begin
    Put 100 % of Record "1st previous bet" data on Record "Current Layout to Bet" layout;
    Add 100 % of Record "2nd previous bet" data on Record "Current Layout to Bet" layout;
    
    If Record "1st previous bet" data = 0
    begin
        Put 100 % of Record "Size of each betting unit" data on
                                        Record "Current Layout to Bet" layout;
    end
end

method "Setup Layout"
begin
    If Record "Current Layout to Bet" data = 1
    begin
        Copy Even to the Record "Current Layout to Bet" layout;
    end
    Else
    begin
        If Record "Current Layout to Bet" data = 2
        begin
            Copy Odd to the Record "Current Layout to Bet" layout;
        end
        Else
        begin
            If Record "Current Layout to Bet" data = 3
            begin
                Copy Red to the Record "Current Layout to Bet" layout;
            end
            Else
            begin
                If Record "Current Layout to Bet" data = 4
                begin
                    Copy Black to the Record "Current Layout to Bet" layout;
                end
                Else
                begin
                    If Record "Current Layout to Bet" data = 5
                    begin
                        Copy high to the Record "Current Layout to Bet" layout;
                    end
                    Else
                    begin
                        If Record "Current Layout to Bet" data = 6
                        begin
                            Copy low to the Record "Current Layout to Bet" layout;
                        end
                    end
                end
            end
        end
    end
end

