var alt = getprop("/instrumentation/altimeter/indicated-altitude-ft");
var cruisefl = getprop("/FMGC/internal/cruise-fl");
var newcruise = getprop("/it-autoflight/input/alt");
var phase = getprop("/FMGC/status/phase");
var state1 = getprop("/systems/thrust/state1");
var state2 = getprop("/systems/thrust/state2");
var wowl = getprop("/gear/gear[1]/wow");
var wowr = getprop("/gear/gear[2]/wow");
var targetalt = getprop("/it-autoflight/input/alt");
var targetvs = getprop("/it-autoflight/input/vs");
var targetfpa = getprop("/it-autoflight/input/fpa");
var vertmode = getprop("/it-autoflight/mode/vert");
if ((((n1_left >= 85) and (n1_right >= 85)) or (gs > 90 )) and flaps < 4 and (mode == "SRS")) {
setprop("/FMGC/status/phase", "1");
}
if ((alt >= 1500) and (alt <= cruisefl) and (phase == "1") and (phase != "4") and (mode != "SRS")) {
setprop("/FMGC/status/phase", "2");
}
if ((alt >= cruisefl) and (phase == "2") and (mode != "SRS")) {
setprop("/FMGC/status/phase", "3"); # for now cruise will be level 100 or above until the MCDU is ready
}
if ((alt <= cruisefl) and (phase == "3")) { # for now it will have to be when we begin descent.
setprop("/FMGC/status/phase", "4");
}
if (getprop("/FMGC/status/to-state") == 0 and flaps >= 4 and ((phase == "4") or (phase == "2"))) { # add man activation of approach phase in MCDU or DECEL when those things are simulated
setprop("/FMGC/status/phase", "5");
}
if ((phase == "5") and (state1 == "TOGA") and (state2 == "TOGA")) { # this is the only fully correct one to FCOM
setprop("/FMGC/status/phase", "6");
}
# forget transition from APP to climb for now because it would be too complex
if ((phase == "6") and ((vertmode == "ALT CAP") or (vertmode == "G/A CLB") or (vertmode == "SPD CLB") or ((vertmode == "V/S") and (targetvs > 0)) or ((vertmode == "FPA") and (targetfpa > 0))) and (alt <= targetalt)) {