The program is written in Delphi, and the code is only 10 lines long.
You are absolutely right about the morale drop (extra turn);
here, you will have to use the following options:
1) take a hero without leadership and artifacts that increase morale;
2) apply a morale-reducing effect;
3) take armies from another castle to lower the morale to neutral;
to avoid cluttering the thread, I will separate the further description and discussion of the program into a separate topic (see the link below).
Charity suffereth long, and is kind; charity envieth not; charity vaunteth not itself, is not puffed up,
Doth not behave itself unseemly, seeketh not her own, is not easily provoked, thinketh no evil;
Rejoiceth not in iniquity, but rejoiceth in the truth;
Beareth all things, believeth all things, hopeth all things, endureth all things. Charity never faileth...