diff options
-rw-r--r-- | app.php | 224 | ||||
-rw-r--r-- | css/mapstyle.css | 29 | ||||
-rw-r--r-- | errors.php | 2 | ||||
-rw-r--r-- | includes/header.php | 2 | ||||
-rw-r--r-- | includes/mapoftheday.php | 2 | ||||
-rw-r--r-- | includes/maps.php | 434 | ||||
-rw-r--r-- | index.php | 8 | ||||
-rw-r--r-- | js/mapspecs.js | 22 | ||||
-rw-r--r-- | pages/embed.php | 113 | ||||
-rw-r--r-- | pages/home.php | 102 | ||||
-rw-r--r-- | pages/login.php | 19 | ||||
-rw-r--r-- | pages/tutorial.php | 116 |
12 files changed, 884 insertions, 189 deletions
@@ -0,0 +1,224 @@ +<?PHP
+
+include "includes/maps.php";
+include "includes/db.inc.php";
+include "includes/mapoftheday.php";
+include "includes/datas.php";
+
+// encode array $json to JSON string
+
+//echo "working...";
+
+if ($_GET['act'] == "test") {
+
+//header('Content-Type: text/xml');
+header("Content-Type: text/plain");
+
+if ($_POST['XMLRequest']) {
+ $string = $_POST['XMLRequest'];
+} else {
+ $string = '<!-- request -->
+<BrainMazeAPI version="0.1">
+ <APIRequest>
+ <SubmitScore>
+ <MapID>5</MapID>
+ <Username>FiftyToo</Username>
+ <Score>50</Score>
+ </SubmitScore>
+ </APIRequest>
+</BrainMazeAPI>';
+}
+
+$xml = simplexml_load_string($string);
+
+//echo $xml->APIRequest->SubmitScore->MapID;
+//print_r ($xml);
+
+
+
+
+$score = $xml->APIRequest[0]->SubmitScore[0]->Score;
+$username = $xml->APIRequest[0]->SubmitScore[0]->Username;
+
+//echo $xml->getName() . "<br />";
+// foreach($xml->children() as $child) {
+// echo $child->getName() . ": " . $child . "<br />";
+// }
+
+
+//$score = 50;
+$previousScore = 49;
+$rank = 1;
+
+//Begin XML Response
+$w = new XMLWriter();
+$w->openMemory();
+$w->startDocument('1.0','UTF-8');
+$w->startElement("BrainMazeAPI");
+ $w->writeAttribute("version", "0.1");
+ $w->startElement("APIResponse");
+ $w->startElement("SubmitScore");
+ $w->writeAttribute("result", "SUCCESS");
+
+ $w->startElement("rank");
+ $w->text($rank);
+ $w->endElement();
+
+ $w->startElement("update");
+ $w->text('true');
+ $w->endElement();
+
+ $w->startElement("UsernameUsed");
+ $w->text($username);
+ $w->endElement();
+
+ $w->startElement("SubmittedScore");
+ $w->text($score);
+ $w->endElement();
+
+ $w->startElement("PreviousHighScore");
+ $w->text($previousScore);
+ $w->endElement();
+
+ $w->endElement();
+ $w->endElement();
+$w->endElement();
+echo $w->outputMemory(true);
+
+}
+
+
+
+if ($_GET['act'] == "submit") {
+header('Content-Type: text/xml');
+echo '<!-- response -->
+<BrainMazeAPI version="0.1">
+ <APIResponse>
+ <SubmitScore result="SUCCESS">
+ <Rank>5</Rank>
+ <SubmittedScore>50</SubmittedScore>
+ <PreviousHighScore>49</PreviousHighScore>
+ </SubmitScore>
+ </APIResponse>
+</BrainMazeAPI>';
+
+}
+
+
+$xml = '<!-- request -->
+<BrainMazeAPI version="0.1">
+ <APIRequest>
+ <SubmitScore>
+ <MapID>5</MapID>
+ <Username>FiftyToo</Username>
+ <Score>50</Score>
+ </SubmitScore>
+ </APIRequest>
+</BrainMazeAPI>
+
+
+<!-- response -->
+<BrainMazeAPI version="0.1">
+ <APIResponse>
+ <SubmitScore result="SUCCESS">
+ <Rank>5</Rank>
+ <SubmittedScore>50</SubmittedScore>
+ <PreviousHighScore>49</PreviousHighScore>
+ </SubmitScore>
+ </APIResponse>
+</BrainMazeAPI>';
+
+
+
+
+if ($_GET['act'] == "getmap") {
+
+ $maptype = $_GET['maptype'] + 0;
+ if (!is_int($maptype))
+ return;
+ if ($maptype > 4)
+ return;
+ if ($maptype < 1)
+ return;
+
+ $motd = MapOfTheDay($maptype);
+ $map = $motd['map'];
+ $mapID = $motd['id'];
+
+ //print_r($map);
+
+ echo translatemap($map, $mapID);
+
+}
+
+function translatemap($mapMatrix, $mapID) {
+
+
+ $mapdata['height'] = $mapMatrix[0][0];
+ $mapdata['width'] = $mapMatrix[0][1];
+ $waypoints = $mapMatrix[0][2];
+ $mapdata['rocks'] = $mapMatrix[0][3];
+ $walls = $mapMatrix[0][4];
+ $mapdata['teleports'] = $mapMatrix[0][5];
+
+ $r .= "<level>";
+ $r .= "\n <properties>";
+ $r .= "\n <mapID>$mapID</mapID>";
+ $r .= "\n <availableCost>$walls</availableCost>";
+ $r .= "\n <waypoints>$waypoints</waypoints>";
+ $r .= "\n </properties>";
+
+
+ $r .= "\n <tiles>";
+ $r .= "\n <rows>";
+ for ($i = 1; $i < count($mapMatrix); $i++) {
+
+ $r .= "\n <row>";
+ for ($j = 0; $j < count($mapMatrix[$i]); $j++) {
+
+ switch($mapMatrix[$i][$j]) {
+ case 's': $r .= "02 "; break;
+ case 'f': $r .= "03 "; break;
+
+ case 't': $r .= "50 "; break;
+ case 'u': $r .= "61 "; break;
+ //TP2
+ case 'm': $r .= "51 "; break;
+ case 'n': $r .= "62 "; break;
+ //TP3
+ case 'g': $r .= "52 "; break;
+ case 'h': $r .= "63 "; break;
+ //TP4
+ case 'i': $r .= "53 "; break;
+ case 'j': $r .= "64 "; break;
+ //TP5
+ case 'k': $r .= "54 "; break;
+ case 'l': $r .= "65 "; break;
+
+ case 'a': $r .= "40 "; break;
+ case 'b': $r .= "41 "; break;
+ case 'c': $r .= "42 "; break;
+ case 'd': $r .= "43 "; break;
+ case 'e': $r .= "44 "; break;
+
+ case 'r': $r .= "00 "; break; //rock
+ case 'w': $r .= "01 "; break; //wall
+ //default: $r .= "<td class='grid_td' id='$handle' onClick='grid_click(this)' >".$index."</td>";
+ default: $r .= "10 ";
+ //default: $r .= "<td class='grid_td' id='$handle' onClick='grid_click(this)' >".$mapMatrix[$i][$j]."</td>";
+ }
+ }
+ $r .= "</row>";
+ }
+ $r .= "\n </rows>";
+ $r .= "\n </tiles>";
+ $r .= "\n</level>";
+ return $r;
+}
+
+
+
+
+
+
+
diff --git a/css/mapstyle.css b/css/mapstyle.css index 3dbf8c1..ffec888 100644 --- a/css/mapstyle.css +++ b/css/mapstyle.css @@ -9,9 +9,9 @@ position:relative;
padding: 0px;
margin-top: 10px;
- margin-bottom: 60px;
+ margin-bottom: 1px;
padding-top:2px;
- padding-bottom:10px;
+ padding-bottom:1px;
margin-left:auto;
margin-right:auto;
border-top: 1px solid #000;
@@ -24,6 +24,7 @@ color: #FFFF33;
}
+
.dsp_33 {
width:32%;
}
@@ -85,7 +86,7 @@ margin: 0px;
}
.grid_td,
-.grid_td_rocks, .grid_td_walls,
+.grid_td_rocks, .grid_td_gray, .grid_td_path, .grid_td_blanks, .grid_td_walls,
.grid_td_start, .grid_td_finish,
.grid_td_cpa, .grid_td_cpb, .grid_td_cpc,
.grid_td_cpd, .grid_td_cpe,
@@ -117,22 +118,31 @@ .grid_td
{
background: #F5FBFE url(../images/OverlayTile10.png);
- background-color: #F5FBFE;
}
.grid_td:hover
{
background: #CCCCCC url(../images/OverlayTileFaceted10.png);
- background-color: #CCC;
}
.grid_td_pressed {
background: #111122;
}
.grid_td_rocks {
- background-color: #b76666;
+ background: #b85555 url(../images/OverlayTileFaceted50.png);
+}
+.grid_td_gray {
+ background: #CCCCCC url(../images/OverlayTileFaceted50.png);
+}
+.grid_td_path {
+ background: #FFFFEE url(../images/OverlayTeleport.png);
+}
+
+.grid_td_blanks {
+ background: inherit;
}
.grid_td_walls {
- background-color: #777;
+ background-color: #666666;
+ background: url(../images/OverlayTileFaceted50.png);
transition:background-color 1.6s ease-out;
-webkit-transition:background-color 1.6s ease-out;
-o-transition:background-color 1.6s ease-out;
@@ -145,12 +155,11 @@ .grid_td_start {
background: url(../images/OverlayStart50i.png);
- background-color: #E44;
- color: #fff;
+ background-color: #F75555;
}
.grid_td_finish {
background: url(../images/OverlayStart50.png);
- background-color: #55e;
+ background-color: #6666FF;
color: #fff;
}
@@ -8,7 +8,7 @@ Echo "You're here because of error: $_GET[error] "; Echo "<br />$_SERVER[HTTP_REFERER]";
-Echo "<br /><a href='http://www.snapems.com'>Go back to Home</a>";
+Echo "<br /><a href='http://www.pathery.com'>Go back to Home</a>";
diff --git a/includes/header.php b/includes/header.php index 53c1a82..b386cfa 100644 --- a/includes/header.php +++ b/includes/header.php @@ -9,7 +9,7 @@ function htmlHeader() { <link href="css/mapstyle.css" rel="stylesheet" type="text/css" />
<link href="css/pagestyle.css" rel="stylesheet" type="text/css" />
<link href="css/statsstyle.css" rel="stylesheet" type="text/css" />
- <title>Snapems.com Mazegame</title>
+ <title>pathery.com</title>
<script src="js/ajax.js" type="text/javascript"></script>
<script src="js/mapspecs.js" type="text/javascript"></script>
diff --git a/includes/mapoftheday.php b/includes/mapoftheday.php index cd646cb..62b44a4 100644 --- a/includes/mapoftheday.php +++ b/includes/mapoftheday.php @@ -1 +1 @@ -<?PHP
include_once('maps.php');
include_once('db.inc.php');
//Select from current day.
function getMapOfTheDay() {
$sql = "
select `ID`, `code` from `maps`
WHERE (
DAY(dateCreated) = DAY(NOW())
AND
MONTH(dateCreated) = MONTH(NOW())
AND
YEAR(dateCreated) = YEAR(NOW())
)
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
// If you want to modify the maps created! This is the line
$map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9));
$code = GenerateMapCode($map);
$sql = "INSERT INTO `maps` (`code`)
VALUES ('$code')";
mysql_query($sql);
$r['code'] = $code;
$r['map'] = $map;
$r['id'] = mysql_insert_id();
return $r;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['map'] = GenerateMapByCode($r['code']);
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
function mapOfTheDay($type = 1) {
$sql = "
select maps.ID, maps.code
FROM `mapOfTheDay`, `maps`
WHERE `mapDate` = CURDATE() AND
`mapType` = $type AND
mapID = maps.ID
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
// If you want to modify the maps created! This is the line
//GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) {
switch ($type) {
case 1: //Easy
$map = GenerateMap(13, 7, 12, rand(7,10), rand(0, 2), 0);
break;
case 2: //Normal
$map = GenerateMap(15, 9, 7, rand(11,13), rand(1,2) + rand(0,1), rand(0,1));
break;
case 3: //Hard
$map = GenerateMap(19, 9, rand(7, 9), rand(13,16), rand(2,5), rand(1,2));
break;
case 4: //Full random map
//Get the current day as int.
$numday = date('w');
$numday = intval($numday);
switch ($numday) {
case 0: //Sunday
//Thirty
$map = GenerateMap(
18, 14, 20 , //width, height, rocks
weight(30) , //Walls
weight(1) , //Checkpoints
weight(1) //Teleports
);
break;
case 1: //Monday
//Simple
$map = GenerateMap(
18, 9, 7 , //width, height, rocks
weight(15,16,17) , //Walls
weight(0) , //Checkpoints
weight(0) //Teleports
);
break;
case 2: //Tuesday
//ABC's
$map = GenerateMap(
19, 11, 12 , //width, height, rocks
weight(20,21,22,22,23) , //Walls
weight(3) , //Checkpoints
weight(0) //Teleports
);
break;
case 3: //Wednesday
//Tele Madness
$map = GenerateMap(
17, 12, 10 , //width, height, rocks
weight(17,18) , //Walls
weight(1) , //Checkpoints
weight(5) //Teleports
);
break;
case 4: //Thursday
//Rocky Maze
$map = GenerateMap(
19, 15, 5 , //width, height, rocks
weight(16,17,18) , //Walls
weight(1,2,2,2,3,3) , //Checkpoints
weight(0) //Teleports
);
break;
case 5: //Friday
//Side to Side
$map = GenerateMap(
26, 6, 12 , //width, height, rocks
weight(17,18,19) , //Walls
weight(2,2,2,3,3) , //Checkpoints
weight(3,3,3,4) //Teleports
);
break;
case 6: //Saturday
//ABC's
$map = GenerateMap(
19, 11, 12 , //width, height, rocks
weight(20,21,22,22,23) , //Walls
weight(3) , //Checkpoints
weight(0) //Teleports
);
break;
}
break;
default:
$map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9));
break;
}
$code = GenerateMapCode($map);
$sql = "INSERT INTO `maps` (`code`)
VALUES ('$code')";
mysql_query($sql);
$mapID = mysql_insert_id();
$r['code'] = $code;
$r['map'] = $map;
$r['id'] = $mapID;
$sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`)
VALUES ('$mapID', '$type', CURDATE()) ";
mysql_query($sql);
return $r;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['map'] = GenerateMapByCode($r['code']);
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
// RMA # CT1160811
// 97686
//Select from yesterday
function getYesterdaysMap() {
$sql = "
select `ID`, `code` from `maps`
WHERE (
DAY(dateCreated) = DAY(NOW()) - 1
AND
MONTH(dateCreated) = MONTH(NOW())
AND
YEAR(dateCreated) = YEAR(NOW())
)
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
return -1;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
?>
\ No newline at end of file +<?PHP
include_once('maps.php');
include_once('db.inc.php');
//Select from current day.
function getMapOfTheDay() {
$sql = "
select `ID`, `code` from `maps`
WHERE (
DAY(dateCreated) = DAY(NOW())
AND
MONTH(dateCreated) = MONTH(NOW())
AND
YEAR(dateCreated) = YEAR(NOW())
)
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
// If you want to modify the maps created! This is the line
$map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9));
$code = GenerateMapCode($map);
$sql = "INSERT INTO `maps` (`code`)
VALUES ('$code')";
mysql_query($sql);
$r['code'] = $code;
$r['map'] = $map;
$r['id'] = mysql_insert_id();
return $r;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['map'] = GenerateMapByCode($r['code']);
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
function mapOfTheDay($type = 1) {
$sql = "
select maps.ID, maps.code
FROM `mapOfTheDay`, `maps`
WHERE `mapDate` = CURDATE() AND
`mapType` = $type AND
mapID = maps.ID
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
// If you want to modify the maps created! This is the line
//GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) {
switch ($type) {
case 1: //Easy
$map = GenerateMap(13, 7, 12, rand(7,10), rand(0, 2), 0);
break;
case 2: //Normal
$map = GenerateMap(15, 9, 7, rand(11,13), rand(1,2) + rand(0,1), rand(0,1));
break;
case 3: //Hard
$map = GenerateMap(19, 9, rand(7, 9), rand(13,16), rand(2,5), rand(1,2));
break;
case 4: //Full random map
//Get the current day as int.
$numday = date('w');
$numday = intval($numday);
switch ($numday) {
case 0: //Sunday
//Thirty
$map = GenerateMap(
18, 14, 20 , //width, height, rocks
weight(30) , //Walls
weight(1) , //Checkpoints
weight(1) //Teleports
);
break;
case 1: //Monday
//Simple
$map = GenerateMap(
18, 9, 7 , //width, height, rocks
weight(15,16,17) , //Walls
weight(0) , //Checkpoints
weight(0) //Teleports
);
break;
case 2: //Tuesday
//ABC's
$map = GenerateMap(
19, 11, 12 , //width, height, rocks
weight(20,21,22,22,23) , //Walls
weight(3) , //Checkpoints
weight(0) //Teleports
);
break;
case 3: //Wednesday
//Tele Madness
$map = GenerateMap(
17, 12, 10 , //width, height, rocks
weight(17,18) , //Walls
weight(1) , //Checkpoints
weight(5) //Teleports
);
break;
case 4: //Thursday
//Rocky Maze
$map = GenerateMap(
19, 15, 5 , //width, height, rocks
weight(16,17,18) , //Walls
weight(1,2,2,2,3,3) , //Checkpoints
weight(0) //Teleports
);
break;
case 5: //Friday
//Side to Side
$map = GenerateMap(
26, 6, 12 , //width, height, rocks
weight(17,18,19) , //Walls
weight(2,2,2,3,3) , //Checkpoints
weight(3,3,3,4) //Teleports
);
break;
case 6: //Saturday
//Dual map
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "oqqqqqqqqqqqqqqqqqqqq";
$dualmapa[] = "oqqqqqqqqqqqqqqqqqqqq";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapa = insertPoint($dualmapa, 'abc');
$dualmapb = insertPoint($dualmapb, 'abc');
$dualmap = array_merge($dualmapa, $dualmapb);
$dualmap = insertPoint($dualmap, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = weight(20, 20, 21, 21, 22, 23);
$map = GenerateShapedMap($dualmap, $myparams);
break;
}
break;
default:
$map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9));
break;
}
$code = GenerateMapCode($map);
$sql = "INSERT INTO `maps` (`code`)
VALUES ('$code')";
mysql_query($sql);
$mapID = mysql_insert_id();
$r['code'] = $code;
$r['map'] = $map;
$r['id'] = $mapID;
$sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`)
VALUES ('$mapID', '$type', CURDATE()) ";
mysql_query($sql);
return $r;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['map'] = GenerateMapByCode($r['code']);
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
// RMA # CT1160811
// 97686
//Select from yesterday
function getYesterdaysMap() {
$sql = "
select `ID`, `code` from `maps`
WHERE (
DAY(dateCreated) = DAY(NOW()) - 1
AND
MONTH(dateCreated) = MONTH(NOW())
AND
YEAR(dateCreated) = YEAR(NOW())
)
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
return -1;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
?>
\ No newline at end of file diff --git a/includes/maps.php b/includes/maps.php index acb4c6c..7be04eb 100644 --- a/includes/maps.php +++ b/includes/maps.php @@ -1,4 +1,5 @@ <?PHP
+//Displays the map
function DisplayMap($mapMatrix, $idprefix = 1, $example = false, $speed = NULL) {
//Iterate through $mapMatrix and generate the html
$maptable = ""; //The string to return to the database.
@@ -50,6 +51,11 @@ function DisplayMap($mapMatrix, $idprefix = 1, $example = false, $speed = NULL) case 'e': $maptable .= "<td class='grid_td_cpe' id='$handle' ></td>"; break;
case 'r': $maptable .= "<td class='grid_td_rocks' id='$handle' ></td>"; break; //rock
+ case 'R': $maptable .= "<td class='grid_td_gray' id='$handle' ></td>"; break; //metalic looking rock
+
+ case 'p': $maptable .= "<td class='grid_td_path' id='$handle' ></td>"; break; //path.
+ case 'q': $maptable .= "<td class='grid_td_blanks' id='$handle' ></td>"; break; //transparent
+
case 'w': $maptable .= "<td class='grid_td_walls' id='$handle' name='true' onClick='grid_click(this)' ></td>"; break; //wall
//default: $maptable .= "<td class='grid_td' id='$handle' onClick='grid_click(this)' >".$index."</td>";
default: $maptable .= "<td title='Position: $i,$j' class='grid_td' id='$handle' onClick='grid_click(this)' ></td>";
@@ -78,11 +84,28 @@ function DisplayMap($mapMatrix, $idprefix = 1, $example = false, $speed = NULL) //$height = (($i * 22) + 2).'px';
$jsonmap = json_encode($mapdata);
+
+
+
+
+ //This works in chrome, not sure about others.
+ $preloaddiv .= "
+ <div style='visibility:hidden;display:none'>
+ <img src='images/Path1.png' />
+ <img src='images/Path2.png' />
+ <img src='images/Path3.png' />
+ <img src='images/Path4.png' />
+ <img src='images/OverlayTileFaceted50.png' />
+ <img src='images/OverlayTileFaceted30.png' />
+ <img src='images/OverlayTileFaceted10.png' />
+ </div>";
+
$mapdatadiv .= "<div id='$idprefix,mapdata' style='visibility:hidden;display:none'>";
$mapdatadiv .= $jsonmap;
$mapdatadiv .= '</div>';
- $maptable = "<table style='width:$width;height:$height;' class='grid_table'>
+ $maptable = "$preloaddiv
+ <table style='width:$width;height:$height;' class='grid_table'>
$maptable
</table>";
@@ -174,10 +197,20 @@ function DisplayMap($mapMatrix, $idprefix = 1, $example = false, $speed = NULL) return $output;
}
+
//Generates map
function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) {
- //!! Possibility of inf loop here.
+ if ($numBlocks == -1)
+ $numBlocks = Rand(7, (int)($rows * $cols) * .12);
+ //Checkpoints and teleports.
+ if ($cp == -1)
+ $cp = rand(0, 5);
+ if ($tp == -1)
+ $tp = rand(0, 2);
+ $tp = $tp * 2; //Requires an out-teleport.
+
+ //== Possibility of inf loop here, if the map is too small.
do {
$randvalue = rand(1, ($rows * $cols));
//As long as it isn't the first, or last column.
@@ -188,23 +221,16 @@ function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = $unique = array_unique($unique);
$unique = array_values($unique);
}
- } while (count($unique) < 15);
+ } while (count($unique) < ($cp+$tp) );
- if ($numBlocks == -1)
- $numBlocks = Rand(7, (int)($rows * $cols) * .12);
-
- if ($cp == -1)
- $cp = rand(0, 5);
- if ($tp == -1)
- $tp = rand(0, 2);
- $tp = $tp * 2; //Requires an out-teleport.
-
+ //Prepare our checkpoint and teleport names.
$cpnames = Array("a", "b", "c", "d", "e");
+ // in out in out etc.
$tpnames = Array("t", "u", "m", "n", 'g', 'h', 'i', 'j', 'k', 'l');
$teleport = Array();
$checkpoint = Array();
-
+ //Assign our checkpoints and teleports a unique position on the map.
$i = 0;
for($p = 0; $p < $cp; $p++) {
$checkpoint[$cpnames[$p]] = $unique[$i];
@@ -218,7 +244,7 @@ function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = $rocks = 0; //Number of rocks in the maze.
// We need to make sure the map we construct is valid.
- // so we throw this in a do-while.
+ // so we throw this in a do-while the map is invalid.
do {
$p = -1;
//Begin loop to populate grid.
@@ -227,10 +253,14 @@ function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = $p++;
//Start and Finish squares.
if ($x == 0) {
+ //if ($x == 0 AND $y == 1) {
+ //if ($x == 0 AND rand(1,3) == 1) {
$grid[$y][$x] = "s";
} elseif ($x == $rows - 1) {
+ //} elseif ($x == $rows - 1 AND $y == intval(($cols + 1) * .5) ) {
+ //} elseif ($x == $rows - 1 AND rand(1,3) == 1) {
$grid[$y][$x] = "f";
- //Randomly Placed Rocks
+ //Randomly Placed Rocks
} elseif (rand(1, $rockchance) == 2) {
$grid[$y][$x] = "r";
$rocks++;
@@ -261,23 +291,194 @@ function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = $grid[0][4] = $numBlocks;
$grid[0][5] = count($teleport);
- //Confirm the map isn't broken to start-out.
- $path = routePath($grid);
+ //Validate map
+ $path = routePath($grid, '', true);
//Only repeat if it's blocked.
} while ($path['blocked'] == true);
return $grid;
}
+//Generates map based on $shape.
+function GenerateShapedMap($shape, $params) {
+
+ //Get width and height.
+ $cols = strlen($shape[0]);
+ $rows = count($shape);
+
+ //Scan for checkpoints.
+ //$checkpoints = 0;
+ //$cpnames = Array("a", "b", "c", "d", "e");
+ //Get the amount of checkpoints on this map.
+ //foreach ($cpnames as $cpt)
+ // if (findTiles($mygrid, $cpt))
+ // $checkpoints++;
+
+ //Confirm params.
+ if ($params['rockchance'])
+ $rockchance = $params['rockchance'];
+ else
+ $rockchance = 10;
+
+ if ($params['checkpoints'])
+ $checkpoints = $params['checkpoints'];
+ else
+ $checkpoints = 0;
+
+ if ($params['teleports'])
+ $teleports = $params['teleports'];
+ else
+ $teleports = 0;
+
+ if ($params['walls'])
+ $walls = $params['walls'];
+ else
+ $walls = 13;
+
+ $mapMatrix[0][0] = $cols;
+ $mapMatrix[0][1] = $rows;
+ $mapMatrix[0][2] = $checkpoints;
+ //set after;
+ $mapMatrix[0][3] = 0;
+ //walls
+ $mapMatrix[0][4] = $walls;
+ $mapMatrix[0][5] = $teleports;
+
+
+ do {
+ $rockcount = 0;
+ $i = 0;
+ if (! is_array($shape))
+ break;
+ foreach ($shape as $row) {
+ $i++;
+ for( $j = 0; $j < $cols; $j++) { //Number of Columns
+ $item = substr($row, $j, 1);
+ if ($item == '?') {
+ if (rand(1, $rockchance) == 1) {
+ $item = 'r';
+ $rockcount++;
+ } else {
+ $item = 'o';
+ }
+ }
+ $mapMatrix[$i][$j] = $item;
+ //echo $item;
+ }
+ //echo "\n";
+ }
+ $path = routePath($mapMatrix, '', true);
+ //echo $path['blocked']."\n";
+ //Only repeat if it's blocked.
+ } while ($path['blocked'] == true);
+
+ //Set rockcount.
+ $mapMatrix[0][3] = $rockcount;
+
+ //print_r ($mapMatrix);
+ return $mapMatrix;
+}
+
+//Inserts a point into a shape-array.
+function insertPoint($array, $new, $target = '?') {
+ //Replaces a random element in $array that matches $target with $new,
+ // if $new is a single character.
+ //If $new is a string, replace a random element for each of $new's characters.
+
+ /*
+ Snap - "the goal is to turn something like:
+ $mymap = Array("s??????f". "s???????f")
+ // into; Array("s???a??f", "s???b???f")
+ after a couple calls to the function."
+ */
+
+ //Getting $array parameters
+ $rows = count($array);
+ $length = strlen($array[0]);
+ $size = $rows * $length;
+
+ //Retrieving all cells == $target from $array
+ //This is more memory intensive, and probably more CPU-so, but far more safe.
+ $targetCells = array();
+
+ for( $i = 0; $i < $size; $i++)
+ {
+ $y = $i % $length; //Get coordinates based on $index
+ $x = (int)($i / $length);
+
+ //echo "<br />index: $i y: $y, x: $x <br />";
+ //echo $array[$x][$y];
+ if($array[$x][$y] == $target)
+ $targetCells[] = $i;
+ }
+
+ //Now that we have a definite selection of cells, we can pick easily with
+ // the only caveat being if there aren't enough $target cells.
+
+ if(strlen($new) > $length)
+ {
+ //There are too many replace requests and not enough free cells.
+ echo "Too many $new characters. No replacements made.<br/>";
+ return $array;
+ }
+
+ //Debug to see what indexes were selected as == $target
+ /*
+ echo "array = ";
+ print_r($array);
+ echo "<br/>";
+ echo "targetCells = ";
+ print_r($targetCells);
+ echo "<br/>";
+ echo "<br/>";
+ */
+
+ while(strlen($new) > 0)
+ {
+ $length = count($targetCells);
+ $indexReplace = rand(0, $length - 1); //Get a random position in $targetCells
+ $indexTarget = $targetCells[$indexReplace]; //Get the index stored in $targetCells
+
+ $y = $indexTarget % strlen($array[0]); //Get coordinates based on $index
+ $x = (int)($indexTarget / strlen($array[0]));
+
+ if($array[$x][$y] == $target) //Shouldn't be necessary, but just in case...
+ {
+ $array[$x][$y] = $new[0]; //We've found a valid target. Replace.
+ $new = substr($new, 1); //Go to the next $new character.
+
+ unset($targetCells[$indexReplace]); //Remove the selected $targetCell.
+ $targetCells = array_values($targetCells); //Reorder the array for no holes.
+
+ continue;
+ }
+ else
+ {
+ //Somehow an invalid target got into our list of valid targets...
+ echo "<br/>";
+ echo "Error in selecting $indexTarget ($x,$y). Replacement stopped on $new[0].<br/>";
+ echo "indexTarget = $indextarget<br/>";
+ echo "indexReplace = $indexReplace<br/>";
+
+ echo "array = ";
+ print_r($array);
+ echo "<br/>";
+ echo "targetCells = ";
+ print_r($targetCells);
+ echo "<br/>";
+ echo "<br/>";
+ return $array;
+ }
+ }
+
+ return $array;
+}
//Turns a mapMatrix into a code - see GenerateMapByCode
function GenerateMapCode($mapMatrix) {
//Iterate through $mapMatrix and generate the code used to save and
// load the map through the database.
- // 0.1 Snap. (added mapsize header data)
- // 0.2 Rex - Added #checkpoints, #rocks, #walls to header data; adjusted loops.
-
$code = ""; //The string to return to the database.
$index = 0; //The current number of tiles from the last tile saved.
@@ -304,12 +505,16 @@ function GenerateMapCode($mapMatrix) { {
//As long as the tile is NOT open, embed it in the code.
$code .= $index.$mapMatrix[$i][$j].'.';
+ //Start from 0 again.
$index = -1;
- //==echo "<br /><b>".$index.$mapMatrix[$i][$j]."</b><br />";
}
$index += 1;
}
}
+ //== Don't need to fill in the last spot.
+ //if ($index > 1) {
+ // $code .= $index.'o.';
+ //}
return $code;
}
@@ -338,7 +543,7 @@ function GenerateMapByCode($code) { $mapMatrix[0][5] = (int)substr($headers[4], 1); //Number of Teleports
//Printing out parameters for debug purposes...
- /*
+ /*
echo "<br />Map Parameters:<br />";
echo "mapMatrix[0][0]: ".$mapMatrix[0][0]."<br />";
echo "mapMatrix[0][1]: ".$mapMatrix[0][1]."<br />";
@@ -346,7 +551,7 @@ function GenerateMapByCode($code) { echo "mapMatrix[0][3]: ".$mapMatrix[0][3]."<br />";
echo "mapMatrix[0][4]: ".$mapMatrix[0][4]."<br />";
echo "mapMatrix[0][5]: ".$mapMatrix[0][5]."<br />";
- */
+ */
//Begin creating our mapMatrix
$t = -1;
$index = 0;
@@ -355,52 +560,21 @@ function GenerateMapByCode($code) { $t++;
$next = substr($splitCode[$index], 0, strlen($splitCode[$index]) - 1);
- if ($next == $t) {
+ //Are we at the next target, if there is one.
+ if ($next == $t AND $next != '') {
+ //Update tile.
$type = substr($splitCode[$index], -1, 1);
$mapMatrix[$i][$j] = $type;
$index++;
+ //Start from 0 again.
$t = -1;
- //echo "type:".$type."<br />";
- //echo "number:".$next."<br />";
- //echo "original:".$splitCode[$index]."<br />";
} else {
$mapMatrix[$i][$j] = 'o'; //Empty Tile
}
- //echo "Value:".$mapMatrix[$i][$j]."<br />";
}
}
-
- //echo "mapMatrix[1][0]: ".$mapMatrix[1][0]."<br />";
- //echo "mapMatrix[1][1]: ".$mapMatrix[1][1]."<br />";
-
return $mapMatrix;
- //Snap Stops
-
- //Iterate through the code and adjust spaces as directed.
- /* UNREACHABLE CODE
- $index = 0;
- for ( $i = 4; $i < count($splitCode); $i++)
- {
- echo "<br />";
-
- $index += (int)$splitCode[$i];
- $type = $splitCode[$i][strlen($splitCode[$i])-1];
-
- //$tile = GetTile($mapMatrix, $index);
- echo "$x = (int)($index / ".$mapMatrix[0][0].");<br />";
- $x = (int)($index / $mapMatrix[0][0]);
- $y = $id % $mapMatrix[0][0];
-
-
- echo "splitCode: ".$splitCode[$i]."<br />";
- echo "Index: ".$index." -- ".$x.",".$y." to ".$type;
- echo "<br />";
-
- $mapMatrix[$x][$y] = $type;
- }
-
- return $mapMatrix; */
}
//Returns a mapMatrix merged with a solution/maze.
@@ -489,8 +663,16 @@ function pastMap($maptype, $daysago) { return $r;
}
-
-
+function findTiles ($mapMatrix, $search) {
+ //print_r ($mapMatrix);
+ for( $i = 1; $i <= $mapMatrix[0][1]; $i++) { //Number of Rows
+ for( $j = 0; $j < $mapMatrix[0][0]; $j++) { //Number of Columns
+ if ($mapMatrix[$i][$j] == $search)
+ $r.= "$j,$i.";
+ }
+ }
+ return $r;
+}
// Returns: ARRAY( blocked, path, start, end )
@@ -512,45 +694,46 @@ function findPath($mapMatrix, $start = '0,1.', $target = 'f') { $y = $v[1];
//Create a handle on the squares around it.
switch($i){
- case 1: $y--; break; //up
- case 2: $x++; break; //right
- case 3: $y++; break; //down
- case 4: $x--; break; //left
+ case 1: $y--; break; //up
+ case 2: $x++; break; //right
+ case 3: $y++; break; //down
+ case 4: $x--; break; //left
}
if ($y < 1 OR $x < 0) continue 1;
//What's there?
switch($mapMatrix[$y][$x]) {
- case $target: //Finishline!
- //Our search is over.
- $r['blocked'] = false;
- $r['path'] = $seed[$key][3].$i;
- $r['start'] = $v[2];
- $r['end'] = "$x,$y";
- return $r;
+ case $target: //Finishline!
+ //Our search is over.
+ $r['blocked'] = false;
+ $r['path'] = $seed[$key][3].$i;
+ $r['start'] = $v[2];
+ $r['end'] = "$x,$y";
+ return $r;
break;
- // Teleports m t g i k
- case "m": case "t": case "g": case "i": case "k":
- $path = $mapMatrix[$y][$x];
-
- case "o": //Available squares
- //!!
- case "s": case "f": //Start and end tiles
+ // Teleports m t g i k
+ case "m": case "t": case "g": case "i": case "k":
+ $path = $mapMatrix[$y][$x];
- case "a": case "b": case "c": case "d": case "e": //Checkpoints too
- case "u": case "n": case "h": case "j": case "l": //Teleport-out towers included!
- //Plant Seed here
- $seed[$index][0] = $x;
- $seed[$index][1] = $y;
- //Save our starting position.
- $seed[$index][2] = $v[2];
- //Save 'PATH'
- $path = $i.$path;
- $seed[$index][3] = $v[3].$path;
- $path = '';
- //Been there, done that.
- $mapMatrix[$y][$x] = null;
- //Move index
- $index++;
+ case "o": //Available squares
+ //!!
+ case "p":
+ case "s": case "f": //Start and end tiles
+
+ case "a": case "b": case "c": case "d": case "e": //Checkpoints too
+ case "u": case "n": case "h": case "j": case "l": //Teleport-out towers included!
+ //Plant Seed here
+ $seed[$index][0] = $x;
+ $seed[$index][1] = $y;
+ //Save our starting position.
+ $seed[$index][2] = $v[2];
+ //Save 'PATH'
+ $path = $i.$path;
+ $seed[$index][3] = $v[3].$path;
+ $path = '';
+ //Been there, done that.
+ $mapMatrix[$y][$x] = null;
+ //Move index
+ $index++;
break;
}
@@ -585,61 +768,61 @@ function GetTile($mapMatrix, $id) //Routes a path through all checkpoints and teleports, returning an array.
// [path] path-string. [blocked] boolean, [moves] int.
-function routePath($mygrid, $start = '') {
+function routePath($mygrid, $start = '', $validate = false) {
- //== This should grab the start positions by scaning the map.
- if ($start == '') {
- for ($i = 1; $i <= $mygrid[0][1]; $i++) {
- $start .= "0,$i.";
- }
- }
+ //Locate the start locations.
+ $start = findTiles($mygrid, "s");
//Checkpoint names
- $cpnames = Array("a", "b", "c", "d", "e");
- //Get the amount of checkpoints on this map.
- $cpcount = $mygrid[0][2];
+ $cpnames = array("a", "b", "c", "d", "e");
- //Add the existing checkpoints to targets.
- for($p = 0; $p < $cpcount; $p++) {
- $target[] = $cpnames[$p];
- }
- //Always need the finish line.
+
+ //Add the existing checkpoints to target array.
+ foreach ($cpnames as $cpt)
+ if (findTiles($mygrid, $cpt))
+ $target[] = $cpt;
+
+ //Our last target is the finish line.
$target[] = 'f';
//Assume that we're not blocked, and raise a red flag later.
$blocked = false;
-
//All possible teleports in play.
- $tpnames = Array('t', 'm', 'g', 'i', 'k');
-
- $tpcount = intval($mygrid[0][5] * .5);
- //Add the existing checkpoints to targets.
- for($p = 0; $p < $tpcount; $p++) {
- $teleport[] = $tpnames[$p];
- }
+ $tpnames = array('t', 'm', 'g', 'i', 'k');
+ //Where there's an in, there's an out.
$teleout['t'] = 'u';
$teleout['m'] = 'n';
$teleout['g'] = 'h';
$teleout['i'] = 'j';
$teleout['k'] = 'l';
- //$r['tparray'] = $teleport;
- //$r['cparray'] = $target;
+ $teleport = array();
+
+ //Find all the existing teleports.
+ foreach ($tpnames as $tpt)
+ if (findTiles($mygrid, $tpt))
+ $teleport[] = $tpt;
+
+ //If validate, add teleport in/out's.
+ if ($validate) {
+ $target = array_merge($target, $teleport);
+ foreach ($teleport as $tin)
+ $target[] = $teleout[$tin];
+ }
//Loop through all the targets.
foreach($target as $t) {
//Path from where we are, to the target.
$p = Findpath ($mygrid, $start, $t);
+ //echo "FP: ".$p['path'];
+ //echo "T: $t";
//It's possible to start from multiple places;
//so mark where we ended up starting from.
if ($r['start'] == '')
$r['start'] = $p['start'];
- //$f = 0;
- //1449
- //2263
do {
//Make sure there is a teleport to search.
if (! is_array($teleport))
@@ -672,10 +855,11 @@ function routePath($mygrid, $start = '') { $outchar = $teleout[$port];
if ($position === false) continue;
- //if ($teleactive[$port] === false) continue;
//Where is the tele $out location.
- $x = Findpath($mygrid, $start, $outchar);
- $out = $x['end'];
+ // == String/array, messy.. needs a bit of changes to fix though.
+ $out = findTiles($mygrid, $outchar);
+ $out = explode(".", $out);
+ $out = $out[0];
if ($x['blocked']) $blocked = true; //Optional?
//New path starting from our out-location.
@@ -696,6 +880,8 @@ function routePath($mygrid, $start = '') { //123 U CORDS U
//123 U CORDS U 2322
$p['path'] .= $z['path'];
+ //Our end point may have been modified.
+ $p['end'] = $z['end'];
$movesoffset -= countmoves($out);
//}
@@ -29,6 +29,14 @@ switch (strtolower($_GET[page])) { require("pages/test.php");
break;
+ case "tutorial":
+ require("pages/tutorial.php");
+ break;
+
+ case "embed":
+ require("pages/embed.php");
+ break;
+
case "about":
require("pages/about.php");
break;
diff --git a/js/mapspecs.js b/js/mapspecs.js index fe58658..17e4a74 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -8,6 +8,9 @@ window.onload = function(){ //document.getElementById('blocksdisplay').innerHTML = "<b>"+blocks+"</b>";
//doSend();
loadSol();
+ if (ischallenge == true) {
+ challengehint();
+ }
}
var solution = new Array();
@@ -274,6 +277,9 @@ function animatePathDone(mapid) { updateDsp(mapid, 'dspScore', htmlscores);
htmlscores = '';
}
+ if (ischallenge == true) {
+ challengecomplete(mapid);
+ }
}
function request_scores_done() {
@@ -624,12 +630,16 @@ function doanimate(x, y, p, c, mapid) { setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"')",rs);
}
-function flashelement(eid, times, color) {
+function flashelement(eid, times, color, speed) {
//alert("exe"+eid);
if (document.getElementById(eid) == undefined) return;
if (!color) {
color = "#FFFF44";
}
+ if (!speed) {
+ speed = 220;
+ }
+ speedon = speed * .5;
//document.getElementById(eid).setAttribute('class', 'no_transition');
var currentclass = document.getElementById(eid).className;
if (document.getElementById(eid).classOrigName != undefined)
@@ -639,17 +649,17 @@ function flashelement(eid, times, color) { document.getElementById(eid).style.backgroundColor = '#000000';
for (var i=0; i<times; i++) {
//Flash bright
- setTimeout("document.getElementById('"+eid+"').style.color = '#000000'", i*220);
- setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+color+"'", i*220);
+ setTimeout("document.getElementById('"+eid+"').style.color = '#000000'", i*speed);
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+color+"'", i*speed);
// setTimeout("document.getElementById('"+mapid+",dspCount').style.fontWeight = 'bold'", i*200);
//Flash out
- setTimeout("document.getElementById('"+eid+"').style.color = ''", (i*220) + 100);
- setTimeout("document.getElementById('"+eid+"').style.backgroundColor = ''", (i*220) + 100);
+ setTimeout("document.getElementById('"+eid+"').style.color = ''", (i*speed) + speedon);
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = ''", (i*speed) + speedon);
// setTimeout("document.getElementById('"+mapid+",dspCount').style.fontWeight = ''", i*200);
}
//setTimeout("document.getElementById('"+eid+"').className = '"+currentclass+"'", (i*220) + 200);
- setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+currentColor+"'", (i*220) + 200);
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+currentColor+"'", (i*speed) + 200);
//document.getElementById(eid).className=currentclass;
//document.getElementById(eid).style.backgroundColor=currentColor;
}
diff --git a/pages/embed.php b/pages/embed.php new file mode 100644 index 0000000..4c1ca68 --- /dev/null +++ b/pages/embed.php @@ -0,0 +1,113 @@ +<?PHP
+htmlHeader();
+?>
+
+<body>
+<script type="text/javascript" src="sounds/script/soundmanager.js"></script>
+
+<?php
+include('./includes/maps.php');
+include('./includes/mapoftheday.php');
+
+include('./includes/datas.php');
+
+
+
+//Get the current day as int.
+$numday = date('w');
+$numday = intval($numday);
+switch ($numday) {
+ case 0:
+ $mapstyle = 'Thirty';
+ break;
+ case 1:
+ $mapstyle = 'Simple';
+ break;
+ case 2:
+ $mapstyle = "ABC's";
+ break;
+ case 3:
+ $mapstyle = 'Teleport Madness';
+ break;
+ case 4:
+ $mapstyle = 'Rocky Maze';
+ break;
+ case 5: //Friday
+ $mapstyle = 'Side to Side';
+ break;
+ case 6: //Saturday
+ $mapstyle = "Seeing Double";
+ break;
+}
+
+$normal = 'Normal';
+$easy = 'Simple';
+$hard = 'Complex';
+
+$today = date('l');
+//if ($today == 'Sunday' OR $today == 'Saturday')
+ //$today = 'Weekend Map';
+//else
+ $today .= "'s";
+$special = "$today $mapstyle";
+
+switch ($_GET['maptype']) {
+ case "normal":
+ case "2":
+ $maptype = 2;
+ $normal = '<b>Normal</b>';
+ break;
+
+ case "hard":
+ case "3":
+ $maptype = 3;
+ $hard = '<b>Complex</b>';
+ break;
+
+ case "day":
+ case "4":
+ $maptype = 4;
+ $special = "<b>$special</b>";
+ break;
+
+ case "easy":
+ case "1":
+ default:
+ $maptype = 1;
+ $easy = '<b>Simple</b>';
+}
+
+$motd = MapOfTheDay($maptype);
+$mapID = $motd['id'];
+$map = $motd['map'];
+$userID = $_SESSION['userID'];
+$date = date("m-d-y");
+//$mergesolution = mergeMapSolution($map, $mysolution);
+$topscores = topScores($motd['id'], 30);
+$topscorediv = "<div id='$mapID,dspScore'>\n$topscores\n</div>";
+$mergesolution = $map;
+
+?>
+<div class="col2" style="text-align: center">
+<?
+echo "$date: <a href='?page=embed&maptype=easy'>Easy</a> | ";
+echo "<a href='?page=embed&maptype=normal'>Normal</a> | ";
+echo "<a href='?page=embed&maptype=hard'>Hard</a> | ";
+echo "<a href='?page=embed&maptype=day'>Special</a>";
+
+echo DisplayMap($mergesolution, $mapID);
+
+$mysolution = getSolution($userID, $mapID);
+$solutiondiv .= "<div id='mapsol' style='visibility:hidden;display:none'>";
+//$solutiondiv .= "<div id='mapsol'>";
+$solutiondiv .= $mapID.":".$mysolution;
+$solutiondiv .= '</div>';
+
+echo $solutiondiv;
+?>
+<a href="http://www.pathery.com">www.pathery.com</a>
+</div>
+<script type="text/javascript">soundManagerInit();</script>
+
+</body>
+</html>
diff --git a/pages/home.php b/pages/home.php index 4a034c3..928a99e 100644 --- a/pages/home.php +++ b/pages/home.php @@ -11,26 +11,70 @@ include('./includes/mapoftheday.php'); include('./includes/datas.php');
+
+
+//Get the current day as int.
+$numday = date('w');
+$numday = intval($numday);
+switch ($numday) {
+ case 0:
+ $mapstyle = 'Thirty';
+ break;
+ case 1:
+ $mapstyle = 'Simple';
+ break;
+ case 2:
+ $mapstyle = "ABC's";
+ break;
+ case 3:
+ $mapstyle = 'Teleport Madness';
+ break;
+ case 4:
+ $mapstyle = 'Rocky Maze';
+ break;
+ case 5: //Friday
+ $mapstyle = 'Side to Side';
+ break;
+ case 6: //Saturday
+ $mapstyle = "Seeing Double";
+ break;
+}
+
+$normal = 'Normal';
+$easy = 'Simple';
+$hard = 'Complex';
+
+$today = date('l');
+//if ($today == 'Sunday' OR $today == 'Saturday')
+ //$today = 'Weekend Map';
+//else
+ $today .= "'s";
+$special = "$today $mapstyle";
+
switch ($_GET['maptype']) {
case "normal":
case "2":
$maptype = 2;
+ $normal = '<b>Normal</b>';
break;
case "hard":
case "3":
$maptype = 3;
+ $hard = '<b>Complex</b>';
break;
case "day":
case "4":
$maptype = 4;
+ $special = "<b>$special</b>";
break;
case "easy":
case "1":
default:
$maptype = 1;
+ $easy = '<b>Simple</b>';
}
//$motd = getMapOfTheDay();
@@ -58,15 +102,16 @@ $mergesolution = $map; <br />
<div class="col1">
- <b>I'm testing letting the path go over the START and FINISH tiles.</b>
- <br /> Have an opinion about this? Let me know!
<p>
- New maps are generated daily at 9:00 PM Pacific Time.
- <br />Maps for <?php echo "$date" ?>:
- <br /><a href='?page=home&maptype=easy'>Simple</a>
- <br /><a href='?page=home&maptype=normal'>Normal</a>
- <br /><a href='?page=home&maptype=hard'>Complex</a>
- <br /><a href='?page=home&maptype=day'>Today's Special</a>
+ <center><strong>News:</strong></center>
+ <strong>We've moved to www.Pathery.com </strong> (look up, you're already there) <strong>You'll need to re-allow your email-address with google.
+ <br />Don't worry- we've saved all your solutions and history - (soon you'll be able to access it too! hehe)</strong> - 09-09-11
+ <br />New maps are generated daily at 9:00 PM Pacific Time.
+ <br /><i>Maps for <?php echo "$date" ?>:</i>
+ <br /><a href='?page=home&maptype=easy'><? echo $easy; ?></a>
+ <br /><a href='?page=home&maptype=normal'><? echo $normal; ?></a>
+ <br /><a href='?page=home&maptype=hard'><? echo $hard; ?></a>
+ <br /><a href='?page=home&maptype=day'><? echo $special; ?></a>
</p>
<? echo $topscorediv; ?>
@@ -85,42 +130,11 @@ if ($_SESSION['accepted'] != 1) { echo "<br />";
-//Get the current day as int.
-$numday = date('w');
-$numday = intval($numday);
-switch ($numday) {
- case 0:
- $mapstyle = 'Thirty';
- break;
- case 1:
- $mapstyle = 'Simple';
- break;
- case 2:
- $mapstyle = "ABC's";
- break;
- case 3:
- $mapstyle = 'Teleport Madness';
- break;
- case 4:
- $mapstyle = 'Rocky Maze';
- break;
- case 5: //Friday
- $mapstyle = 'Side to Side';
- break;
- case 6: //Saturday
- $mapstyle = "ABC's";
- break;
-}
-echo "<br />$date<br /><a href='?page=home&maptype=easy'>Simple</a> | ";
-echo "<a href='?page=home&maptype=normal'>Normal</a> | ";
-echo "<a href='?page=home&maptype=hard'>Complex</a> | ";
-$today = date('l');
-//if ($today == 'Sunday' OR $today == 'Saturday')
- //$today = 'Weekend Map';
-//else
- $today .= "'s";
-echo "<i><b> NEW: </b></i> <a href='?page=home&maptype=day'>$today $mapstyle</a>";
+echo "<br />$date<br /><a href='?page=home&maptype=easy'>$easy</a> | ";
+echo "<a href='?page=home&maptype=normal'>$normal</a> | ";
+echo "<a href='?page=home&maptype=hard'>$hard</a> | ";
+echo "<a href='?page=home&maptype=day'>$special</a>";
echo DisplayMap($mergesolution, $mapID);
@@ -156,7 +170,7 @@ echo $solutiondiv; <br />Send feedback to <a href='mailto:snapems@gmail.com'>snapems@gmail.com</a> (or IM me if you know me).
<br />We've been aptly implementing changes from feedback.
<br />This game is being adjusted, some 'rules' may change.
- <br />Copyright © 2011 Snapems.com
+ <br />Copyright © 2011 www.pathery.com
</div>
diff --git a/pages/login.php b/pages/login.php index c730846..1c16fe8 100644 --- a/pages/login.php +++ b/pages/login.php @@ -39,7 +39,9 @@ try { //I know just where to put this stuff!
require './includes/db.inc.php';
//Unless I already have this information...
- $sql = "SELECT `ID`, `isAdmin` FROM `users` WHERE `openID` = '$claimedid'";
+ //* Modify this to WHERE `email`
+ $sql = "SELECT `ID`, `isAdmin`, `openID` FROM `users` WHERE `email` = '$email'";
+ //$sql = "SELECT `ID`, `isAdmin` FROM `users` WHERE `openID` = '$claimedid'";
$result = mysql_query($sql);
$_SESSION['isAdmin'] = false;
@@ -51,6 +53,19 @@ try { if (mysql_result($result, 0, 'isAdmin') == 1)
$_SESSION['isAdmin'] = true;
+ //TEMPORARY CODE
+ //Check openID; and update it if necessary
+ if (mysql_result($result, 0, 'openID') == $claimedid) {
+ //Don't need to do anything
+ } else {
+ //Update the OpenID Code
+ $sql = "UPDATE `users`
+ SET `openID` = '$claimedid'
+ WHERE `ID` = '$userID'";
+ mysql_query($sql);
+ }
+ // </TEMPORARY CODE>
+
//I last-see you now!
$sql = "UPDATE `users`
SET `dateLogin` = NOW()
@@ -96,7 +111,7 @@ try { $two = MD5($one.$salt);
$three = MD5($pepper.$two);
- $expire = time() + (7 * 24 * 60 * 60);
+ $expire = time() + (31 * 24 * 60 * 60);
setcookie("userID", $userID, $expire);
setcookie("doLogin", "yes", $expire);
setcookie("auth", $three, $expire);
diff --git a/pages/tutorial.php b/pages/tutorial.php new file mode 100644 index 0000000..3ce0d06 --- /dev/null +++ b/pages/tutorial.php @@ -0,0 +1,116 @@ +<?PHP
+htmlHeader();
+?>
+<body>
+<?php
+topbar($Links);
+?>
+
+<script type="text/javascript" src="sounds/script/soundmanager.js"></script>
+
+<?
+$requiredmoves = '18';
+?>
+
+<script type="text/javascript">
+ischallenge = true;
+
+function challengecomplete(mapid) {
+ var moves = mapjson[mapid].moves;
+
+ if (moves == <? echo $requiredmoves; ?>) {
+ flashelement('nextbtn', 15, null, 400);
+ updateDsp(1, 'instructions', 'Great Job!<br />Lets move on to the next shall we?')
+ } else {
+ //challengehint();
+ updateDsp(1, 'instructions', 'Place some walls<br />What would make it travel the longest?')
+ flashelement('1,instructions', 2, '#cce', 700);
+ setTimeout("flashelement('1,3,5', 10, '#cce', 760);", 1500);
+ setTimeout("flashelement('1,4,6', 10, '#cce', 760);", 1500);
+ }
+}
+
+function challengehint() {
+ //setTimeout("flashelement('1,3,5', 10, '#cce', 620);", 100);
+ //setTimeout("flashelement('1,4,6', 10, '#cce', 620);", 100);
+ setTimeout("flashelement('1,btn', 6, '#ee4', 620);", 1500);
+ setTimeout("flashelement('1,instructions', 3, '#cce', 620);", 700);
+ //updateDsp(mapid, element, data) {
+}
+
+
+</script>
+
+<?php
+include('./includes/maps.php');
+
+include('./includes/datas.php');
+
+
+?>
+<div class="col2" style="text-align: center">
+<br /> <br />
+<strong><p id='1,instructions'>
+Press GO!
+<br />
+</p>
+</strong>
+<br />
+<?
+echo "<a href='#'>Previous</a> | <a href='#' id='nextbtn'>Next</a> ";
+
+$challenge1[] = "sooraooof";
+$challenge1[] = "sooorooof";
+$challenge1[] = "sooooooof";
+$challenge1[] = "sooooooof";
+$challenge1[] = "sooooooof";
+
+$myparams['checkpoints'] = 1;
+$myparams['teleports'] = 0;
+$myparams['walls'] = 2;
+
+$map1 = GenerateShapedMap($challenge1, $myparams);
+
+$challenge2[] = "soooraoof";
+$challenge2[] = "sooooroof";
+$challenge2[] = "sooooooof";
+$challenge2[] = "sooroooof";
+$challenge2[] = "soobrooof";
+
+$myparams['checkpoints'] = 2;
+$myparams['teleports'] = 0;
+$myparams['walls'] = 4;
+
+$map2 = GenerateShapedMap($challenge2, $myparams);
+
+$challenge3[] = "soooraoof";
+$challenge3[] = "sooooroof";
+$challenge3[] = "sooooooof";
+$challenge3[] = "sooroooof";
+$challenge3[] = "soobrooof";
+
+$myparams['checkpoints'] = 1;
+$myparams['teleports'] = 0;
+$myparams['walls'] = 4;
+
+$map3 = GenerateShapedMap($challenge3, $myparams);
+
+echo DisplayMap($map1, 1);
+echo "<br />";
+echo "<br /><center>map2</center>";
+echo "<br />";
+//echo DisplayMap($map2, 2);
+
+//$mysolution = getSolution($userID, $mapID);
+//$solutiondiv .= "<div id='mapsol' style='visibility:hidden;display:none'>";
+//$solutiondiv .= "<div id='mapsol'>";
+//$solutiondiv .= $mapID.":".$mysolution;
+//$solutiondiv .= '</div>';
+
+//echo $solutiondiv;
+?>
+</div>
+<script type="text/javascript">soundManagerInit();</script>
+
+</body>
+</html>
|