Skip to content
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

Feature: Add spirit_type to Spirits #10

Open
bitsoflogic opened this issue Aug 14, 2021 · 0 comments
Open

Feature: Add spirit_type to Spirits #10

bitsoflogic opened this issue Aug 14, 2021 · 0 comments

Comments

@bitsoflogic
Copy link

Just like we have structure_type on the structures, I would like spirit_type on the spirits.

The idea here is to add Flow.js support for the global spirits value. Right now, I cannot create a proper union type because there's way to do disjoint unions:

// This says the keys are type SpiritId and the values are either type TriangleSpirit or type EnemySpirit
declare var spirits: { [SpiritId] : TriangleSpirit | EnemySpirit }


let spirit = spirits[0]
if (spirit.type === 'friend') {  // <========== I want to be able to do this

  // flow.js knows this is MyChosenSpirit, so it won't error when using its method:
  spirit.explode()

}

Keeping with the naming used in spirit.sight, I'd imagine that the type would be: 'friend' | 'enemy'


Flow.js isn't smart enough to filter based on a function like (spirit.id.substring(0, MY_USERNAME.length) === MY_USERNAME).

Possible workaround
As a workaround, I'm going to try adding the type every tick to all spirits (and not running that code through Flow.js)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant