Skip to content

Instantly share code, notes, and snippets.

@kozaru
Created July 24, 2016 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozaru/81cb0bc7177cd89605233303f3e396d1 to your computer and use it in GitHub Desktop.
Save kozaru/81cb0bc7177cd89605233303f3e396d1 to your computer and use it in GitHub Desktop.
JSWarrior 途中 kazutake
jsWarrior.turn = function(warrior) {
// 前に敵がいたら
if(warrior.check() == "enemy") {
   // 敵をアタック
   warrior.attack();
// 前に敵がいなかったら
} else {
    //ヒットポイントが19より小さかったら
   if( warrior.getHealth() < 19){
    // 後ろにあるく
    warrior.walk('backward');
   //それ以外
   } else {
    // 休む
     warrior.rest();
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment