package main

type levelPacks struct {
	packs map[string]levelPack
	order []string
}

func newLevelPacks() *levelPacks {
	return &levelPacks{map[string]levelPack{}, nil}
}

func (p *levelPacks) Add(id string, pack levelPack) {
	p.order = append(p.order, id)
	p.packs[id] = pack
}

func (p *levelPacks) ByID(id string) levelPack { return p.packs[id] }

func (p *levelPacks) FirstPackID() string {
	if p.Len() == 0 {
		return ""
	}
	return p.order[0]
}

func (p *levelPacks) Len() int { return len(p.order) }

func (p *levelPacks) LenLevels() int {
	var cnt int
	for _, pack := range p.packs {
		cnt += pack.Len()
	}
	return cnt
}

func (p *levelPacks) MustSelect() bool { return p.Len() != 1 }
