-
-
Notifications
You must be signed in to change notification settings - Fork 554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type
property to every unit
#2441
Conversation
now that `type` exists on all units also created `UnitData` type
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -3927,8 +3977,9 @@ export const unitData = [ | |||
id: 50, | |||
name: 'Shadow Leech', | |||
playable: false, | |||
level: '1', | |||
level: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single quotes missing on this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the single quotes intentional? The only other unit that has a string
level is Dark Priest level: '-'
. All other units have a number
level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seemed lighter and easier to type I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to a number
as it made the Level
type defined in units.ts
cleaner and I think easier to understand.
before : type Level = "-" | 1 | 3 | 2 | 4 | 5 | 6 | 7 | "1"
after: type Level = "-" | 1 | 3 | 2 | 4 | 5 | 6 | 7
This also simplifies type checking once these types are implemented in game.ts
, as now if Level
is a string the only possibility is '-'
versus '-' | '1'
However, it's your call, I'll just wait for clarification and then close this PR
I appreciate the effort, but one important thing about me: I'll never want to go for manual entry data when stuff is simply formula based with like one exception, I see this PR going a bit backwards. We'll be aiming for 150 units in the long run. |
@andretchen0 Hey, what's your take on this PR? Keep in mind my above comment as well... |
Thanks @allmtz for the commit. Keep it up!
I'm not familiar with this part of the codebase. I don't know what to make of it entirely. But since I was asked to comment, here we go (somewhat blindly): On the one hand:
On the other:
To see the problems of "writing down" derived data in action, have a look at the old creatureQueue compared to the new one. The creatureQueue is responsible for ordering creatures in the current and upcoming round. At some point, it was decided that queue should hold arrays of creatures. That meant that any time a creature was created, waited, was delayed, finished a turn, or died, And even when the dev remembered, the "right" code was just extra bookkeeping. It wouldn't need to exist if the data were derived on the fly. As part of the larger picture, a sore point with the current codebase is that it relies on these "you-just-have-to-know" strings. Creature types are one example. E.g.: You want to make a priest. You have to
or
But I'd really like to see the codebase move in the direction of Same thing with abilities. Here's how an ability file begins: But, simplifying is hard. Code structures that got built around the old way of doing things will all need changed, and that'll mean errors and debugging in the short term, but hopefully more and happier developpers in the long term. Just my 2 cents. ✌️😀 |
Got it. I thought this would simplify accessing
I'll open a PR soon implementing the types created from |
That would be great! |
This will simplify code in
game.ts
asunit.type
will no longer need to be dynamically generated. It also makes theCreatureType
type more accurate since it now includes only theunit.type
values that are being used and not all possible combinations ofunit.type