How to get an unit?
See original GitHub issuei read you documentation --> unit.isFriendly() so I wrote this:
let unit = warrior.feel().getUnit();
if(unit.isFriendly()){
warrior.rescue();
}
but the terminal show: Invalid submitted code: Cannot read property ‘isFriendly’ of undefined
My English is not good , can you tell me how to get the unit. thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Unit Vector- Definition, Formula, Example and Solved ...
To find a unit vector with the same direction as a given vector, we divide the vector by its magnitude. For example, consider...
Read more >Unit Vector - Formula, Definition, Caculate, Notation
To find a unit vector with the same direction as a given vector, simply divide the vector by its magnitude. For example, consider...
Read more >How to Buy a Multi-Unit Property
How to Buy a Multi-Unit Property. Purchasing a multi-unit building is a first step for some individuals seeking to start a real estate...
Read more >Unit Testing Tutorial: 6 Best Practices to Get Up To Speed
If you write code that stuffs things into a database or that reads a file from disk, you have not written a unit...
Read more >How to get the unit test method name at runtime from within ...
If you are using NUnit 2.5.7 / 2.6 you can use the TestContext class:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think, essentially - The docs of the ‘APIs’ provide no clear idea of these two relationships to the player/warrior
const unitAPIObject = warrior.feel().getUnit();
const spaceAPIObject = warrior.feel();
It would be even clearer to just put in the instructions that
const space = warrior.feel();
const unit = space.getUnit();
With the inability to log anything to the terminal, it is almost impossible to intuit this.
Hello @383366204!
warrior.feel()
returns a space, so it’s correct calling.getUnit()
on it. However, not all spaces have units on them. You should check if there is a unit before trying to call methods like.isFriendly()
on them.P.S.: When reporting a problem, please try to follow the issue template and provide the data requested in it.