package section import ( "fmt" "log" "wartank/pkg/components/counttime" "wartank/pkg/components/lststring" "wartank/pkg/components/section/sectionmode" "wartank/pkg/types" ) /* Базовый объект игры -- секция. Основа множества зданий игры. */ // Section -- секция игры type Section struct { countDown types.ICountTime lstString *lststring.LstString mode types.IMode } // NewSection -- возвращает новый *Section func NewSection(app types.IServer, strControl string) (*Section, error) { log.Printf("NewSection(): strControl=%q\n", strControl) sf := &Section{ countDown: counttime.NewCountTime(app), mode: sectionmode.NewSectionMode(), } var err error sf.lstString, err = lststring.NewLstString(strControl) if err != nil { return nil, fmt.Errorf("NewSection(): in create *LstString, err=\n\t%w", err) } return sf, nil } // Update -- обновляет список строк секции func (sf *Section) Update(lstString []string) error { if err := sf.lstString.Set(lstString); err != nil { return fmt.Errorf("Section.Update(): in set lstString, err=\n\t%w", err) } return nil } // GetLst -- возвращает список строк арсенала func (sf *Section) GetLst() []string { return sf.lstString.Get() } // CountDown -- возвращает объект оставшегося времени func (sf *Section) CountDown() types.ICountTime { return sf.countDown } // ModeCurrent -- текущий режим работы func (sf *Section) ModeCurrent() types.IMode { return sf.mode }