Class: Accountant

accountant-class~Accountant

new Accountant(announcer, config)

The accountant handles pricing, profits vs investments and rendering this data to the DOM
Parameters:
Name Type Description
announcer object Announcer instance, handles communication between objects
config object config object
Source:

Members

investments :array

Type:
  • array
Source:
Example

Example of this.investments structure

[
  {
    "id": "Rope",
    "number": 750,
    "amount": 1
  },
  {
    "id": "Bomb",
    "number": 750,
    "amount": 3
  }
]

profits :array

Type:
  • array
Source:
Example

Example of this.profits structure

[
  {
    "id": "Large Ruby",
    "number": 1600,
    "amount": 1
  },
  {
    "id": "Small Ruby",
    "number": 400,
    "amount": 1
  },
  {
    "id": "Stack of Gold Bars",
    "number": 1500,
    "amount": 2
  }
]

Methods

findNumber(category, id) → {object|undefined}

Search this[category] for specific price according to type of item
Parameters:
Name Type Description
category string
id string
Source:
See:
Returns:
reference to found object
Type
object | undefined

invest(data)

Log investment
Parameters:
Name Type Description
data object
Properties
Name Type Description
id string consumable id
calculatedPrice number consumable price
Source:

profit(data)

Log profit
Parameters:
Name Type Description
data object
Properties
Name Type Description
id string treasure id
calculatedPrice number treasure price
Source:

publish() → {module:announcer-class~publishData}

Returns object used by Announcer to subscribe and/or update objects
Source:
Returns:
Type
module:announcer-class~publishData

render()

Render investments, profits and total to DOM
Source:

resetAllAmounts()

Resets all amounts of items back to 0, renders and tells announcer to deselectAllItems
Source:
See:

updatePrice(specs)

Update price of item according to new price Render new price
Parameters:
Name Type Description
specs object
Properties
Name Type Description
category string 'profits' or 'investments'
id string type of Treasure or Consumable
number number Price
Source: