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

›Guida

Guida

  • Introduzione
  • Creare la tua torre
  • Aggiungere livelli
  • Definire le abilità
  • Definendo le Unità
  • Refactoring
  • Test
  • Pubblicare

API creatore

  • API relative allo spazio
  • API dell'unità
Translate

Aggiungere livelli

Un livello è un altro oggetto JavaScript:

const Level1 = {
  // Level definition.
};

Cominciamo scrivendo una descrizione e un suggerimento per il nostro livello:

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.",
};

Dobbiamo anche definire due numeri: il tempo bonus e il punteggio ace. Il tempo bonus viene guadagnato dal giocatore a seconda di quanto velocemente completa il livello (viene diminuito turno dopo turno fino a raggiungere lo zero). Il punteggio ace, invece, viene usato per calcolare il voto ottenuto per il livello (solo in modalità epica). Qualsiasi punteggio maggiore o uguale al punteggio ace otterrà una S. Aggiungiamo questi numeri:

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,
};

Questi due numeri dovranno essere perfezionati testando la torre in gioco. Per questa guida, lo abbiamo già fatto.

La prossima cosa da fare è definire il piano del livello, a partire dalle sue dimensioni:

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,
    },
  },
};

Poi, abbiamo bisogno di posizionare le scale in modo che il Guerriero possa passare al prossimo livello:

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,
    },
  },
};

Parlando del guerriero, definiamo il Guerriero per questo livello:

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',
      },
    },
  },
};

Fatto questo, il livello è completo. Ma prima di continuare, definiamo un altro livello:

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',
      },
    },
  },
};

Poiché le cose iniziano a diventare sempre più impegnative per il giocatore, questa volta abbiamo aggiunto un indizio. Gli indizi sono opzionali e vengono mostrati solo su richiesta.

Ora dobbiamo aggiungere questi due livelli alla torre. I livelli vengono aggiunti all'elenco levels della torre:

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

Magnifico! Ma come avrai notato, abbiamo istruito il giocatore a usare warrior.attack(), warrior.feel(), and warrior.walk() ma non abbiamo insegnato al Guerriero come fare tutto questo. Allora facciamolo!

← Creare la tua torreDefinire le abilità →
WarriorJS Docs
Docs
PlayerMaker
Community
SpectrumTwitterFollow WarriorJS on Twitter
More
DonateGitHubStar