system "Dream_System"

method "main"
begin
    While Starting a New Session
    begin
        Call "Initialize";
        Call "Select Input Information";
        Call "Initialize Data Input";
    end
    
    While on each Spin
    begin
        Call "Determine Win/Loss";
        Call "Check Win Goal";
        Call "Check Loss Goal";
        Call "Make Bet";
        Call "Determine next Layout";
        Set Flag "Bet Placed" to True;
    end
end

method "Make Bet"
begin
    Put 100 % of Record "Current Unit to bet" data on Record "Layout List" layout;
    Add 1 to Record "Bet counter" data;
end

method "Determine next Layout"
begin
    Add 1 to Record "Layout List" Layout index;
    
    If Record "Layout List" Layout index > 3
    begin
        Put 1 to Record "Layout List" Layout index;
    end
end

method "Check Win Goal"
begin
    If Bankroll >= Record "Total Win Goal" data
    And  Flag "Bet Placed" is True
    begin
        Display "Your Win Goal Reached  Session will now End.";
        Stop Session;
    end
end

method "Check Loss Goal"
begin
    If Bankroll <= Record "Total Loss Goal" data
    And  Flag "Bet Placed" is True
    begin
        Display "***  Loss Goal Reached.  Session will now End. ***";
        Stop Session;
    end
end

method "Determine Win/Loss"
begin
    If Any Outside Bet has won each time
    begin
        Subtract 100 % of Record "Unit adjustment" data to
                                             Record "Current Unit to bet" data;
    end
    
    If Any Outside Bet has lost each time
    begin
        Add 100 % of Record "Unit adjustment" data to
                                             Record "Current Unit to bet" data;
    end
    
    If Record "Current Unit to bet" data <= Record "Starting Unit" data
    begin
        Put 100 % of Record "Starting Unit" data to
                                              Record "Current Unit to bet" data;
    end
end

method "Initialize"
begin
    Set Flag "Bet Placed" to false;
    Copy list [Red,Black,Black] to the Record "Layout List" layout;
    Put 1 to Record "Layout List" Layout index;
    
    Clear Record "Wheel indicator" data;
    Clear Record "Loss Goal" data;
    Clear Record "Win Goal" data;
    Clear Record "Starting Bankroll" data;
    Clear Record "Starting Unit" data;
    Clear Record "Bet counter" data;
    Clear Record "Total Win Goal" data;
    Clear Record "Total Loss Goal" data;
    Clear Record "Current Unit to bet" data;
    Clear Record "Unit adjustment" data;

    Put 0 to Record "Bet counter" data;
end

method "Initialize Data Input"
begin
    Put 100 % of Record "Starting Bankroll" data on Bankroll;
    Put 100 % of Record "Starting Unit" data on Record "Current Unit to bet" data;
    Put 100 % of Bankroll on Record "Total Win Goal" data;
    Put 100 % of Bankroll on Record "Total Loss Goal" data;
    Add 100 % of Record "Win Goal" data on Record "Total Win Goal" data;
    Subtract 100 % of Record "Loss Goal" data on Record "Total Loss Goal" data;
    
    While Record "Wheel indicator" data = 1
    begin
        Load Single Wheel;
    end
    Else
    begin
        Load Double Wheel;
    end
end

method "Select Input Information"
begin
    Group
    begin
        Display "This is a short-term hit-and-run roulette strategy.
                  
                  It is recommended to quit if you are up by 5 to 10 units.";
        Input Data "Enter Bankroll for entire Session" to Record "Starting Bankroll" data;
        Input Dropdown "What Table Layout do you want to use?
                  
                  1:=European Layout
                  2:=American Layout" to Record "Wheel indicator" data;
        Input Data "Enter Starting Unit:" to Record "Starting Unit" data;
        Input Data "Enter your Win Goal in Units:" to Record "Win Goal" data;
        Input Data "Enter your Loss Goal in Units:" to Record "Loss Goal" data;
        Input Data "Enter your Unit amount to increase/decrease by:" to Record "Unit adjustment" data;
    end
end
