etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
BlockStrategy.cpp
[詳解]
1 #include <BlockStrategy.h>
2 
3 using namespace BlockSideBySide;
4 
5 void BlockStrategy::createColorBlockPlace()
6 {
7  for(std::int8_t i = 0; i < BLOCK_NUM; i++) {
8  std::shared_ptr<ColorBlockPlace> blockPlace
9  = std::make_shared<ColorBlockPlace>(ColorArray[i], i);
10  colorBlockPlaceArray[i] = blockPlace;
11  }
12 }
13 
14 void BlockStrategy::putColorBlock()
15 {
17  ipcd.decode(initialPositionCode);
19 
20  for(std::int8_t code : decodedColorBlockCodeList) {
21  std::shared_ptr<ColorBlock> colorBlock = std::make_shared<ColorBlock>();
22  colorBlockPlaceArray[code]->block = colorBlock;
23  }
24 }
25 
26 void BlockStrategy::connectColorBlockPlace()
27 {
28  for(std::int8_t i = 0; i < BLOCK_NUM; i++) {
29  if(i > 3) { // ブロックエリア1行目以外
30  colorBlockPlaceArray[i]->black_line[Direction::NORTH] = colorBlockPlaceArray[i - 4];
31  }
32  if(i < 12) { // ブロックエリア4行目以外
33  colorBlockPlaceArray[i]->black_line[Direction::SOUTH] = colorBlockPlaceArray[i + 4];
34  }
35  if(i % 4 != 0) { // ブロックエリア1列目以外
36  colorBlockPlaceArray[i]->black_line[Direction::EAST] = colorBlockPlaceArray[i - 1];
37  }
38  if(i % 4 != 3) { // ブロックエリア4列目以外
39  colorBlockPlaceArray[i]->black_line[Direction::WEST] = colorBlockPlaceArray[i + 1];
40  }
41  }
42 }
std::vector< std::int8_t > getInitialPositionCodeList()
std::vector< std::int8_t > decodedColorBlockCodeList
Definition: BlockStrategy.h:27