add move range for token
See original GitHub issueI am adding move range for token, I suppose it is a common function for hex grid game. here is how it look like
for now, I just simply put the highlight and range calculation methods in hex. Before I wanna submit PR, I found there must be a activeId alike props to indicate which token is currently selected when it comes multi-token… I was struggling with the multi-token things.
My thought is manage the activeToken id state in hex state, add selectToken methods as follow, but I am not sure how to update activeToken id immediately.
_selectToken(target) {
let tokens = this.props.children, index = 0;
const coordinate = `${target.x},${target.y},${target.z}`;
if(Array.isArray(tokens)) {
tokens.forEach((token) => {
const {x, y, z} = token.props;
console.warn(`multi token, curToken xyz: ${x}, ${y}, ${z}, clicked@:${coordinate}`);
if (x === target.x && y === target.y && z === target.z)
this.setState({ activeId: index });
index += 1;
});
// because setState is async.. activeId would be updated @nextClicked..
console.warn(`activeToken id: ${this.state.activeId}`);
return tokens[this.state.activeId];
} else {
// handle single token..
}
}
I am not experienced in React…Any suggestion @nicolodavis , thx !
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
add move range for token · Issue #156 - GitHub
I am adding move range for token, I suppose it is a common function for hex grid game. here is how it look...
Read more >Token movement limits? : r/Roll20 - Reddit
If you just want to have a reminder of movement range, you could just add an aura of the appropriate size to the...
Read more >Adding, replacing, moving and removing nodes
Adding new nodes is called "bootstrapping". The num_tokens parameter will define the amount of virtual nodes (tokens) the joining node will be assigned ......
Read more >FG Academy Presents: FGU Token Movement - YouTube
Fantasy Grounds Unity Token Movement : Controlling the movement of players and NPC's as the host.We now have live streaming simultaneously ...
Read more >Adding or replacing single-token nodes | Apache Cassandra 2.2
Existing nodes can keep their existing token assignments, and new nodes are assigned tokens that bisect (or trisect) the existing token ranges.
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 Free
Top 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
setState
can also take a function As its second argument, and you are guaranteed this function will not be called until after the state update happens, I think that’s what your looking for?Closing this for lack of activity.