Resolve codefactor

This commit is contained in:
Waiting Idly 2021-06-16 00:04:11 -07:00
parent 13ecc4ae03
commit beb368e324
7 changed files with 60 additions and 52 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
.idea
node_modules
.eslintrc.js
package-lock.json
package-lock.json
playfab.js

View File

@ -82,7 +82,7 @@ Vue.component("time-study", {
return this.eternityChallengeRunning ? "o-time-study-eternity-challenge--running" : "";
},
config() {
return {...this.study.config, formatCost: value => (value >= 1e6 ? format(value) : formatInt(value))};
return { ...this.study.config, formatCost: value => (value >= 1e6 ? format(value) : formatInt(value)) };
}
},
methods: {

View File

@ -50,16 +50,7 @@ Vue.component("new-ui", {
const isIC8Running = InfinityChallenge(8).isRunning;
const isChallengePowerVisible = isC2Running || isC3Running || isIC6Running || isIC8Running;
this.isChallengePowerVisible = isChallengePowerVisible;
if (isChallengePowerVisible) {
const powerArray = [];
if (isC2Running) powerArray.push(`Production: ${formatPercents(player.chall2Pow, 2, 2)}`);
if (isC3Running) powerArray.push(`First dimension: ${formatX(player.chall3Pow, 3, 4)}`);
if (isIC6Running) powerArray.push(`Matter: /
${format(new Decimal(1).timesEffectOf(InfinityChallenge(6)), 2, 2)}`);
if (isIC8Running) powerArray.push(`Production: /
${format(new Decimal(1).timesEffectOf(InfinityChallenge(8)).reciprocal(), 2, 2)}`);
this.challengePower = powerArray.join(", ");
}
if (this.isChallengePowerVisible) updateChallengePower();
this.isInMatterChallenge = Player.isInMatterChallenge;
if (this.isInMatterChallenge) {
@ -95,6 +86,16 @@ Vue.component("new-ui", {
this.bigCrunch = endOfChallenge ||
(Time.thisInfinity.totalMinutes > 1 && Time.bestInfinityRealTime.totalMinutes > 1);
},
updateChallengePower() {
const powerArray = [];
if (isC2Running) powerArray.push(`Production: ${formatPercents(player.chall2Pow, 2, 2)}`);
if (isC3Running) powerArray.push(`First dimension: ${formatX(player.chall3Pow, 3, 4)}`);
if (isIC6Running) powerArray.push(`Matter: /
${format(new Decimal(1).timesEffectOf(InfinityChallenge(6)), 2, 2)}`);
if (isIC8Running) powerArray.push(`Production: /
${format(new Decimal(1).timesEffectOf(InfinityChallenge(8)).reciprocal(), 2, 2)}`);
this.challengePower = powerArray.join(", ");
},
updateCelestial() {
if (Teresa.isRunning) this.currCelestial = "Teresa's";
else if (Effarig.isRunning) this.currCelestial = "Effarig's";

View File

@ -8,7 +8,7 @@ const AUTOMATOR_BLOCKS_COMPARISON_CURRENCIES = [
];
const AUTOMATOR_BLOCKS_RESETS = ["INFINITY", "ETERNITY", "REALITY"];
const automator_blocks = [
const automatorBlocks = [
{
cmd: "WAIT",
targets: [...AUTOMATOR_BLOCKS_COMPARISON_CURRENCIES, ...AUTOMATOR_BLOCKS_RESETS],
@ -78,22 +78,22 @@ const automator_blocks = [
];
const automatorBlocksMap = automator_blocks.mapToObject(b => b.cmd, b => b);
const automatorBlocksMap = automatorBlocks.mapToObject(b => b.cmd, b => b);
function findAutomatorBlockByName(name) {
return automator_blocks.find(b => b.cmd === name);
return automatorBlocks.find(b => b.cmd === name);
}
Vue.component("automator-blocks", {
data() {
return {
blocks: automator_blocks
blocks: automatorBlocks
};
},
methods: {
clone(block) {
let b = {
const b = {
...block,
id: UIID.next()
};

View File

@ -77,6 +77,6 @@ const Async = {
remaining = this.runForTime(fun, remaining, config);
if (config.asyncProgress) config.asyncProgress(maxIter - remaining);
} while (remaining > 0);
if (config.asyncExit) config.asyncExit()
if (config.asyncExit) config.asyncExit();
}
};

View File

@ -148,7 +148,7 @@ const AutomatorCommands = ((() => {
return {
target: ctx.PrestigeEvent[0].tokenType.name.toUpperCase(),
inputValue: input,
...automatorBlocksMap["AUTO"]
...automatorBlocksMap.AUTO
};
}
},
@ -241,7 +241,7 @@ const AutomatorCommands = ((() => {
const comparison = B.visit(ctx.comparison);
return {
nest: commands,
...automatorBlocksMap["IF"],
...automatorBlocksMap.IF,
...comparison,
target: comparison.target.toUpperCase()
};
@ -280,7 +280,7 @@ const AutomatorCommands = ((() => {
blockify: ctx => {
const c = ctx.duration[0].children;
return {
...automatorBlocksMap["PAUSE"],
...automatorBlocksMap.PAUSE,
inputValue: c.NumberLiteral[0].image + c.TimeUnit[0].image
};
}
@ -346,8 +346,7 @@ const AutomatorCommands = ((() => {
if (startDilatedEternity(true)) return AUTOMATOR_COMMAND_STATUS.NEXT_TICK_NEXT_INSTRUCTION;
return AUTOMATOR_COMMAND_STATUS.NEXT_TICK_SAME_INSTRUCTION;
},
blockify: () => ({ target: "DILATION", ...automatorBlocksMap["START"]
})
blockify: () => ({ target: "DILATION", ...automatorBlocksMap.START })
},
{
id: "startEC",
@ -376,7 +375,7 @@ const AutomatorCommands = ((() => {
blockify: ctx => ({
target: "EC",
inputValue: ctx.eternityChallenge[0].children.$ecNumber,
...automatorBlocksMap["START"]
...automatorBlocksMap.START
})
},
{
@ -462,7 +461,7 @@ const AutomatorCommands = ((() => {
},
blockify: ctx => ({
inputValue: ctx.$studies.image,
...automatorBlocksMap["STUDIES"]
...automatorBlocksMap.STUDIES
})
},
{
@ -508,7 +507,7 @@ const AutomatorCommands = ((() => {
},
blockify: ctx => ({
inputValue: ctx.$presetIndex,
...automatorBlocksMap["LOAD"]
...automatorBlocksMap.LOAD
})
},
{
@ -525,7 +524,7 @@ const AutomatorCommands = ((() => {
player.respec = true;
return AUTOMATOR_COMMAND_STATUS.NEXT_INSTRUCTION;
},
blockify: () => automatorBlocksMap["RESPEC"]
blockify: () => automatorBlocksMap.RESPEC
},
{
id: "tt",
@ -546,7 +545,7 @@ const AutomatorCommands = ((() => {
},
blockify: ctx => ({
target: ctx.TTCurrency[0].tokenType.name.toUpperCase(),
...automatorBlocksMap["TT"]
...automatorBlocksMap.TT
})
},
{
@ -567,7 +566,7 @@ const AutomatorCommands = ((() => {
},
blockify: () => ({
target: "DILATION",
...automatorBlocksMap["UNLOCK"]
...automatorBlocksMap.UNLOCK
})
},
{
@ -592,7 +591,7 @@ const AutomatorCommands = ((() => {
blockify: ctx => ({
target: "EC",
inputValue: ctx.eternityChallenge[0].children.$ecNumber,
...automatorBlocksMap["UNLOCK"]
...automatorBlocksMap.UNLOCK
})
},
{
@ -638,7 +637,7 @@ const AutomatorCommands = ((() => {
if (ctx.comparison) {
return {
nest: commands,
...automatorBlocksMap["UNTIL"],
...automatorBlocksMap.UNTIL,
...comparison,
target: comparison.target.toUpperCase()
};
@ -646,7 +645,7 @@ const AutomatorCommands = ((() => {
return {
target: ctx.PrestigeEvent[0].tokenType.name.toUpperCase(),
nest: commands,
...automatorBlocksMap["UNTIL"]
...automatorBlocksMap.UNTIL
};
}
},
@ -672,7 +671,7 @@ const AutomatorCommands = ((() => {
const comparison = B.visit(ctx.comparison);
return {
nest: commands,
...automatorBlocksMap["WAIT"],
...automatorBlocksMap.WAIT,
...comparison,
target: comparison.target.toUpperCase()
};
@ -701,7 +700,7 @@ const AutomatorCommands = ((() => {
},
blockify: ctx => ({
target: ctx.PrestigeEvent[0].tokenType.name.toUpperCase(),
...automatorBlocksMap["WAIT"]
...automatorBlocksMap.WAIT
})
},
{
@ -724,7 +723,7 @@ const AutomatorCommands = ((() => {
B.visit(ctx.block, commands);
return {
nest: commands,
...automatorBlocksMap["WHILE"],
...automatorBlocksMap.WHILE,
...B.visit(ctx.comparison)
};
}

View File

@ -286,7 +286,7 @@
comparison(ctx) {
super.comparison(ctx);
if (!ctx.compareValue || ctx.compareValue[0].recoveredNode ||
ctx.compareValue.length != 2 || ctx.compareValue[1].recoveredNode) {
ctx.compareValue.length !== 2 || ctx.compareValue[1].recoveredNode) {
this.addError(ctx, "Missing value for comparison");
}
if (!ctx.ComparisonOperator || ctx.ComparisonOperator[0].isInsertedInRecovery) {
@ -367,9 +367,7 @@
cv.children.AutomatorCurrency ? cv.children.AutomatorCurrency[0].tokenType.$getter : () => cv.children.$value
));
const compareFun = ctx.ComparisonOperator[0].tokenType.$compare;
return () => {
return compareFun(getters[0](), getters[1]());
};
return () => compareFun(getters[0](), getters[1]());
}
block(ctx) {
@ -396,7 +394,7 @@
// eslint-disable-next-line no-loop-func
this[cmd.id] = (ctx, output) => {
if (ownMethod && ownMethod !== super[cmd.id]) ownMethod.call(this, ctx, output);
let block = blockify(ctx, this);
const block = blockify(ctx, this);
output.push({
...block,
id: UIID.next()
@ -408,21 +406,30 @@
comparison(ctx) {
const isCurrency = ctx.compareValue.map(cv => Boolean(cv.children.AutomatorCurrency));
// eslint-disable-next-line no-bitwise
if (!(isCurrency[0] ^ isCurrency[1])) {
throw new Error("arbitrary comparisons are not supported in block mode yet");
}
const currencyIndex = isCurrency[0] ? 0 : 1;
const flipped = currencyIndex == 1;
const flipped = currencyIndex === 1;
const valueChildren = ctx.compareValue[1 - currencyIndex].children;
const isDecimalValue = Boolean(valueChildren.$value);
const value = isDecimalValue ? valueChildren.$value.toString() : valueChildren.NumberLiteral[0].image;
let operator = ctx.ComparisonOperator[0].image;
if (flipped) {
switch (operator) {
case ">": operator = "<"; break;
case "<": operator = ">"; break;
case ">=": operator = "<="; break;
case "<=": operator = ">="; break;
case ">":
operator = "<";
break;
case "<":
operator = ">";
break;
case ">=":
operator = "<=";
break;
case "<=":
operator = ">=";
break;
}
}
return {
@ -472,13 +479,13 @@
const tokens = lexResult.tokens;
AutomatorGrammar.parser.input = tokens;
const parseResult = AutomatorGrammar.parser.script()
const parseResult = AutomatorGrammar.parser.script();
const validator = new Validator(input);
validator.visit(parseResult)
if (lexResult.errors.length == 0 && AutomatorGrammar.parser.errors.length == 0 && validator.errors.length == 0) {
const b = new Blockifier()
let blocks = b.visit(parseResult)
return blocks
validator.visit(parseResult);
if (lexResult.errors.length === 0 && AutomatorGrammar.parser.errors.length === 0 && validator.errors.length === 0) {
const b = new Blockifier();
const blocks = b.visit(parseResult);
return blocks;
}
return null;
@ -494,7 +501,7 @@
validator.visit(parseResult);
validator.addLexerErrors(lexResult.errors);
validator.addParserErrors(parser.errors, tokens);
return validator
return validator;
}
AutomatorGrammar.validateLine = validateLine;