OSDN Git Service

[Refactor] クラスを定義
authorSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Tue, 15 Mar 2022 13:30:02 +0000 (22:30 +0900)
committerSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Sun, 20 Mar 2022 03:56:42 +0000 (12:56 +0900)
src/target/projection-path-calculator.h

index b499baa..4d150ae 100644 (file)
@@ -1,9 +1,23 @@
 #pragma once
 
 #include "system/angband.h"
+#include <utility>
+#include <vector>
 
 class PlayerType;
-int projection_path(PlayerType *player_ptr, uint16_t *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg);
+class projection_path {
+public:
+    projection_path(PlayerType *player_ptr, int range, int y1, int x1, int y2, int x2, BIT_FLAGS flg);
+    std::vector<std::pair<int, int>>::const_iterator begin() const;
+    std::vector<std::pair<int, int>>::const_iterator end() const;
+    const std::pair<int, int> &front() const;
+    const std::pair<int, int> &back() const;
+    const std::pair<int, int> &operator[](int num) const;
+    int path_num() const;
+
+private:
+    std::vector<std::pair<int, int>> position;
+};
 bool projectable(PlayerType *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2);
 int get_max_range(PlayerType *player_ptr);
 POSITION get_grid_y(uint16_t grid);