diff options
Diffstat (limited to 'pages/challengeOld.php')
-rw-r--r-- | pages/challengeOld.php | 362 |
1 files changed, 362 insertions, 0 deletions
diff --git a/pages/challengeOld.php b/pages/challengeOld.php new file mode 100644 index 0000000..afb8741 --- /dev/null +++ b/pages/challengeOld.php @@ -0,0 +1,362 @@ +<?php +htmlHeader(array('tutorial'), 'Pathery Challenges', 'Challenges', array('scores')); +?> + +<body> + +<?php +topbar($Links); +?> + +<script src="sounds/script/soundmanager.js"></script> + +<script> +isChallenge = true; + + +function challengeLoad() {} + + +challenge1 = new Object(); +challenge2 = new Object(); +challenge3 = new Object(); +challenge4 = new Object(); +challenge5 = new Object(); + + +challenge1.start = "Welcome to Advanced Training #1. Help for these puzzles will be limited.<br /><i>Goal: 32</i> or more."; +challenge1.help = "If that was wrong, then try the right.<br /><i>Goal: 32</i> or more."; +challenge1.complete = "Great, I hope we discovered some things about the pathing.<br/>Press <b>Next</b>"; + +challenge2.start = "Round 2! What does it do when there's 2 outs?<br><i>Goal: 22</i> or more."; +challenge2.complete = "Yup, you can just block things off when there's more than one. This holds true for checkpoints too.<br/>Press <b>Next</b>"; +challenge2.help = "This might be something you didn't know you could do<br /><i>Goal: 22</i> or more."; + +challenge3.start = "Round 3! We're really getting to know that clock-wise path-priority thing aren't we.<br><i>Goal: 39</i> or more."; +//challenge3.complete = "What did you decide to do with that 4th wall? <br/>Press <b>Next</b>"; +challenge3.complete = "I wonder what you decided to do with that 4th wall... That's it for now. Go play the game! (press home)"; +challenge3.bonus = "Bonus Level unlocked. 'cMeInDtDeLrE'<br/>Press <b>Next</b>"; +challenge3.help = "I believe in this case, less is more.<br><i>Goal: 39</i> or more."; + +challenge4.start = "Teleports are traps you can use to your advantage. See if you can use the teleport to reach 33 moves!<br>Press <b>Go!</b>"; +challenge4.complete = "Well done!<br>Teleports add extra intrigue to the game."; +challenge4.help = "Let's use that teleport to block the way to the <i>A</i>!<br>We can make the path take longer to get to <i>A</i> in the process."; + +challenge5.start = "Now for a difficult one. The goal for this one is 75 moves.<br>Press <b>Go!</b> to check your path."; +challenge5.complete = "Look at you, so pro.<br><a href='home'>Go play the game!</a>"; +challenge5.help = "Try placing the walls as highlighted."; + +function challengeGo(mapid) { + var moves = mapjson[mapid].moves; + var tiles; + + switch (mapid) { + case '1': + if (moves >= 32) { + updateDsp(1, 'instructions', challenge1.complete); + tv.unlock(2); + } else { + updateDsp(1, 'instructions', challenge1.help); + } + break; + + case '2': + if (moves >= 22) { + updateDsp(1, 'instructions', challenge2.complete); + tv.unlock(3); + } else { + updateDsp(1, 'instructions', challenge2.help); + //var tiles = ["2,3,5","2,4,6"]; + //markTiles(tiles); + } + break; + + case '3': + if (moves >=39) { + updateDsp(1, 'instructions', challenge3.complete); + tv.unlock(4); + } else { + updateDsp(1, 'instructions', challenge3.help); + } + break; + + case '4': + if (moves >= 33) { + updateDsp(1, 'instructions', challenge4.complete); + tv.unlock(5); + } else { + updateDsp(1, 'instructions', challenge4.help); + tiles = ["4,1,5","4,2,6","4,3,7","4,4,9"]; + markTiles(tiles); + } + break; + + case '5': + if (moves >= 75) { + updateDsp(1, 'instructions', challenge5.complete); + //Unlock next button. + } else { + updateDsp(1, 'instructions', challenge5.help); + tiles = ["5,1,5","5,2,6","5,3,3","5,4,2","5,3,1"]; + markTiles(tiles); + } + break; + + } +} + + + +function markTiles(tiles) { + for(var i in tiles) { + var tmp = tiles[i]; + setTimeout('document.getElementById("'+tiles[i]+'").style.backgroundColor = "#ccccdd"', i*150 + 900); + } +} + +//TODO: +function challengeWall(mapid) { + //Disable function + return; + //Required walls: + var reqwall = new Array(); + reqwall[0] = "3,5."; + reqwall[1] = "4,6."; + + for(var i in reqwall) { + if (solution[mapid].indexOf(reqwall[i]) == -1) { + //Failed + return; + } + } + updateDsp(1, 'instructions', challenge2.wallstext) +} +function highlightElement(Eid) { +} + + +function startChallenge(mapid) { + //console.log("start challenge", mapid); + switch (mapid) { + case 1: + updateDsp(1, 'instructions', challenge1.start); + var goBtn = document.getElementById('1,btn'); + var interval1 = setInterval(function() { + goBtn.className += ' flash'; + }, 1200), + interval2; + setTimeout(function() { + interval2 = setInterval(function() { + goBtn.className = goBtn.className.replace(' flash', ''); + }, 1200); + }, 600); + var prevHandler = goBtn.onclick; + goBtn.onclick = function() { + clearInterval(interval1); + clearInterval(interval2); + goBtn.className = goBtn.className.replace(' flash', ''); + prevHandler.apply(this, arguments); + } + break; + case 2: + updateDsp(1, 'instructions', challenge2.start); + break; + case 3: + updateDsp(1, 'instructions', challenge3.start); + break; + case 4: + updateDsp(1, 'instructions', challenge4.start); + break; + case 5: + updateDsp(1, 'instructions', challenge5.start); + break; + } +} + +function TutorialView(low, high) { + this.low = low; + this.high = high; + this.cur = low; + //Lock them all. + this.locked = low; + + //Override hack to unlock all the levels. + //this.locked = high; + + this.nextbtn = document.getElementById('nextbtn'); + this.prevbtn = document.getElementById('prevbtn'); + this.interval1 = this.interval2 = null; +} +TutorialView.prototype.showTutorial = function(num) { + for (var i = this.low; i <= this.high; i++) { + var elem = document.getElementById("tut-" + i); + if (elem.className.indexOf('hidden') < 0) + elem.className += 'hidden'; + } + elem = document.getElementById("tut-" + num); + elem.className = elem.className.replace('hidden', ''); + //Is the map after this disabled? + this.nextbtn.className = this.nextbtn.className.replace(' disabled', ''); + if (this.locked <= this.cur) + this.nextbtn.className += ' disabled'; + startChallenge(num); + tv.nextbtn.className = tv.nextbtn.className.replace(' flash', ''); +} +TutorialView.prototype.next = function() { + clearInterval(this.interval1); + clearInterval(this.interval2); + if (this.nextbtn.className.indexOf(' disabled') > -1) + return; + this.showTutorial(++this.cur); + if (this.cur == this.high) { + if (this.nextbtn.className.indexOf('hidden') < 0) + this.nextbtn.className += ' hidden'; + } else { + this.nextbtn.className = this.nextbtn.className.replace(' hidden', ''); + //this.nextbtn.className += ' disabled'; + } + this.prevbtn.className = this.prevbtn.className.replace(' hidden', ''); +} +TutorialView.prototype.prev = function() { + this.showTutorial(--this.cur); + if (this.cur == this.low) { + if (this.prevbtn.className.indexOf('hidden') < 0) + this.prevbtn.className += ' hidden'; + } else + this.prevbtn.className = this.prevbtn.className.replace(' hidden', ''); + this.nextbtn.className = this.nextbtn.className.replace(' hidden', ''); +} +TutorialView.prototype.unlock = function(n) { + if (n > this.locked) { + this.locked = n; + if (this.locked >= this.cur) { + this.nextbtn.className = this.nextbtn.className.replace(' disabled', ''); + this.interval1 = setInterval(function() { + tv.nextbtn.className += ' flash'; + }, 1200); + setTimeout(function() { + tv.interval2 = setInterval(function() { + tv.nextbtn.className = tv.nextbtn.className.replace(' flash', ''); + }, 1200); + }, 600); + } + } + + +} +</script> + +<?php +include('./includes/maps.php'); +//include('./includes/datas.php'); + +//Page Load; +//STAGE 1: +//Intro and Instructions; press go! +//Lightup; Go-button. + +//Go is done animating and GOAL is unachieved. +//STAGE 2: +//Show where walls go, and/or encourage them. +//Lightup; Wall Spots + +//All walls have been placed correctly. +//STAGE 3: +//'That looks good, try pressing Go!' +//Lightup; Go-Button + +//Go is done animating, and goal is achieved: +//STAGE 4: +//Horray! Move on to next - highlight 'Next' +//Lightup; Next-Button + +?> +<div id="tut-wrapper"> + <div style='height:80px;' id='1,instructions'> + Welcome to Advanced Training #1. Help for these puzzles will be limited.<br /><i>Goal: 32</i> or more. + </div> +<? + +//Prepare maps. +$example1[] = "ootooooooooo"; +$example1[] = "oofooooooooo"; +$example1[] = "oooooooooooo"; +$example1[] = "oooooooooooo"; +$example1[] = "oooooooousoo"; + +$myparams['teleports'] = 1; +$myparams['walls'] = 5; +$map1 = GenerateShapedMap($example1, $myparams); + +$challenge2[] = "oooooooou"; +$challenge2[] = "ooooooooo"; +$challenge2[] = "ooooooooo"; +$challenge2[] = "oroooooos"; +$challenge2[] = "ooroooooo"; +$challenge2[] = "ftoooooou"; +$myparams['checkpoints'] = 1; +$myparams['teleports'] = 1; +$myparams['walls'] = 2; +$map2 = GenerateShapedMap($challenge2, $myparams); + +$challenge3[] = "otoooooooooan"; +$challenge3[] = "ooooooooooooo"; +$challenge3[] = "ooooooooooooo"; +$challenge3[] = "ooooooooooooo"; +$challenge3[] = "osuofoooooomo"; + +$myparams['checkpoints'] = 2; +$myparams['teleports'] = 0; +$myparams['walls'] = 4; +$map3 = GenerateShapedMap($challenge3, $myparams); + +$challenge4[] = "suooooaooof"; +$challenge4[] = "sooooooooof"; +$challenge4[] = "sooooooooof"; +$challenge4[] = "sooooooorof"; +$challenge4[] = "soooooootof"; +$myparams['checkpoints'] = 1; +$myparams['teleports'] = 1; +$myparams['walls'] = 4; +$map4 = GenerateShapedMap($challenge4, $myparams); + +$challenge5[] = "soooaobtorf"; +$challenge5[] = "soocrooooof"; +$challenge5[] = "souooooooof"; +$challenge5[] = "sooooooooof"; +$challenge5[] = "sooooooooof"; +$myparams['checkpoints'] = 3; +$myparams['teleports'] = 1; +$myparams['walls'] = 5; +$map5 = GenerateShapedMap($challenge5, $myparams); + +//Display maps. +echo '<div id="tut-1" class="hidden">'; +echo DisplayMap($map1, 1, 'puzzle'); +echo '</div><div id="tut-2" class="hidden">'; +echo DisplayMap($map2, 2, 'puzzle'); +echo '</div><div id="tut-3" class="hidden">'; +echo DisplayMap($map3, 3, 'puzzle'); +echo '</div><div id="tut-4" class="hidden">'; +echo DisplayMap($map4, 4, 'puzzle'); +echo '</div><div id="tut-5" class="hidden">'; +echo DisplayMap($map5, 5, 'puzzle'); +echo '</div>'; + +?> + + <div class="wrapper"> + <a href="javascript:tv.next()" id="nextbtn" class="next disabled">Next</a> + <a href="javascript:tv.prev()" id="prevbtn" class="next hidden">Previous</a> + </div> +</div> + +<script> +var tv = new TutorialView(1, 3); +tv.showTutorial(1); +soundManagerInit(); +</script> + +<?php +htmlFooter(array('tutorial')); +?> |