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

›Průvodce

Průvodce

  • Úvod
  • Tvorba vlastní věže
  • Přidávání úrovní
  • Definování schopností
  • Definování jednotek
  • Refactoring
  • Testování
  • Publikování

API tvůrce

  • API pole
  • API jednotky
Translate

Přidávání úrovní

Patro je jen další JavaScript object:

const Level1 = {
  // Level definition.
};

Začněme sepsáním popisu a tipu pro naše patro:

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

Musíme také definovat dvě čísla: časový bonus a ace skóre. Časový bonus získá hráč podle toho, jak rychle dokončí dané patro (je snižován každý tah dokud nedosáhne nuly). Na druhou stranu, ace skóre se používá k ohodnocení patra (pouze v epickém módu). Jakékoli skóre větší než nebo rovno ace skóre dostane ohodnocení S. Přidejme tato čísla:

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

Tyto dvě čísla bude nutné doladit při testování věže. Pro tento návod už je máme hotová.

Dalším krokem je definování hrací plochy, počínaje její velikostí:

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

Následně musíme umístit schody, aby se válečník mohl dostat na další úroveň:

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

Když už mluvíme o válečníkovi, pojďme definovat válečníka pro toto patro:

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

A tak je patro dokončené. Ale než budeme pokračovat, pojďme definovat další patro:

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

Protože věci začaly být pro hráče složitější, přidali jsme nápovědu. Nápovědy jsou nepovinné a zobrazí se pouze na požádání.

Teď musíme tyto dvě patra přidat do věže. Patra jsou přidána do levels array věže:

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

Úžasné! Ale možná jsi si všiml, že jsme hráči řekli, aby volal warrior.attack(), warrior.feel(), a warrior.walk(), i když jsme válečníka nenaučili žádnou z těchto metod. Pojďme na to!

← Tvorba vlastní věžeDefinování schopností →
WarriorJS Docs
Docs
PlayerMaker
Community
SpectrumTwitterFollow WarriorJS on Twitter
More
DonateGitHubStar