etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
BlockArea.h
[詳解]
1 #ifndef __BLOCK_AREA__
2 #define __BLOCK_AREA__
3 
4 #include <cstdint>
5 #include <list>
6 #include <map>
7 #include <memory>
8 
9 namespace BlockSideBySide {
10  enum struct GameColor { UNKNOWN, RED, YELLOW, BLUE, GREEN };
11 
12  const std::array<GameColor, 16> ColorArray{
17  };
18 
19  enum struct Direction { EAST, NORTH, WEST, SOUTH };
20 
21  class ColorBlock {
22  public:
23  ColorBlock() = default;
25  };
26 
28  public:
29  ColorBlockPlace(GameColor color_, std::int8_t place_cord_)
30  : color(color_), place_cord(place_cord_)
31  {
32  }
33  std::shared_ptr<ColorBlock> block;
34  std::map<Direction, std::shared_ptr<ColorBlockPlace>> black_line;
35  GameColor getColor() { return color; }
36  std::int8_t getPlaceCord() { return place_cord; }
37  bool hasBlock()
38  {
39  if(block) {
40  return true;
41  }
42  return false;
43  }
44 
45  private:
47  std::int8_t place_cord = -1;
48  };
49 
50  class BlockArea {
51  public:
52  // void calculateFirstCord();
53  std::array<std::shared_ptr<ColorBlockPlace>, 16> colorBlockPlaceArray;
54  BlockSideBySide::Direction getDirection(std::int8_t n1, std::int8_t n2);
55 
56  private:
57  std::unique_ptr<std::weak_ptr<ColorBlockPlace>> colorBlockPlaces;
58  std::int32_t first_cord;
59  std::list<ColorBlockPlace> waitTransportBlock;
60  std::int8_t finishColorBlockNum = 0;
61  };
62 
63 } // namespace BlockSideBySide
64 #endif
std::array< std::shared_ptr< ColorBlockPlace >, 16 > colorBlockPlaceArray
Definition: BlockArea.h:53
BlockSideBySide::Direction getDirection(std::int8_t n1, std::int8_t n2)
Definition: BlockArea.cpp:3
std::shared_ptr< ColorBlock > block
Definition: BlockArea.h:33
std::map< Direction, std::shared_ptr< ColorBlockPlace > > black_line
Definition: BlockArea.h:34
ColorBlockPlace(GameColor color_, std::int8_t place_cord_)
Definition: BlockArea.h:29