I edited the indentation style so it looks like I edited a LOT more than I really did also the commit comparison is really strange, anyways
If you have an if statement that ranges an entire function, for example say
function something(){
if (i > 1){
for (let i in stuff){
lots();
of();
things();
}
}
}
you can fix it like this
function something(){
if (i <= 1){
return;
}
for (let i in stuff){
lots();
of();
things();
}
}
function stuff(){
if (this){
if (that){
do();
}
}
else {
things();
}
}
can also be cut down to (assuming the else block is at the very end and nothing's being returned)
function stuff(){
if (this && that){
do();
return;
}
// you might not want to do this part if you think
// it makes code more unreadable but definitely
// don't nest if statements like that
things();
}
boom now that's a lot easier to read, any time you're nesting if statements
Other than that, if you're getting up to 7-8 lines of indentation and you're repeating code,
it means time to start using helper functions.
Since you're using ES6 classes, you should really never be using var to declare variables.
I didn't know if changing that would cause issues for you in terms of scoping so
I didn't touch anything in order to not break it but you really should be changing it.
Looking at this code, I can't tell why you're using C style loops, and not only that, I don't know what
these numbers mean, why is it 4, why 12? try using range based loops for (let ... in ...) if not ,
using constants is a good idea to not get lost in what's going on.
Fixed some coercion issues with your comparisons.
Other than 1 single case, there's no reason to ever use == or !=, use === and !== to avoid coercion
(the only useful instance I can think of is (something == null) which checks for undefined and null at the same time)
There's a lot of repetition for the blocks, you seem to be inheriting from a single class
but I think you can still cut down the repetition by factoring some code out
I also changed the formatting from spaces to tabs because it was hard to work with
if you want I can change that back tho
There's a chance I might have broken some stuff, I couldn't manage to get the game working on my machine properly
so I'm sorry if I have, I might be able to fix it later if I have time
I didn't really have time to change all of them, I fixed the first 5 ish js files and the base block file.
I can do more later if you fix the code repetition so I don't spend time editing code you're gonna delete
You can see all my comments in the commits tab or by searching for Xetera:
If anything breaks just revert the commit let me know what and I'll try to see what the problem is
Removed lots of unnecessary indentation
If you have an if statement that ranges an entire function, for example say
you can fix it like this
can also be cut down to (assuming the else block is at the very end and nothing's being returned)
boom now that's a lot easier to read, any time you're nesting if statements Other than that, if you're getting up to 7-8 lines of indentation and you're repeating code, it means time to start using helper functions.
Since you're using ES6 classes, you should really never be using
var
to declare variables. I didn't know if changing that would cause issues for you in terms of scoping so I didn't touch anything in order to not break it but you really should be changing it.Looking at this code, I can't tell why you're using C style loops, and not only that, I don't know what these numbers mean, why is it 4, why 12? try using range based loops
for (let ... in ...)
if not , using constants is a good idea to not get lost in what's going on.Fixed some coercion issues with your comparisons. Other than 1 single case, there's no reason to ever use == or !=, use === and !== to avoid coercion (the only useful instance I can think of is (something == null) which checks for undefined and null at the same time)
There's a lot of repetition for the blocks, you seem to be inheriting from a single class but I think you can still cut down the repetition by factoring some code out
I also changed the formatting from spaces to tabs because it was hard to work with if you want I can change that back tho
There's a chance I might have broken some stuff, I couldn't manage to get the game working on my machine properly so I'm sorry if I have, I might be able to fix it later if I have time
I didn't really have time to change all of them, I fixed the first 5 ish js files and the base block file. I can do more later if you fix the code repetition so I don't spend time editing code you're gonna delete
You can see all my comments in the commits tab or by searching for
Xetera:
If anything breaks just revert the commit let me know what and I'll try to see what the problem is