Get returns a pointer to the item in the given slot, or nil for an unrecognized slot type. This is the single place that maps an ItemType to a Worn struct field; add new slots here and nowhere else.
(slot items.ItemType)
| 19 | // unrecognized slot type. This is the single place that maps an ItemType to a |
| 20 | // Worn struct field; add new slots here and nowhere else. |
| 21 | func (w *Worn) Get(slot items.ItemType) *items.Item { |
| 22 | switch slot { |
| 23 | case items.Weapon: |
| 24 | return &w.Weapon |
| 25 | case items.Offhand: |
| 26 | return &w.Offhand |
| 27 | case items.Head: |
| 28 | return &w.Head |
| 29 | case items.Neck: |
| 30 | return &w.Neck |
| 31 | case items.Body: |
| 32 | return &w.Body |
| 33 | case items.Belt: |
| 34 | return &w.Belt |
| 35 | case items.Gloves: |
| 36 | return &w.Gloves |
| 37 | case items.Ring: |
| 38 | return &w.Ring |
| 39 | case items.Legs: |
| 40 | return &w.Legs |
| 41 | case items.Feet: |
| 42 | return &w.Feet |
| 43 | } |
| 44 | return nil |
| 45 | } |
| 46 | |
| 47 | // Set places item into the given slot. Does nothing for an unrecognized slot. |
| 48 | func (w *Worn) Set(slot items.ItemType, item items.Item) { |
no outgoing calls