I'm working on a somewhat simple game. Currently trying to implement the game logic for moving the pieces around.Logic is something like this:does player have pieces in inventory?    if yes:        did they try to move it to an empty location            if yes: ...            if no: ...    if no:        ...As you can see it's a bunch of nested if-else statements. My question is how could one refactor the code (or perhaps even approach the design) to avoid large nested blocks of if-else statements.My game is not chess, but if you take chess for example, how should you approach the design as to avoid conditionals where the game logic is quite complex.From the very brief search I've done polymorphism seems to be one(1)(1) https://stackoverflow.com/questions/7264145/if-less-programming-basically-without-conditionals
Defining logic without nested if-else statements
design patterns;conditions