summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2012-12-02 13:29:04 -0800
committerPatrick Davison <snapwilliam@gmail.com>2012-12-02 13:29:04 -0800
commit7197310f6901833a6ba01ad90d7300089a4978ca (patch)
treeea71a24792a162241df9144fbaab178d6993486f
parentb2bffd5eb17212b60b62ab86a8559213ed3820af (diff)
downloadpathery-7197310f6901833a6ba01ad90d7300089a4978ca.tar.xz
Tutorial progress saved for users not-logged-in.
Completion notice, and "sign in to save progress" added.
-rw-r--r--do.php48
-rw-r--r--pages/achievements.php2
-rw-r--r--pages/login.php9
3 files changed, 48 insertions, 11 deletions
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 = "<strong>Tutorial Completed!</strong>";
+ $note .= "<center>You've unlocked: Blue Wall Color!";
+ $note .= "<table><tr><td onclick='changeWallColor(\"#4444ff\")' style='background-color:#4444ff;' class='grid_td_rocks'></td></tr></table>";
+ $note .= '<br /><a href="javascript:showSignin();"><strong>Sign in</strong></a> to save your progress!<br />';
+ $note .= "</center>";
+ }
}
+ 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;
diff --git a/pages/achievements.php b/pages/achievements.php
index 30d59b2..0502198 100644
--- a/pages/achievements.php
+++ b/pages/achievements.php
@@ -334,7 +334,7 @@ SELECT
IfNull(userData.displayColor, '#cccccc'),
userData.wallEmblem
FROM `users`
-JOIN `solutions`
+LEFT JOIN `solutions`
ON users.ID = solutions.userID
LEFT JOIN `userData`
ON users.ID = userData.userID
diff --git a/pages/login.php b/pages/login.php
index b8662ab..6918958 100644
--- a/pages/login.php
+++ b/pages/login.php
@@ -116,6 +116,15 @@ try {
if ($result) {
$userID = mysql_insert_id();
$dateJoined = date(DateTime::ISO8601);
+
+ //Tutorial done?
+ if (isset($_SESSION['preCompletedTutorial'])) {
+ if ($_SESSION['preCompletedTutorial'] == true) {
+ include_once('./includes/datas.php');
+ onCompletedTutorial($userID);
+ }
+ }
+
} //Oh crap?
else {
$errortext = "<br />new-user db register failure of unknown cause.\n