• R/O
  • SSH
  • HTTPS

jinrousiki: Commit


Commit MetaInfo

Revision2316 (tree)
Time2018-12-30 22:02:12
Authorumethyl

Log Message

Cast::OutputError()

Change Summary

Incremental Difference

--- trunk/include/cast_class.php (revision 2315)
+++ trunk/include/cast_class.php (revision 2316)
@@ -23,7 +23,7 @@
2323 public static function Stack() {
2424 static $stack;
2525
26- if (is_null($stack)) {
26+ if (true === is_null($stack)) {
2727 $stack = new Stack();
2828 }
2929 return $stack;
@@ -41,8 +41,8 @@
4141 //人数とゲームオプションに応じた役職テーブルを返す
4242 public static function Get($user_count) {
4343 //人数に応じた配役リストを取得
44- if (! isset(CastConfig::$role_list[$user_count])) { //リストの有無をチェック
45- self::Output(sprintf(VoteMessage::NO_CAST_LIST, $user_count));
44+ if (false === isset(CastConfig::$role_list[$user_count])) { //リストの有無をチェック
45+ self::OutputError(sprintf(VoteMessage::NO_CAST_LIST, $user_count));
4646 }
4747 $role_list = CastConfig::$role_list[$user_count];
4848 //Text::p(DB::$ROOM->option_list, '◆OptionList');
@@ -68,13 +68,15 @@
6868 self::ReplaceRole($role_list); //村人置換村
6969 }
7070
71- if (! is_array($role_list)) self::Output(VoteMessage::INVALID_CAST);
71+ if (false === is_array($role_list)) {
72+ self::OutputError(VoteMessage::INVALID_CAST);
73+ }
7274
7375 //役職名を格納した配列を生成
7476 $role_fill_list = [];
7577 foreach ($role_list as $role => $count) {
7678 if ($count < 0) { //人数をチェック
77- self::Output(sprintf(VoteMessage::INVALID_ROLE_COUNT, $role));
79+ self::OutputError(sprintf(VoteMessage::INVALID_ROLE_COUNT, $role));
7880 }
7981 for (; $count > 0; $count--) {
8082 $role_fill_list[] = $role;
@@ -88,7 +90,7 @@
8890 Text::p($str);
8991 return $role_fill_list;
9092 }
91- self::Output($str);
93+ self::OutputError($str);
9294 }
9395
9496 return $role_fill_list;
@@ -132,7 +134,7 @@
132134 $filter = OptionManager::GetFilter('cast_message');
133135
134136 //-- メイン役職 --//
135- if (is_null($filter)) {
137+ if (true === is_null($filter)) {
136138 $header = VoteMessage::ROLE_HEADER;
137139 $main_type = '';
138140 $main_role_list = $role_count_list;
@@ -143,7 +145,7 @@
143145 }
144146
145147 //-- サブ役職 --//
146- if (is_null($filter)) {
148+ if (true === is_null($filter)) {
147149 $sub_type = '';
148150 $sub_role_list = $role_count_list;
149151 } else {
@@ -154,7 +156,7 @@
154156 //-- 出力メッセージ生成 --//
155157 $stack = [];
156158 foreach (RoleDataManager::GetDiff($main_role_list) as $role => $name) {
157- if ($css) {
159+ if (true === $css) {
158160 $name = RoleDataHTML::GenerateMain($role);
159161 }
160162 $stack[] = $name . $main_type . $main_role_list[$role];
@@ -196,13 +198,12 @@
196198
197199 //身代わり君配役
198200 private static function CastDummyBoy() {
199- if (! DB::$ROOM->IsDummyBoy()) return;
201+ if (false === DB::$ROOM->IsDummyBoy()) return;
200202
201203 self::SetDummyBoy();
202204 //self::Stack()->p(self::CAST, '◆dummy_boy');
203205 if (self::Stack()->Count(self::CAST) < 1) {
204- $str = sprintf(VoteMessage::ERROR_CAST, VoteMessage::NO_CAST_DUMMY_BOY);
205- VoteHTML::OutputResult($str, ! DB::$ROOM->IsTest());
206+ self::OutputError(VoteMessage::NO_CAST_DUMMY_BOY);
206207 }
207208
208209 self::Stack()->Add(self::UNAME, GM::DUMMY_BOY); //決定済みリスト登録
@@ -222,7 +223,8 @@
222223 }
223224
224225 if (isset($fix_role)) {
225- if (($key = array_search($fix_role, $role_list)) !== false) {
226+ $key = array_search($fix_role, $role_list);
227+ if (false !== $key) {
226228 self::Stack()->Add(self::CAST, $fix_role);
227229 self::Stack()->DeleteKey(self::ROLE, $key);
228230 }
@@ -252,7 +254,7 @@
252254
253255 //探偵村対応
254256 $role = 'detective_common';
255- if (DB::$ROOM->IsOption('detective') && ! in_array($role, $stack)) {
257+ if (DB::$ROOM->IsOption('detective') && false === in_array($role, $stack)) {
256258 $stack[] = $role;
257259 }
258260 return $stack;
@@ -276,8 +278,7 @@
276278 $remain = $stack->Count(self::REMAIN);
277279 $role = $stack->Count(self::ROLE);
278280 if ($remain != $role) {
279- $str = sprintf(VoteMessage::CAST_MISMATCH_REMAIN, $remain, $role);
280- VoteHTML::OutputResult(sprintf(VoteMessage::ERROR_CAST, $str), ! DB::$ROOM->IsTest());
281+ self::OutputError(sprintf(VoteMessage::CAST_MISMATCH_REMAIN, $remain, $role));
281282 }
282283 }
283284
@@ -288,7 +289,8 @@
288289
289290 foreach ($stack->Get(self::USER) as $uname) {
290291 $role = self::GetWishRole($uname); //希望役職を取得
291- if (($key = self::GetWishRoleKey($role)) !== false) { //希望役職存在判定
292+ $key = self::GetWishRoleKey($role); //希望役職存在判定
293+ if (false !== $key) {
292294 $stack->Add(self::UNAME, $uname);
293295 $stack->Add(self::CAST, $role);
294296 $stack->DeleteKey(self::ROLE, $key);
@@ -303,7 +305,9 @@
303305 //希望役職取得
304306 private static function GetWishRole($uname) {
305307 $role = DB::$USER->GetWishRole($uname); //希望役職を取得
306- if ($role == '' || ! Lottery::Percent(CastConfig::WISH_ROLE_RATE)) return null;
308+ if ($role == '' || false === Lottery::Percent(CastConfig::WISH_ROLE_RATE)) {
309+ return null;
310+ }
307311
308312 if (self::Stack()->Get(self::WISH)) { //特殊村はグループ単位で希望処理を行なう
309313 $stack = [];
@@ -345,30 +349,24 @@
345349 //self::Stack()->p(self::UNAME, '◆Uname/2nd');
346350 //self::Stack()->p(self::CAST, '◆Role/2nd');
347351
348- //配役結果チェック
349- $format = VoteMessage::ERROR_CAST;
350- $reset_flag = ! DB::$ROOM->IsTest();
351-
352- //配役決定者チェック
352+ //-- 配役結果チェック --//
353+ //配役決定者
353354 $user_count = self::Stack()->Get(self::COUNT);
354355 $fix_uname = self::Stack()->Count(self::UNAME);
355356 if ($user_count != $fix_uname) {
356- $str = sprintf(VoteMessage::CAST_MISMATCH_USER, $user_count, $fix_uname);
357- VoteHTML::OutputResult(sprintf($format, $str), $reset_flag);
357+ self::OutputError(sprintf(VoteMessage::CAST_MISMATCH_USER, $user_count, $fix_uname));
358358 }
359359
360- //配役数チェック
360+ //配役数
361361 $fix_role = self::Stack()->Count(self::CAST);
362362 if ($fix_uname != $fix_role) {
363- $str = sprintf(VoteMessage::CAST_MISMATCH_ROLE, $fix_uname, $fix_role);
364- VoteHTML::OutputResult(sprintf($format, $str), $reset_flag);
363+ self::OutputError(sprintf(VoteMessage::CAST_MISMATCH_ROLE, $fix_uname, $fix_role));
365364 }
366365
367- //残り配役数チェック
366+ //残り配役数
368367 $role = self::Stack()->Count(self::ROLE);
369368 if ($role > 0) {
370- $str = sprintf(VoteMessage::CAST_REMAIN_ROLE, $role);
371- VoteHTML::OutputResult(sprintf($format, $str), $reset_flag);
369+ self::OutputError(sprintf(VoteMessage::CAST_REMAIN_ROLE, $role));
372370 }
373371 }
374372
@@ -388,7 +386,9 @@
388386 //self::Stack()->p(self::RAND, '◆Rand');
389387
390388 //闇鍋モード処理
391- if (DB::$ROOM->IsOption('no_sub_role') || ! DB::$ROOM->IsOptionGroup('chaos')) return;
389+ if (DB::$ROOM->IsOption('no_sub_role') || false === DB::$ROOM->IsOptionGroup('chaos')) {
390+ return;
391+ }
392392
393393 //ランダムなサブ役職のコードリストを作成
394394 $filter = OptionManager::GetFilter('cast_sub_role');
@@ -467,7 +467,7 @@
467467 //Text::p($boost_list, '◆boost');
468468
469469 //-- 最小出現補正 --//
470- if (! $chaos_verso) {
470+ if (false === $chaos_verso) {
471471 $stack = []; //役職系統別配役数
472472 foreach ($fix_role_list as $role => $count) { //固定枠を系統別にカウント
473473 ArrayFilter::Add($stack, RoleDataManager::GetGroup($role), $count);
@@ -507,7 +507,7 @@
507507 //Text::p($role_list, sprintf('◆1st(%d)', array_sum($role_list)));
508508
509509 //-- 上限補正 --//
510- if (! $chaos_verso) {
510+ if (false === $chaos_verso) {
511511 //役職グループ毎に集計
512512 $total_stack = []; //グループ別リスト (全配役)
513513 $random_stack = []; //グループ別リスト (ランダム)
@@ -519,7 +519,10 @@
519519 }
520520
521521 foreach (ChaosConfig::$role_group_rate_list as $group => $rate) {
522- if (! ArrayFilter::IsArray($random_stack, $group)) continue;
522+ if (false === ArrayFilter::IsArray($random_stack, $group)) {
523+ continue;
524+ }
525+
523526 $target = $random_stack[$group];
524527 $count = array_sum($total_stack[$group]) - round($user_count / $rate);
525528 //if ($count > 0) Text::p($count, "◆Calib [{$group}]"); //テスト用
@@ -580,10 +583,13 @@
580583 }
581584
582585 //-- 村人上限補正 --//
583- if (! $chaos_verso && ! DB::$ROOM->IsReplaceHumanGroup() && isset($role_list['human'])) {
586+ if (false === $chaos_verso && false === DB::$ROOM->IsReplaceHumanGroup() &&
587+ true === isset($role_list['human'])) {
584588 $role = 'human';
585589 $count = $role_list[$role] - round($user_count / ChaosConfig::$max_human_rate);
586- if (DB::$ROOM->IsOption('gerd')) $count--;
590+ if (DB::$ROOM->IsOption('gerd')) {
591+ $count--;
592+ }
587593 if ($count > 0) {
588594 $name = ChaosConfig::${$base_name . '_replace_human_role_list'};
589595 $rate = Lottery::GetChaos($name, $boost_list);
@@ -657,7 +663,9 @@
657663 }
658664
659665 $count = ArrayFilter::GetInt($list, $role);
660- if ($role == 'human' && DB::$ROOM->IsOption('gerd')) $count--; //ゲルト君モード
666+ if ($role == 'human' && DB::$ROOM->IsOption('gerd')) { //ゲルト君モード
667+ $count--;
668+ }
661669 if ($count > 0) {
662670 ArrayFilter::Replace($list, $role, $target, $count); //置換処理
663671 }
@@ -666,7 +674,7 @@
666674 }
667675
668676 //エラーメッセージ出力
669- private static function Output($str) {
670- VoteHTML::OutputResult(sprintf(VoteMessage::ERROR_CAST, $str), ! DB::$ROOM->IsTest());
677+ private static function OutputError($str) {
678+ VoteHTML::OutputResult(sprintf(VoteMessage::ERROR_CAST, $str), false === DB::$ROOM->IsTest());
671679 }
672680 }
Show on old repository browser