TripleTown game logic in PHP