system "Guetting_Progression_System"

{Guetting Progression System
In each group, you have to play two games.  You go from group 1 to group 3 before you
enter the next stage.  You can only go forward if you won your bet.  If you loose the
first game of a group, you have to go back to the beginning of the previous group.
If you loose the second game of a group, just play the whole group again.
}
method "main"
begin
    While Starting a New Session
    begin
        Call "Initialize";
        call "Input Layout";
        call "Make Bets";
    end

    While Record "Current Layout to Bet" layout has lost each time
    begin
        Put 100 % of Record "Ptr to Next Group" data on
                                            Record "Ptr to Next Group Bet section" data;
        Call "Point Which Group";
    end

    While Record "Current Layout to Bet" layout has won each time
    begin
        Add 1 on Record "Ptr to Next Group Bet section" data;
        Call "Point to Next Group";
    end

    call "Make Bets";
end

method "Make Bets"
begin
    Put 100% of Record "Ptr to Next Group Bet section" data on
                                                        Record "Group List" Data index;
    Put 100% of record "Group List" data on Record "Current Layout to Bet" Layout;
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 (0-18)" to Record "Layout Selection" data;

    Call "Setup Layout";
end

method "Setup Layout"
begin
    While Record "Layout Selection" data = 1
    begin
        Copy Even to the Record "Current Layout to Bet" layout;
    end
    Else
    begin
        While Record "Layout Selection" data = 2
        begin
            Copy Odd to the Record "Current Layout to Bet" layout;
        end
        Else
        begin
            While Record "Layout Selection" data = 3
            begin
                Copy Red to the Record "Current Layout to Bet" layout;
            end
            Else
            begin
                While Record "Layout Selection" data = 4
                begin
                    Copy Black to the Record "Current Layout to Bet" layout;
                end
                Else
                begin
                    While Record "Layout Selection" data = 5
                    begin
                        Copy high to the Record "Current Layout to Bet" layout;
                    end
                    Else
                    begin
                        While Record "Layout Selection" data = 6
                        begin
                            Copy low to the Record "Current Layout to Bet" layout;
                        end
                    end
                end
            end
        end
    end
end

method "Point to Next Group"
begin
    If Record "Ptr to Next Group Bet section" data = 4
    Or Record "Ptr to Next Group Bet section" data = 6
    Or Record "Ptr to Next Group Bet section" data = 8
    Or Record "Ptr to Next Group Bet section" data = 10
    Or Record "Ptr to Next Group Bet section" data = 13
    Or Record "Ptr to Next Group Bet section" data = 15
    Or Record "Ptr to Next Group Bet section" data = 17
    Or Record "Ptr to Next Group Bet section" data = 19
    Or Record "Ptr to Next Group Bet section" data = 21
    begin
        Add 2  on Record "Ptr to Next Group" data;
    end
    
    If Record "Ptr to Next Group Bet section" data> 21
    begin
        Put 1 on Record "Ptr to Next Group" data;
        Put 1 on Record "Ptr to Next Group Bet section" data;
    end
end

method "Point Which Group"
begin
    If Record "Ptr to Next Group Bet section" data = 3
    Or Record "Ptr to Next Group Bet section" data = 5
    Or Record "Ptr to Next Group Bet section" data = 7
    Or Record "Ptr to Next Group Bet section" data = 9
    Or Record "Ptr to Next Group Bet section" data = 11
    Or Record "Ptr to Next Group Bet section" data = 13
    Or Record "Ptr to Next Group Bet section" data = 15
    Or Record "Ptr to Next Group Bet section" data = 17
    Or Record "Ptr to Next Group Bet section" data = 19
    begin
        Subtract 2 on Record "Ptr to Next Group" data;
    end
    
    If Record "Ptr to Next Group Bet section" data < 1
    begin
        Put 1 on Record "Ptr to Next Group" data;
        Put 1 on Record "Ptr to Next Group Bet section" data;
    end
end

method "Initialize"
begin
    Set Flag "Playing Second Game" to false;
    set list [2,2,3,3,4,4,6,6,8,8,12,12,20,20,
              30,30,40,40] to record "Group List" data;

    Put 1 on Record "Ptr to Next Group" data;
    Put 1 on Record "Ptr to Next Group Bet section" data;
end


