From 7197310f6901833a6ba01ad90d7300089a4978ca Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sun, 2 Dec 2012 13:29:04 -0800 Subject: Tutorial progress saved for users not-logged-in. Completion notice, and "sign in to save progress" added. --- do.php | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'do.php') diff --git a/do.php b/do.php index 329af35..d574031 100644 --- a/do.php +++ b/do.php @@ -19,6 +19,12 @@ if (!isset($_SESSION['accepted']) || $_SESSION['accepted'] <> 1) if (isset($_COOKIE['doLogin']) && $_COOKIE['doLogin'] == 'yes') CookieLogin(); +if (!isset($_SESSION['accepted']) || $_SESSION['accepted'] <> 1) + $accepted = false; +else + $accepted = true; + + // encode array $json to JSON string $debug = false; @@ -61,12 +67,23 @@ if ($_GET['r'] == 'reqScorePage') { $json['mapid'] = $mapID; $json['page'] = $page; + $note = false; if ($_SESSION['accepted'] == 1) { $userID = $_SESSION['userID']; $note = getNotified($userID); - if ($note !== false) - $json['notificationtext'] = $note; + } else { + if ($_SESSION['preCompletedTutorial'] == true && $_SESSION['preCompletedTutorialNotified'] == false) { + $_SESSION['preCompletedTutorialNotified'] = true; + $note = "Tutorial Completed!"; + $note .= "
You've unlocked: Blue Wall Color!"; + $note .= "
"; + $note .= '
Sign in to save your progress!
'; + $note .= "
"; + } } + if ($note !== false) + $json['notificationtext'] = $note; + $encoded = json_encode($json); die($encoded); @@ -215,6 +232,7 @@ if ($_GET['r'] == 'getpath') { // --------- CONTINUE EXECUTION + //TODO: Commented this out - temporarly. // $firephp->log('Got this far'); // $firephp->log($_SESSION['accepted'], '$_SESSION["accepted"]'); @@ -239,6 +257,24 @@ if ($_GET['r'] == 'getpath') { // return; //} //x + //TODO: I changed this; note these changes before re-applying the above. + //Challenge/Tutorial? + if ($mapID <= 10 AND $_GET['isChallenge'] = 'true') { + $json['error'][] = 'executed as a challenge'; + + //This will allow me to give insentive to logging in. + // So that they don't have to do the tutorial twice. + if ($mapID == 5 && $moves == 75 && $accepted == false) { + $_SESSION['preCompletedTutorial'] = true; + $_SESSION['preCompletedTutorialNotified'] = false; + } + if ($accepted == false) + return; + + getCompletedChallenges($userID, $mapID, $solution, $moves, $paths); + return; + } + // --------- USER NOT LOGGED IN? if ($_SESSION['accepted'] !== 1) { @@ -251,14 +287,6 @@ if ($_GET['r'] == 'getpath') { $json['error'][] = 'user is logged in'; // --------- USER LOGGED IN - //Challenge/Tutorial? - if ($mapID <= 10 AND $_GET['isChallenge'] = 'true') { - $json['error'][] = 'executed as a challenge'; - //echo "running function".$_GET['challengeID']; - applyChallengeAchievements($userID, $_GET['challengeID'], $mapID, $solution, $moves); - return; - } - //Is the map still valid to score on? if (!isCurrentMap($mapID)) return; -- cgit v1.2.3