OSDN Git Service

[Fix] next_mirror で鏡のマスと同じ座標にある場合、抽選し直すように修正
authorSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Sun, 27 Mar 2022 13:23:42 +0000 (22:23 +0900)
committerSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Sun, 27 Mar 2022 13:31:08 +0000 (22:31 +0900)
抽選し直しは可読性を考え、do-whileで実装

src/spell-class/spells-mirror-master.cpp

index 2a6affc..4a03b6a 100644 (file)
@@ -255,8 +255,10 @@ void SpellsMirrorMaster::next_mirror(int *next_y, int *next_x, int cury, int cur
         return;
     }
 
-    *next_y = cury + randint0(5) - 2;
-    *next_x = curx + randint0(5) - 2;
+    do {
+        *next_y = cury + randint0(5) - 2;
+        *next_x = curx + randint0(5) - 2;
+    } while ((*next_y == cury) && (*next_x == curx));
 }
 
 void SpellsMirrorMaster::project_seeker_ray(int target_x, int target_y, int dam)