WarriorJS Docs
  • Joueur
  • Créateur
  • Communauté
  • Français
    • English
    • العربية
    • Català
    • Čeština
    • Deutsch
    • Ελληνικά
    • Español
    • Italiano
    • Polskie
    • Русский
    • Српски језик (Ћирилица)
    • Svenska
    • Türkçe
    • 中文
    • 繁體中文
    • Aidez-nous à traduire
  • GitHub

›Guide

Guide

  • Introduction
  • Créer votre tour
  • Ajoutez des niveaux
  • Définition des capacités
  • Définition des unités
  • Refactoring
  • Test en cours
  • Publication

API constructeur

  • API de l'espace
  • API des unités
Translate

Ajoutez des niveaux

Un niveau est un autre objet JavaScript:

const Level1 = {
  // Level definition.
};

Commençons par écrire une description et une astuce pour notre niveau:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
};

Nous allons aussi définir deux nombres: le bonus de temps et le aceScore. Le bonus de temps est gagné par le joueur en fonction de la vitesse à laquelle il fini le niveau (il diminue à chaque tour jusqu'à atteindre 0). Le aceScore, en d'autres termes, est utilisé pour calculer l’expérience du niveau (en mode épique seulement). Tout score supérieur ou égale aux aceScore donne un rang S. Ajoutons ces nombres:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
  timeBonus: 15,
  aceScore: 10,
};

Ces deux nombres sont à ajuster quand on test la tour. Pour ce tutoriel, nous l'avons déjà fait.

La prochaine chose à faire est de définir le sol du niveau, à commencer par sa taille:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
  timeBonus: 15,
  aceScore: 10,
  floor: {
    size: {
      width: 8,
      height: 1,
    },
  },
};

Maintenant, nous allons positionner les escaliers pour que le Warrior puisse atteindre le prochain niveau:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
  timeBonus: 15,
  aceScore: 10,
  floor: {
    size: {
      width: 8,
      height: 1,
    },
    stairs: {
      x: 7,
      y: 0,
    },
  },
};

En parlent du Warrior, il faut définir sa position dans ce niveau:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
  timeBonus: 15,
  aceScore: 10,
  floor: {
    size: {
      width: 8,
      height: 1,
    },
    stairs: {
      x: 7,
      y: 0,
    },
    warrior: {
      character: '@',
      maxHealth: 20,
      position: {
        x: 0,
        y: 0,
        facing: 'east',
      },
    },
  },
};

Avec ça, le niveau est terminé. Mais avant de continuer, nous allons créer un autre niveau:

const Level2 = {
  description:
    'The cold became more intense. In the distance, you see a pair of deep and blue eyes, a blue that burns like ice.',
  tip:
    "Use `warrior.feel().isEmpty()` to see if there's anything in front of you, and `warrior.attack()` to fight it. Remember, you can only do one action per turn.",
  clue:
    'Add an if/else condition using `warrior.feel().isEmpty()` to decide whether to attack or walk.',
  timeBonus: 20,
  aceScore: 26,
  floor: {
    size: {
      width: 8,
      height: 1,
    },
    stairs: {
      x: 7,
      y: 0,
    },
    warrior: {
      character: '@',
      maxHealth: 20,
      position: {
        x: 0,
        y: 0,
        facing: 'east',
      },
    },
  },
};

Les choses deviennent plus corsées pour le joueur, nous allons donc ajouter des astuces. Les astuces sont optionnelles et n’apparaissent que sur la demande du joueur.

Maintenant, nous devons ajouter ces deux niveaux à la tour. Les niveaux sont ajoutés dans le tableau levels de la tour:

module.exports = {
  name: 'Game of Thrones',
  description:
    'There is only one war that matters: the Great War. And it is here.',
  levels: [Level1, Level2],
};

Super ! Mais comme vous l'avez remarqué, nous apprenons au joueur à appeler warrior.attack(), warrior.feel(), and warrior.walk() mais nous n'avons pas dit au Warrior comment faire ces actions. Faisons-le après !

← Créer votre tourDéfinition des capacités →
WarriorJS Docs
Docs
PlayerMaker
Community
SpectrumTwitterFollow WarriorJS on Twitter
More
DonateGitHubStar