fossasia / labyrinth

FOSSASIA Labyrinth
GNU Affero General Public License v3.0
1.52k stars 154 forks source link

Develop API Documentation #244

Open YashKumarVerma opened 6 years ago

YashKumarVerma commented 6 years ago

Expected results

As new features are added day by day (see stats) , and new additions need references. There must be a detailed documentation about the various functions that are used in designing level, user interactions. inventory,level-complete,level-progress etc

Actual results

There is no reference except to copy from fellows

Steps to reproduce the issue

Would you like to work on this

I can help with some part of it. Members needed

[GitHub forks]()

Steps

Documentation Adv. Task 1/6 API Claimed

Notes

YashKumarVerma commented 6 years ago

Claiming inventory.js api docs

Inventory Mechanism


The inventory mechanism allows user to pick up objects or items from the game by passing over them. The API at present provides three functions for interaction with the mechanism.

The engine by default doesn't allow multiple instances of the same item to be added to inventory.


inventory.add()

This function is used to add an item to the player's inventory. The function accepts an array as parameters, the first index containing the item's name and second containing the object's image.
For instance, the following code snippet adds a bucket to the inventory.

  Player.inventory.add(["bucket","bucket.jpg"]);
  Player.inventory.add(["skull","skull.jpg"]);

inventory.has()

This function is used to check the existence of an item in the player's inventory. The function accepts a string as parameter, which is the item's name.
For instance, the following code snippet returns true if key found.

if(Player.inventory.has("bucket")){
  // dance about in the maze
}

inventory.remove()

This function is used to remove an item from the player's inventory. The function accepts a string as parameter, which is the item's name.

if(Player.inventory.has("coin")){
  ThrowParty();
  Player.inventory.remove(coin);
}
dhruvkumarverma commented 6 years ago

@YashKumarVerma How about working together on building a docs structure ?

YashKumarVerma commented 6 years ago

@dhruvkumarverma , i've already done some advanced stuff on this repo.