Finalized functions

Fixed up some if statements so variables were defined properly and
finished the victory conditions.