Code Monkey home page Code Monkey logo

Comments (2)

Longwelwind avatar Longwelwind commented on July 19, 2024

A small part of the stat system is already available in the game, actually, but it's not 100% polished, thus why it's hidden.

If you want to enable it, put this in the Javascript script of your story (Click on the name of your story on the bottom-left, then "Edit story Javascript"):

window.config = {
  "enableStats": true,
  "stats": [
    {
      name: "Strength"
    },
    {
      name: "Dexterity"
    },
    {
      name: "Intelligence"
    }
  ]
};

You can of course change the list of available stats by adding or removing elements in the list.

You have access to those methods to interact with the stats (keep in mind that a stat cannot be lower than 0):

character.addStat("Strength", 4); // Add 4 to the `Strength` stat
character.removeStat("Intelligence", 10); // Removes 10 to the `Intelligence` stat (not lower than 0)
character.setStat("Intelligence", 10); // Set the `Intelligence` stat to 10
character.getStat("Strength"); // Returns the amount of points in the `Strength` stat
character.hasStat("Dexterity", 8); // Returns `true` if the character has at least 8 in the `Dexterity` stat, `false` otherwise

For example:

The merchant must have sold a lot of goods today, as his purse looked full

<% if (character.hasStat("Dexterity", 6)) { %>
  [[Steal the purse of the merchant|Steal]]
<% } else { %>
  It'd be too hard to steal without being seen.
<% } %>

from adventures.

nobody31 avatar nobody31 commented on July 19, 2024

The stats are working, but always appear to be 0, can you fix it ? Thanks.

from adventures.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.