darkf / darkfo

DarkFO, a post-nuclear RPG remake (of Fallout 2)
Apache License 2.0
135 stars 12 forks source link

ES6 related refactoring #126

Closed Allsimon closed 6 years ago

Allsimon commented 6 years ago

Hello,

This PR introduces two minor changes:

I left some var as is in a few places as they might be bugs indicators.

For exemple, in lightmap.ts line 376:

        var v44, v4c, v38, v34, v28, v1c, v28;

The second v28 might be a failed copy pasta (benign) or a failed refactoring (dangerous)

darkf commented 6 years ago

Neat, been meaning to do this myself for a while (current approach has been to just use ES6 in code I touch at time time.)

One thing I notice in the diff is that the indentation changes/breaks, not sure if that's due to your editor or if the input source was just misusing tabs/spaces, but it looks mismatched.

Other than that (if it is a tab/space mismatch I guess I'd better run a tab->spaces formatter), if it does not change semantics it should be fine.

Allsimon commented 6 years ago

Well spotted, IntelliJ has hidden it nicely. Some files (char.ts) use four spaces, some use tabs (audio.ts) and some use both (vm.ts is really weird).

I can use an automatic reformatter, which style do you prefer ?

darkf commented 6 years ago

4 spaces for sure. Sorry about that, I've been meaning to make it consistent for a while now (historically I used Sublime as my editor which defaulted to tabs, but I usually set spaces, although it mis-interpreted them or I forgot sometimes, so it ended up with a mix of both... :P)

Allsimon commented 6 years ago

4 spaces everywhere ! :)

I wanted to enhance the combat system a bit, but I'm not really sure where to begins. I've seen some articles such as http://fallout.wikia.com/wiki/Fallout_combat or https://fallout.gamepedia.com/Fallout_and_Fallout_2_combat . Is there a better documentation somewhere ?

darkf commented 6 years ago

Depends what you're looking for, here are some formulas, there are damage calculations, etc. For anything more specific there's usually some resources found by googling, or in the worst case it can be RE'd or approximated.

Basic ranged/melee combat works AFAIK (minus critical effects, which are registered but don't do anything), throwing doesn't work yet (it's a bit silly), and probably some special weapons like the flamethrower don't work.

I'll review this later to make sure nothing changed semantically, thanks a bunch.

Allsimon commented 6 years ago

Thanks, I'm going to have to read a bunch of things before being useful :)

In the meantime, I added some really minor changes (use LF everywhere instead of CRLF).

darkf commented 6 years ago

So for this:

The whitespace change is good (didn't check all of it, assume you just ran a formatter over it.)

Allsimon commented 6 years ago

Same for the let mapAreas: AreaMap | null = null; I think T|null is more compact/legible than T | null (although I wish ts had built-in syntax for nullable types like it does for undefined.) In general I'd recommend (for any project) that you cleanly split different formatting changs into multiple commits.

Sorry, auto-formatter kicked in :/. I just removed them

info.numFrames-1 -> info.numFrames - 1

This rule is hard to enforce consistently. const sx = 4752 + (32 * y) - (48 * x); should be const sx = 4752+(32*y)-(48*x); ?

I think the tsconfig is like that because it makes it easier to exclude files, and IIRC something screwy with file order.

I thought you excluded files by removing them from the html files. I didn't notice any regressions and I think the typescript compiler would have thrown something if he couldn't compile.

MaxDesiatov commented 6 years ago

any updates on this? I was looking to contribute to darkfo, obviously more comfortable with ES6, so thinking whether it makes sense to fork from darkf/darkfo or Allsimon/darkfo?

darkf commented 6 years ago

Sorry for not getting around to this sooner, I was quite buy and then I kind of forgot about it!

So this is my plan for now:

Basically, keep the tabs->spaces, const/let, and tsconfig/gitignore, but please drop the extra formatting for the moment until I can find the right autoformatter settings

@maxdesiatov It already is ES6 with some ES2017 features (still migrating a lot of the code over to newer practices though), this is just formatting.

darkf commented 6 years ago

Haven't heard back on this so closing for now. I went ahead and converted the code over to using spaces, so that step is done at least. I don't quite like the way autoformatters are so rigid with being consistent in every single context...