Fixing mechanics

I couldnt read the code with all of the primitive loops and repetitive subroutines. I've tried my best to abstract it so we can program in game logic. 

Please look it over and revise anything I may have messed up in the refactoring.