summaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-01-08 01:53:05 -0800
committerPatrick Davison <snapwilliam@gmail.com>2013-01-08 01:53:05 -0800
commit6b8c58ac2d4de502421acef48f4434bee605633f (patch)
treeb6ed4553388d0058952a987734a317ecfaea13f9 /pages
parenta431308aa3c6c698d23b45bf5e1f905123e0cba5 (diff)
downloadpathery-6b8c58ac2d4de502421acef48f4434bee605633f.tar.xz
Challenges Implementation. LOTS of stuff
Fixed an issue with loading best solution from logged out to logged in state. Commented out a lot of firephp stuff; feel free to uncomment.
Diffstat (limited to 'pages')
-rw-r--r--pages/challenge.php17
-rw-r--r--pages/challengelist.php7
-rw-r--r--pages/faq.php4
-rw-r--r--pages/gallery.php178
-rw-r--r--pages/home.php21
-rw-r--r--pages/tutorial.php1
6 files changed, 189 insertions, 39 deletions
diff --git a/pages/challenge.php b/pages/challenge.php
index 2ab279d..8d312d1 100644
--- a/pages/challenge.php
+++ b/pages/challenge.php
@@ -1,5 +1,4 @@
<?php
-ob_start("ob_gzhandler");
htmlHeader(
array('tutorial', 'challenge'), 'Pathery Challenges',
'Challenges', array('scores', 'dateformat')
@@ -94,8 +93,11 @@ if($mapCode === NULL)
return;
}
+// TODO: !! Sanitize mapid
+$mapID = $_GET["mapID"];
+
$mapContent = displayMap(GenerateMapByCode($mapCode), $_GET["mapID"]);
-$challengeResultset = loadChallengesForMap($_GET["mapID"], $userID);
+$challengeResultset = loadChallengesForMap($mapID, $userID);
if($challengeResultset === NULL)
{
redirectToChallengeListing();
@@ -112,9 +114,6 @@ if($challengeResultset === NULL)
?>
</div>
-<div id="copy" style='width:100%;clear: both'>
- Copyright &copy; 2011-2012 pathery.com
-</div>
<script src="sounds/script/soundmanager.js"></script>
<script type="text/javascript">soundManagerInit();</script>
@@ -135,13 +134,15 @@ function displayChallenges($challengeResultset)
echo '<div id="challenges_listing"><ol>';
while($challenge = mysql_fetch_array($challengeResultset))
{
+ $mapID = $_GET["mapID"];
$challengeId = $challenge["challengeID"];
echo "<li>";
if($challenge["dateSolved"] !== NULL)
$cssClass = "challenge_complete";
else
$cssClass = "challenge_incomplete";
- echo "<span class='$cssClass' id='challenge_id_$challengeId'>" . getChallengeDisplayString($challenge) . "</span>";
+ $loadSolutionString = "<a href='javascript:requestChallengeSolution(\"$mapID\", \"$challengeId\");'> Load this solution</a>";
+ echo "<span class='$cssClass' id='challenge_id_$challengeId'>" . getChallengeDisplayString($challenge) . " $loadSolutionString </span>";
echo "</li>";
}
echo "</ol></div></div>";
@@ -157,7 +158,7 @@ function getChallengeDisplayString($challenge)
if($challenge["goal"] == 0)
$returnMe .= "Complete the maze";
else if ($challenge['inequality'] == "greater than")
- $returnMe .= "Get " . $challenge['goal'];
+ $returnMe .= "Get " . $challenge['goal'] . ' or more';
else if ($challenge['inequality'] == "less than")
$returnMe .= "Get LESS THAN " . $challenge['goal'];
else //inequality == "equal"
@@ -169,7 +170,7 @@ function getChallengeDisplayString($challenge)
//Wall-count restriction
if($challenge['restrictWallCount'] !== NULL)
{
- $restrictions[] = "at most " . $challenge['restrictWallCount'] . " wall" . ($challenge['restrictWallCount'] == 1 ? "" : "s");
+ $restrictions[] = "only " . $challenge['restrictWallCount'] . " wall" . ($challenge['restrictWallCount'] == 1 ? "" : "s");
$addUsingToText = true;
}
diff --git a/pages/challengelist.php b/pages/challengelist.php
index e3f057a..03dfdb3 100644
--- a/pages/challengelist.php
+++ b/pages/challengelist.php
@@ -1,5 +1,4 @@
<?php
-ob_start("ob_gzhandler");
htmlHeader(
array('tutorial', 'challenge'), 'Pathery Challenges',
'Challenges', array('scores', 'dateformat')
@@ -45,10 +44,6 @@ displayChallengeList($challengeListResultset);
?>
</div>
-<div id="copy" style='width:100%;clear: both'>
- Copyright &copy; 2011-2012 pathery.com
-</div>
-
<?php
htmlFooter();
?>
@@ -84,7 +79,7 @@ function displayChallengeList($challengeListResultset)
echo '</td></tr>';
}
$currentMap = $challenge["mapID"];
- $mapName = $challenge["challengeName"];
+ $mapName = $challenge["name"];
if($mapName == NULL || $mapName == "")
$mapName = "(unknown)";
echo "<tr><td class='challengelist_link'><a href='challenge?mapID=$currentMap'>$mapName</a></td>";
diff --git a/pages/faq.php b/pages/faq.php
index 7b3c09c..3df08eb 100644
--- a/pages/faq.php
+++ b/pages/faq.php
@@ -124,8 +124,8 @@ Likewise, the Red Path noted by red in the arrow may pass over Red Allow blocks:
<p>The pathing is very greedy. It's only looking at it's next target.
<b>It does not look at the big-picture</b>. You can use this to your advantage.
When there's more than one checkpoint, you can completely wall one off.
-<br />Not many maps contain will more than one of any checkpoint.
-<br />The below demo demonstrates it's greed. - The path will actually be shorter if you wall the bottom A.
+<br />Not many maps will contain more than one of any checkpoint.
+<br />The below demo demonstrates it's greed. - The path will actually be shorter if you wall the bottom A!
<h3>Demo 3</h3>
<? echo $demo3; ?>
diff --git a/pages/gallery.php b/pages/gallery.php
index 098cf74..9df059a 100644
--- a/pages/gallery.php
+++ b/pages/gallery.php
@@ -28,17 +28,171 @@ topbar($Links);
include('./includes/maps.php');
include('./includes/mapoftheday.php');
+//$map = getRandomSpecialMap();
+//$map = getRandomWeeklyMap();
+//$map = getRandomComplexMap();
+echo "<br />";
+echo soundManager2();
+
+
+$spin[] = 'ooooooooooooooo';
+$spin[] = 'oooooororoooooo';
+$spin[] = 'ooooooooooooooo';
+$spin[] = 'uoooroormoroooo';
+$spin[] = 'soooooratooooof';
+$spin[] = 'noooooororooooo';
+$spin[] = 'ooooorooooooooo';
+$spin[] = 'oooooooroororoo';
+$spin[] = 'ooooooooooooooo';
+
+
+$myparams['checkpoints'] = 3;
+$myparams['teleports'] = 1;
+$myparams['rockchance'] = 2000;
+$myparams['walls'] = 12;
+$myparams['name'] = 'Round and Round';
+
+$map = GenerateShapedMap($spin, $myparams);
+
+echo DisplayMap($map, 2);
+
+//addNewChallengeMap($map, 0, 0, 'Round and Round');
+
+//addNewChallenge(1194, "greater than", 163, 1, "Make it go around and around and around");
+//addNewChallenge(1194, "greater than", 161, 1, "Make it go around and around and around", 11);
+//addNewChallenge(1194, "greater than", 173, 1, "Make it go around and around and around");
+
+exit;
+
+
+//Add's a new custom challenge map - returns mapid
+function addNewChallengeMap($map, $tier, $subOrder, $name) {
+ $mapcode = GenerateMapCode($map);
+
+ $sql = "INSERT INTO `maps`
+ (`code`, `isChallenge`, `ChallengeTier`, `ChallengeSuborder`, `ChallengeName`)
+ VALUES
+ ('$mapcode', true, $tier, $subOrder, '$name')";
+
+ echo $sql;
+ mysql_query($sql);
+ $mapID = mysql_insert_id();
+ return $mapID;
+}
+
+//Returns challenge ID
+function addNewChallenge($mapID, $inequality, $goal, $ordering, $hint,
+ $restrictWallCount = null, $restrictWallPlacement = null, $restrictTeleportCount = null,
+ $restrictTeleportsUsed = null, $restrictStartPoint = null, $restrictEndPoint = null) {
+
+ $sql = "INSERT INTO `challenges` (
+ `mapID`, `inequality`, `goal`, `ordering`, `hint`,
+ `restrictWallCount`, `restrictWallPlacement`, `restrictTeleportCount`,
+ `restrictTeleportsUsed`, `restrictStartPoint`, `restrictEndPoint`
+ )
+ VALUES (
+ '$mapID', '$inequality', $goal, $ordering, '$hint',
+ '$restrictWallCount', '$restrictWallPlacement', '$restrictTeleportCount',
+ '$restrictTeleportsUsed', '$restrictStartPoint', '$restrictEndPoint'
+ )";
+
+ echo $sql;
+ mysql_query($sql);
+ $challengeID = mysql_insert_id();
+ return $challengeID;
+}
+
+
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+$reversePath[] = 'fo????????????oS';
+
+$reversePath = insertPoint($reversePath, 'abc');
+
+$myparams['checkpoints'] = 3;
+$myparams['teleports'] = 0;
+$myparams['rockchance'] = 7;
+$myparams['walls'] = 12;
+$myparams['name'] = 'Dualing paths';
+
+//$map = GenerateShapedMap($reversePath, $myparams);
-$openmaps[] = 'Souxoooooooooooooooooooo';
-$openmaps[] = 'ooxoooXooooooooooooooooo';
-$openmaps[] = 'oxooooXoooooooooeocooooo';
-$openmaps[] = 'oxooooXooooooooooooooooo';
-$openmaps[] = 'oxooooXoooaoootooooooooo';
-$openmaps[] = 'oxooooXooooooooooooooooo';
-$openmaps[] = 'oxooooXooooooooooooooooo';
-$openmaps[] = 'oxooooXooooooooooooooooo';
-$openmaps[] = 'oxoooXbdoooooooooooooooo';
-$openmaps[] = 'fooooXooooooooooooooooos';
+$dualingPaths[] = 'so??????????????xf';
+$dualingPaths[] = 'so??????????????xf';
+$dualingPaths[] = 'so??????????????xf';
+$dualingPaths[] = 'so??????????????xf';
+$dualingPaths[] = 'Xo??????????????ox';
+$dualingPaths[] = 'fX??????????????oS';
+$dualingPaths[] = 'fX??????????????oS';
+$dualingPaths[] = 'fX??????????????oS';
+$dualingPaths[] = 'fX??????????????oS';
+
+$dualingPaths = insertPoint($dualingPaths, 'abc');
+$dualingPaths = insertPoint($dualingPaths, weight('x', 'xx', 'xxx').weight('X', 'XX', 'XXX'));
+
+$myparams['checkpoints'] = 3;
+$myparams['teleports'] = 0;
+$myparams['rockchance'] = 9;
+$myparams['walls'] = 12;
+$myparams['name'] = 'Dualing paths';
+
+$map = GenerateShapedMap($dualingPaths, $myparams);
+echo DisplayMap($map, 1);
+
+
+
+$unlimited[] = 'so?o?o?o?o?o?o?of';
+$unlimited[] = 's???????????????f';
+$unlimited[] = 'so?????????????of';
+$unlimited[] = 's???????????????f';
+$unlimited[] = 'so?????????????of';
+$unlimited[] = 's???????????????f';
+$unlimited[] = 'so?????????????of';
+$unlimited[] = 's???????????????f';
+$unlimited[] = 'so?o?o?o?o?o?o?of';
+
+$unlimited = insertPoint($unlimited, 'abc');
+$unlimited = insertPoint($unlimited, weight('tu', 'dtu'));
+
+$myparams['checkpoints'] = 3;
+$myparams['teleports'] = 1;
+$myparams['rockchance'] = 9;
+$myparams['walls'] = 999;
+$myparams['name'] = 'Unlimited';
+
+$map = GenerateShapedMap($unlimited, $myparams);
+
+
+echo "<br />";
+echo soundManager2();
+echo DisplayMap($map, 2);
+
+htmlfooter();
+exit;
+
+//$map = GenerateShapedMap($dualingPaths, $myparams);
+
+//$map = getRandomSpecialMap();
+//$map = getRandomComplexMap();
+
+ // DUALING PATHS MAP
+
+
+
+$openmaps[] = 'SouooooooXoooooooXooooxf';
+$openmaps[] = 'oooooooooXoooooooXooooox';
+$openmaps[] = 'oooooooooxooooooeXcooooo';
+$openmaps[] = 'oooooooooxoooooooXoooooo';
+$openmaps[] = 'oooooooooxaoootooXoooooo';
+$openmaps[] = 'oooooooooxxxxxxxxxoooooo';
+$openmaps[] = 'oooooooooooooooooooooooo';
+$openmaps[] = 'oooooooooooooooooooooooo';
+$openmaps[] = 'Xooooobdoooooooooooooooo';
+$openmaps[] = 'fXooooooooooooooooooooos';
$myparams['checkpoints'] = 5;
$myparams['teleports'] = 0;
@@ -46,9 +200,9 @@ $myparams['rockchance'] = 15;
$myparams['walls'] = 38;
$myparams['name'] = 'Dualing Starts';
-$map = GenerateShapedMap($openmaps, $myparams);
+//$map = GenerateShapedMap($openmaps, $myparams);
-echo DisplayMap($map, 1);
+//echo DisplayMap($map, 1);
?>
<script src="sounds/script/soundmanager.js"></script>
diff --git a/pages/home.php b/pages/home.php
index 7a197aa..37a94c3 100644
--- a/pages/home.php
+++ b/pages/home.php
@@ -124,6 +124,7 @@ Schick mir einfach eine Zeile auf der <a href="feedback">Feedback-Seite</a>.
<br />
+
<?
if ($accepted) {
if (!hasCompletedTutorial($userID)) {
@@ -164,15 +165,13 @@ if ($mapNames[4] == '') {
$mapNames[4] = 'Special';
}
-
-
-// $motd = MapOfTheDay(5);
-// $jmid[5] = $motd['id'];
-// $mapContent .= displayMaze($motd, 5);
-// $special2 = $motd['map'][0][6];
-// if ($special2 == '') {
- // $special2 = 'Special';
-// }
+$motd = MapOfTheDay(5);
+$jmid[5] = $motd['id'];
+$mapContent .= displayMaze($motd, 5);
+$mapNames[5] = $motd['map'][0][6];
+if ($mapNames[5] == '') {
+ $mapNames[5] = 'Special';
+}
echo ' <div id="difficulties">';
foreach ($mapNames as $key => $value) {
@@ -210,14 +209,14 @@ function displayMaze($motd, $mapType) {
";
$mysolution = '';
- $mymoves = '';
+ $mymoves = 0;
if ($accepted) {
$sol = getSolution($userID, $mapID);
$mysolution = $sol['solution'];
//TODO: implement mymoves
$mymoves = $sol['moves'];
}
- if (isset($_SESSION[$mapID.'sol']) && $mysolution == '') {
+ if (isset($_SESSION[$mapID.'sol']) && $_SESSION[$mapID.'moves'] > $mymoves) {
$mysolution = $_SESSION[$mapID.'sol'];
$mymoves = $_SESSION[$mapID.'moves'];
}
diff --git a/pages/tutorial.php b/pages/tutorial.php
index 6854be8..4d2446f 100644
--- a/pages/tutorial.php
+++ b/pages/tutorial.php
@@ -36,6 +36,7 @@ playerWallEmblem = '<?PHP echo isset($wallEmblem) ? $wallEmblem : ''; ?>';
<script>
isChallenge = true;
+isTutorial = true;
challengeID = 1;