# lucy-forge

> Entity and component definition tool

Latest version **0.5.1** (published 2015-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install lucy-forge
pnpm add lucy-forge
yarn add lucy-forge
bun add lucy-forge
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2015-09-22 |
| First published | 2015-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gaspard Bucher |
| Maintainers | lucidogen |
| Keywords | composition, component, entity, game |

## Links

- npm: https://www.npmjs.com/package/lucy-forge
- Repository: https://github.com/lucidogen/lucy-forge
- Homepage: https://github.com/lucidogen/lucy-forge#readme
- Issues: https://github.com/lucidogen/lucy-forge/issues
- npm.io page: https://npm.io/package/lucy-forge

## Dependencies (1)

- [caller](https://npm.io/package/caller.md) ^1.0.0

## Recent versions

- 0.5.1 (latest) — 2015-09-22
- 0.5.0 — 2015-09-22
- 0.4.0 — 2015-09-09
- 0.3.0 — 2015-09-04
- 0.1.0 — 2015-09-02

## README

# Lucy forge  [![Build Status](https://travis-ci.org/lucidogen/lucy-forge.svg)](https://travis-ci.org/lucidogen/lucy-forge)

Part of [lucidity](http://lucidity.io) project.

Beta software. Until 1.0, API subject to change.

## Entity and component definition tool

lucy.forge is a minimal 'game' or 'feature composition' engine. It's goal is to
foster clean and reusable Javascript code through the extensive use of mixins
and conventions.

## Installation

  ```sh
  npm install lucy-forge --save
  ```

### Usage example:

  ```js
  const forge = require ( 'lucy-forge' )

  // Define a component
  // for auto-loading, the path for this component should be 'Person.js'
  const Person = forge.Component
  ( 'Person'
    // Class methods
  , { // Setup an entity. 'e' is the entity being initialized.
      setup ( e )
      { e._person = {}
        Person.people.push ( e )

        e.bind
        ( 'destroy'
        , function ()
          { Person.peopleCount --
          }
        )
      }

      // This is called once on Component creation. It is used to initialize
      // the component (not an entity). 'this' is the component aka 'class'.
      // Here, this === Person.
    , init ()
      { this.peopleCount = 0
      }

    , count ()
      { return this.peopleCount
      }
    }

    // Methods
  , { person ( name, age )
      { let self = this._person
        self.name = name
        self.age  = age
      }
    }
  )

  // Use the component
  let Person = forge.findComponent ( 'Person' )

  console.log
  ( Person.count () ) // ==> 0

  let player1 = forge.Entity
  ( 'Person'
  , 'Score'
    // #set shortcut
    // same as calling player1.person ( 'John Difool', 34 )
    //                 player1.score  ( 100 )
  , { person: [ 'John Difool', 34 ]  
    , score: 100
    }
  )

  console.log
  ( Person.count () ) // ==> 1
  ```


## Tests

  ```sh
  npm test 
  ```

## Contributing

Please use ['jessy style'](http://github.com/lucidogen/jessy).

Add unit tests for any new or changed functionality.

## Release History

  * 0.5.1 (2015-09-22) Fixed npm readme page.
  * 0.5.0 (2015-09-22) Better #set method, forge.merge.
  * 0.4.0 (2015-09-09) Renaming init to 'setup'. Init is now called on class.
  * 0.3.0 (2015-09-04) API change for forge.Component with class methods.
  * 0.2.0 (2015-09-03) Adding possibility to replace binding.
  * 0.1.0 (2015-09-02) Initial release.

---
_Source: https://npm.io/package/lucy-forge · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
