Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/JackLance/PuzzleScript in…
Browse files Browse the repository at this point in the history
…to jack-lance

# Conflicts:
#	js/engine.js
#	js/parser.js
Updates export.
  • Loading branch information
Auroriax committed Apr 24, 2021
2 parents 3491920 + 578c309 commit 746e376
Show file tree
Hide file tree
Showing 4 changed files with 1,239 additions and 1,216 deletions.
22 changes: 14 additions & 8 deletions js/compiler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

'use strict';


Expand Down Expand Up @@ -654,12 +655,10 @@ function findIndexAfterToken(str,tokens,tokenIndex){
function processRuleString(rule, state, curRules)
{
/*
intermediate structure
dirs: Directions[]
pre : CellMask[]
post : CellMask[]
//pre/post pairs must have same lengths
final rule structure
dir: Direction
Expand Down Expand Up @@ -708,6 +707,7 @@ function processRuleString(rule, state, curRules)
var groupNumber=lineNumber;
var commands=[];
var randomRule=false;
var globalRule=false;

if (tokens.length===1) {
if (tokens[0]==="startloop" ) {
Expand Down Expand Up @@ -754,7 +754,9 @@ function processRuleString(rule, state, curRules)
rigid=true;
} else if (token==='random') {
randomRule=true;
} else if (simpleAbsoluteDirections.indexOf(token) >= 0) {
} else if (token==='global') {
globalRule=true;
}else if (simpleAbsoluteDirections.indexOf(token) >= 0) {
directions.push(token);
} else if (simpleRelativeDirections.indexOf(token) >= 0) {
logError('You cannot use relative directions (\"^v<>\") to indicate in which direction(s) a rule applies. Use absolute directions indicators (Up, Down, Left, Right, Horizontal, or Vertical, for instance), or, if you want the rule to apply in all four directions, do not specify directions', lineNumber);
Expand Down Expand Up @@ -889,7 +891,8 @@ function processRuleString(rule, state, curRules)
rigid: rigid,
groupNumber: groupNumber,
commands: commands,
randomRule: randomRule
randomRule: randomRule,
globalRule: globalRule
};

if (directionalRule(rule_line)===false) {
Expand Down Expand Up @@ -931,7 +934,8 @@ function deepCloneRule(rule) {
rigid: rule.rigid,
groupNumber: rule.groupNumber,
commands:rule.commands,
randomRule:rule.randomRule
randomRule:rule.randomRule,
globalRule:rule.globalRule
};
return clonedRule;
}
Expand Down Expand Up @@ -1503,7 +1507,6 @@ function absolutifyRuleCell(forward, cell) {
LEFT parseInt('0', 2);
RIGHT parseInt('0', 2);
? parseInt('', 2);
*/

var dirMasks = {
Expand All @@ -1521,7 +1524,6 @@ var dirMasks = {

function rulesToMask(state) {
/*
*/
var layerCount = state.collisionLayers.length;
var layerTemplate = [];
Expand Down Expand Up @@ -1797,8 +1799,9 @@ function collapseRules(groups) {
newrule.push(oldrule.groupNumber);
newrule.push(oldrule.rigid);
newrule.push(oldrule.commands);
newrule.push(oldrule.randomRule);
newrule.push(oldrule.randomRule);
newrule.push(cellRowMasks(newrule));
newrule.push(oldrule.globalRule);
rules[i] = new Rule(newrule);
}
}
Expand Down Expand Up @@ -2204,6 +2207,9 @@ function printRule(rule) {
if (rule.randomRule) {
result = "RANDOM "+result+" ";
}
if (rule.globalRule) {
result = "GLOBAL "+result+" ";
}
if (rule.late) {
result = "LATE "+result+" ";
}
Expand Down
Loading

0 comments on commit 746e376

Please sign in to comment.