MatrixArea* AreaCombat::createArea(const std::list<uint32_t>& list, uint32_t rows) { uint32_t cols; if (rows == 0) { cols = 0; } else { cols = list.size() / rows; } MatrixArea* area = new MatrixArea(rows, cols); uint32_t x = 0; uint32_t y = 0; for (uint32_t value : list) { if (value == 1 || value == 3) { area->setValue(y, x, true); } if (value == 2 || value == 3) { area->setCenter(y, x); } ++x; if (cols == x) { x = 0; ++y; } } return area; }
MatrixArea* AreaCombat::createArea(const std::list<uint32_t>& list, uint32_t rows) { uint32_t cols = list.size() / rows; MatrixArea* area = new MatrixArea(rows, cols); uint32_t x = 0; uint32_t y = 0; for(std::list<uint32_t>::const_iterator it = list.begin(); it != list.end(); ++it) { if(*it == 1 || *it == 3) area->setValue(y, x, true); if(*it == 2 || *it == 3) area->setCenter(y, x); ++x; if(cols == x) { x = 0; ++y; } } return area; }