Browse Source

added AND triggers, updated spoofs1 to use it

Erinn 8 years ago
parent
commit
ad743b69a7
3 changed files with 23 additions and 17 deletions
  1. 7 7
      levels/02 Spoofs/spoofs01.json
  2. 15 7
      phaser.inc.php
  3. 1 3
      todo

+ 7 - 7
levels/02 Spoofs/spoofs01.json

@@ -24,10 +24,10 @@
 		},
 		{
 			id:"Router 1",
-			type:"ManualRouter",
 			ports:3,
 			x:0.5,
 			y:0.4,
+			script:deviceScripts.manualRouter,
 			rules:[
 				{dstip:"Alice", portNum:0},
 				{dstip:"Bob", portNum:1},
@@ -36,10 +36,10 @@
 		},
 		{
 			id:"Router 2",
-			type:"ManualRouter",
 			ports:3,
 			x:0.35,
 			y:0.6,
+			script:deviceScripts.manualRouter,
 			rules:[
 				{dstip:"Bob", portNum:0},
 				{dstip:"Alice", portNum:1},
@@ -48,10 +48,10 @@
 		},
 		{
 			id:"Router 3",
-			type:"ManualRouter",
 			ports:3,
 			x:0.65,
 			y:0.6,
+			script: deviceScripts.manualRouter,
 			rules:[
 				{dstip:"Carol", portNum:0},
 				{dstip:"Alice", portNum:1},
@@ -119,21 +119,21 @@
 			}
 		}
 	],
-	triggers:{
-		t0:{
+	triggers:[
+		{
 			type:"packet",
 			device:"Bob",
 			payload:{
 				network:{srcip:"Carol", dstip:"Bob"}
 			}
 		},
-		t1:{
+		{
 			type:"packet",
 			device:"Router 1",
 			payload:{
 				network:{srcip:"Carol", dstip:"Bob"}
 			}
 		}
-	},
+	],
 	nextLevel:"02 Spoofs/spoofs02.json"
 }

+ 15 - 7
phaser.inc.php

@@ -145,16 +145,24 @@ function update() {
 
 function donePacket() {
 	this.kill();
+	var youWin = true;
+
 	for (var i = 0; i < level.triggers.length; i++) {
 		if (satisfiesTrigger(this, level.triggers[i])) {
-			$.get("./solns.ajax.php?level="+levelid+"&method=win");
-			$("#winner").dialog({
-				title:"You win!",
-				resizable:false,
-				modal:true,
-				buttons:[{text:"Go to the next level", click:function(){ location.href="./?level="+level.nextLevel; }}]
-			});
+			level.triggers[i].completed = true;
 		}
+
+		if (!level.triggers[i].hasOwnProperty("completed")) youWin = false;
+	}
+
+	if (youWin) {
+		$.get("./solns.ajax.php?level="+levelid+"&method=win");
+		$("#winner").dialog({
+			title:"You win!",
+			resizable:false,
+			modal:true,
+			buttons:[{text:"Go to the next level", click:function(){ location.href="./?level="+level.nextLevel; }}]
+		});
 	}
 
 	if (devices[this.dst].hasOwnProperty("script")) {

+ 1 - 3
todo

@@ -5,9 +5,7 @@ blocking
 - convert triggers in level files to arrays
 - update nextLevel in each file
 - update "you win" dialog to handle no nextLevel property
-- fix borders on playback button sprites
-- finish edit packet functionality (only saves dstip/srcip right now)
-- only processes single triggers right now
+- process timing triggers
 - prettier level listing
 - resize game on resize viewport (attempt at this at top of ui.js but it's laggy)
 - 'repeat' packet property