| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- // package section -- типовая секция работы части игры (банк, арсеал и т.п.)
- package section
- import (
- "fmt"
- "log"
- "wartank/pkg/components/lst_string"
- "wartank/pkg/components/section/count_time"
- "wartank/pkg/components/section/section_mode"
- "wartank/pkg/types"
- )
- /*
- Базовый объект игры -- секция.
- Основа множества зданий игры.
- */
- // Section -- секция игры
- type Section struct {
- countDown types.ICountTime // Обратный отсчёт до окончания работы режима
- mode types.IMode // Объект режима работы
- lstString *lst_string.LstString // Список строк из сети для анализа секции
- }
- // NewSection -- возвращает новую секцию игры
- func NewSection(bot types.IBot, strControl string) (*Section, error) {
- log.Printf("NewSection(): strControl=%q\n", strControl)
- sf := &Section{
- countDown: count_time.NewCountTime(bot),
- mode: section_mode.NewSectionMode(),
- }
- var err error
- sf.lstString, err = lst_string.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
- }
|