Skip to content
Anton Vorobyov edited this page Mar 19, 2015 · 6 revisions

This page lists all the ways which are used to store holder on the Fit instance.

Direct

The most straight-forward container type: just assign holder of corresponding class or None to fit attribute. .ship attribute is likely to be the one you will be using the most:

fit.ship = Ship(11184)
fit.ship = None

Charges on modules also use direct container and work exactly the same way.

List

Ordered collection of holders. Values assigned to some indices may be None, representing, for example, empty slots (which are not occupied by any module). Trailing Nones are always stripped.

.insert(index, value)

Insert value to specified index. Value can be holder or None (to insert empty slots between holders). If index is out of range of the list, fill list with Nones up to specified index and insert value there.

.append(holder)

Append holder to the end of the list.

.place(index, holder)

Put holder to specified index, not changing list outside of this position. If placed outside of list range, fill it with Nones up to specified index and place item in there. Attempt to place holder to index which is already occupied by another holder will raise SlotTakenError.

.equip(holder)

Put holder to first free slot of list - as in, replace first seen None with it, or, if there're no Nones, append it to the end of the list.

.remove(value)

Remove one value from list. Value can be holder, None or index.

.free(value)

Free up one slot - find holder and replace it with None. Value can be holder or index.

.clear()

Clear all contents of the collection.

.holders()

Provides a view over all holders from the list (no None values).

Misc methods

Besides listed methods, list exposes rather standard list methods:

  • .index(value)
  • __getitem__(index)
  • __iter__()
  • __contains__(value)
  • __len__()

Set

Unordered collection of holders.

.add(holder)

Add holder to the set.

.remove(holder)

Remove holder from the set.

.clear()

Clear all contents of the collection.

Misc methods

Standard set methods:

  • __iter__()
  • __contains__(value)
  • __len__()

Restricted set

Same as set, but all holders in set must have unique typeID. Attempt to add holder with duplicate typeID will fail with ValueError.

Modules

This is parent object which holds racks of all modules. It provides only one additional method - view over all racks' holders via .holders() (high rack, med rack, low rack).