Extracted game logic