Comments (10)
Hello, could you please give an example of what you want to achieve, or how you are currently doing it?
from warriorjs.
Thanks for quick reply.
Well at the beginning of each level, I would like to find out which wall is closer, left or right. I also want to set the _health to 20 so that it does not use the value from previous level. I also want to set if we already hit wall in this level etc..
from warriorjs.
I think using a constructor for your warrior will fulfill your needs. Something like this:
class Player {
constructor() {
this._health = 20;
this._hasHitWall = false;
}
playTurn(warrior) {
// Cool code
}
}
The Player constructor
will be executed at the beginning of each level, even in Epic mode.
from warriorjs.
And don't use globals! With instance properties you'll be fine :)
from warriorjs.
Yea I am just replacing the globals :) Ok thanks for the idea. Also can I somehow access warrior in constructor?
from warriorjs.
Not directly, but this came to my mind that might solve whatever you want to do with the warrior:
class Player {
constructor() {
this._isFirstTurn = true;
}
playTurn(warrior) {
if (this._isFirstTurn) {
// Do whatever you want with warrior
this._isFirstTurn = false;
}
}
}
It might be ugly but may do the trick ;)
from warriorjs.
Yea I just did that but wanted a cleaner solution :) Thanks a lot for quick responses
from warriorjs.
Dont you plan to deploy this online and let users create their AIs in online editors and then submitting them and compeating with each other?
from warriorjs.
Maybe also let users create new levels to test AIs properly with much more levels. Or generate levels randomly so that AIs cant be created just for known levels but are generally working in whatever level.
from warriorjs.
Yes, deploying a web version of the game is in the roadmap. I encourage you to open new issues with ideas. I'll close this to keep it neat.
Thank you for the support!
from warriorjs.
Related Issues (20)
- Any plans on i18n? HOT 1
- Documentation links are broken in many places HOT 1
- access to newer abilities in previous levels HOT 3
- Connect WarriorJS CLI with warriorjs.com HOT 2
- Add ability to get warrior's max health HOT 3
- brief description on each release HOT 3
- @warriorjs/tower-tick-tick-boom warrior haven't got the "pivot" ability and bashing 'backward' forcedly
- Should the warrior receive more damage when attacked from behind? HOT 1
- Add retro sounds HOT 2
- translate Korean HOT 2
- Korean Translation HOT 3
- Can't access functions from a Unit object
- Watch for Player.js changes and run
- I cannot sign in or create an account for the online platform HOT 2
- When I 'Run' the game after defeated, the state isn't refreshed unless I reload the page for several times HOT 1
- rescue('backward') is undefined HOT 3
- This code is wierdly running HOT 4
- where did constructor() come from and what is it? How does it work and what does it mean? I'm not able to learn anything here HOT 1
- Error: No files matching the pattern "packages/**/src" were found
- Please help me with the algorithm of moves leading to victory in this 9th level on the map "Tick, Tick... Boom!"!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from warriorjs.