From 6b8c58ac2d4de502421acef48f4434bee605633f Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 8 Jan 2013 01:53:05 -0800 Subject: 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. --- pages/challenge.php | 17 ++--- pages/challengelist.php | 7 +- pages/faq.php | 4 +- pages/gallery.php | 178 ++++++++++++++++++++++++++++++++++++++++++++---- pages/home.php | 21 +++--- pages/tutorial.php | 1 + 6 files changed, 189 insertions(+), 39 deletions(-) (limited to 'pages') 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 @@ -
- Copyright © 2011-2012 pathery.com -
@@ -135,13 +134,15 @@ function displayChallenges($challengeResultset) echo '
    '; while($challenge = mysql_fetch_array($challengeResultset)) { + $mapID = $_GET["mapID"]; $challengeId = $challenge["challengeID"]; echo "
  1. "; if($challenge["dateSolved"] !== NULL) $cssClass = "challenge_complete"; else $cssClass = "challenge_incomplete"; - echo "" . getChallengeDisplayString($challenge) . ""; + $loadSolutionString = " Load this solution"; + echo "" . getChallengeDisplayString($challenge) . " $loadSolutionString "; echo "
  2. "; } echo "
"; @@ -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 @@ -
- Copyright © 2011-2012 pathery.com -
- @@ -84,7 +79,7 @@ function displayChallengeList($challengeListResultset) echo ''; } $currentMap = $challenge["mapID"]; - $mapName = $challenge["challengeName"]; + $mapName = $challenge["name"]; if($mapName == NULL || $mapName == "") $mapName = "(unknown)"; echo "$mapName"; 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:

The pathing is very greedy. It's only looking at it's next target. It does not look at the big-picture. You can use this to your advantage. When there's more than one checkpoint, you can completely wall one off. -
Not many maps contain will more than one of any checkpoint. -
The below demo demonstrates it's greed. - The path will actually be shorter if you wall the bottom A. +
Not many maps will contain more than one of any checkpoint. +
The below demo demonstrates it's greed. - The path will actually be shorter if you wall the bottom A!

Demo 3

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 "
"; +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 "
"; +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); ?> 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 Feedback-Seite.
+ '; 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 = '';