It is the same as writing any person. Unless they are crazy, they need to make sense. If they are crazy, there is usually still some consistency.
What makes sense? A principled person will be principled even if his principle is to loyally serve the baby-eating alien emperor.
A selfish person...