• R/O
  • SSH
  • HTTPS

jinrousiki: 提交


Commit MetaInfo

修訂2762 (tree)
時間2021-08-16 03:03:04
作者umethyl

Log Message

OptionManager::CanLoad()

Change Summary

差異

--- trunk/include/option/option_class.php (revision 2761)
+++ trunk/include/option/option_class.php (revision 2762)
@@ -38,7 +38,7 @@
3838 //オプションクラスロード
3939 public static function GetFilter($type) {
4040 foreach (OptionFilterData::$$type as $option) {
41- if (DB::$ROOM->IsOption($option)) {
41+ if (self::CanLoad($option)) {
4242 return OptionLoader::Load($option);
4343 }
4444 }
@@ -64,14 +64,12 @@
6464 //基礎配役取得
6565 public static function GetCastBase($user_count) {
6666 foreach (OptionFilterData::$cast_base as $option) {
67- if (false === DB::$ROOM->IsOption($option)) {
68- continue;
67+ if (self::CanLoad($option)) {
68+ $filter = OptionLoader::Load($option);
69+ if (true === $filter->EnableCast($user_count)) {
70+ return $filter;
71+ }
6972 }
70-
71- $filter = OptionLoader::Load($option);
72- if (true === $filter->EnableCast($user_count)) {
73- return $filter;
74- }
7573 }
7674 return null;
7775 }
@@ -79,7 +77,7 @@
7977 //追加配役 (普通村)
8078 public static function FilterCastAddRole(array &$list, $count) {
8179 foreach (OptionFilterData::$cast_add_role as $option) {
82- if (DB::$ROOM->IsOption($option) && OptionLoader::LoadFile($option)) {
80+ if (self::CanLoad($option)) {
8381 OptionLoader::Load($option)->FilterCastAddRole($list, $count);
8482 }
8583 }
@@ -88,7 +86,7 @@
8886 //追加配役 (闇鍋固定枠)
8987 public static function FilterCastChaosFixRole(array &$list) {
9088 foreach (OptionFilterData::$cast_chaos_fix_role as $option) {
91- if (DB::$ROOM->IsOption($option)) {
89+ if (self::CanLoad($option)) {
9290 OptionLoader::Load($option)->FilterCastChaosFixRole($list);
9391 }
9492 }
@@ -126,7 +124,7 @@
126124 public static function CastUserSubRole() {
127125 $stack = Cast::Stack()->Get(Cast::DELETE);
128126 foreach (OptionFilterData::$cast_user_sub_role as $option) {
129- if (DB::$ROOM->IsOption($option) && OptionLoader::LoadFile($option)) {
127+ if (self::CanLoad($option)) {
130128 ArrayFilter::AddMerge($stack, OptionLoader::Load($option)->CastUserSubRole());
131129 }
132130 }
@@ -156,7 +154,7 @@
156154 public static function IsRoomOpenCast() {
157155 //便宜上常時公開設定もオプションクラスは実装しているが、システム上はオプション未設定になる
158156 foreach (OptionFilterData::$room_open_cast as $option) {
159- if (DB::$ROOM->IsOption($option)) {
157+ if (self::CanLoad($option)) {
160158 return OptionLoader::Load($option)->IsRoomOpenCast();
161159 }
162160 }
@@ -166,12 +164,17 @@
166164 //ゲーム開始時シーン取得
167165 public static function GetRoomGameStartScene() {
168166 foreach (OptionFilterData::$room_game_start_scene as $option) {
169- if (DB::$ROOM->IsOption($option)) {
167+ if (self::CanLoad($option)) {
170168 return OptionLoader::Load($option)->GetRoomGameStartScene();
171169 }
172170 }
173171 return RoomScene::NIGHT;
174172 }
173+
174+ //オプションロード可能判定
175+ private static function CanLoad($option) {
176+ return DB::$ROOM->IsOption($option) && OptionLoader::LoadFile($option);
177+ }
175178 }
176179
177180 //-- オプションパーサ --//
Show on old repository browser