...

Source file src/gitlab.com/tslocum/venture/pkg/template/adventure/inventory.go

Documentation: gitlab.com/tslocum/venture/pkg/template/adventure

     1  package adventure
     2  
     3  type Inventory struct {
     4  	Size  int
     5  	Items []*Item
     6  }
     7  
     8  func (i *Inventory) Add(item *Item) bool {
     9  	if i.Size <= len(i.Items) {
    10  		return false
    11  	}
    12  
    13  	i.Items = append(i.Items, item)
    14  	return true
    15  }
    16  
    17  func (i *Inventory) Contains(item *Item) bool {
    18  	for _, searchItem := range i.Items {
    19  		if searchItem == item {
    20  			return true
    21  		}
    22  	}
    23  	return false
    24  }
    25  

View as plain text