• R/O
  • SSH
  • HTTPS

jinrousiki: Commit


Commit MetaInfo

Revision2729 (tree)
Time2021-06-11 18:36:19
Authorumethyl

Log Message

RoomManagerController::ValidateRoomCreateInChange()
RoomManagerController::ValidateSelfCreateInChange()

Change Summary

Incremental Difference

--- trunk/include/controller/room_manager_class.php (revision 2728)
+++ trunk/include/controller/room_manager_class.php (revision 2729)
@@ -111,19 +111,20 @@
111111
112112 //部屋説明出力
113113 private static function OutputDescribe() {
114- //エラーチェック
114+ //リクエストチェック
115115 if (RQ::Get()->room_no < 1) {
116116 self::OutputDescribeError(Message::INVALID_ROOM);
117117 }
118118
119+ //村情報ロード
119120 DB::SetRoom(RoomManagerDB::Load());
120121 if (DB::$ROOM->id < 1) {
121122 self::OutputDescribeError(Message::INVALID_ROOM);
122123 }
123124 if (DB::$ROOM->IsFinished()) {
124- $body = DB::$ROOM->id . GameMessage::ROOM_NUMBER_FOOTER . RoomManagerMessage::ERROR_FINISHED;
125- self::OutputDescribeError($body);
125+ self::OutputDescribeError(self::GetErrorRoom(RoomManagerMessage::ERROR_FINISHED));
126126 }
127+
127128 RoomManagerHTML::OutputDescribe();
128129 }
129130
@@ -132,31 +133,19 @@
132133 HTML::OutputResult(self::GetErrorTitle(RoomManagerMessage::TITLE_DESCRIBE), $body);
133134 }
134135
135- //エラーメッセージタイトル取得
136- private static function GetErrorTitle($str) {
137- return $str . ' ' . Message::ERROR_TITLE;
138- }
139-
140136 //データロード (村作成画面出力 / オプション変更時)
141137 private static function LoadOutputCreateInChange() {
142138 Session::Login();
139+
140+ //村情報ロード
143141 DB::SetRoom(RoomManagerDB::Load());
142+ self::ValidateRoomCreateInChange();
144143
145- $title = RoomManagerMessage::TITLE_CHANGE . ' ' . Message::ERROR_TITLE;
146- $header = DB::$ROOM->id . GameMessage::ROOM_NUMBER_FOOTER;
147- if (DB::$ROOM->IsFinished()) {
148- HTML::OutputResult($title, $header . RoomManagerMessage::ERROR_FINISHED);
149- }
150- if (false === DB::$ROOM->IsBeforegame()) {
151- HTML::OutputResult($title, $header . RoomManagerMessage::ERROR_CHANGE_PLAYING);
152- }
153-
144+ //ユーザー情報ロード
154145 DB::LoadUser();
155146 DB::LoadSelf();
156- if (false === DB::$SELF->IsDummyBoy()) {
157- $body = sprintf(RoomManagerMessage::ERROR_CHANGE_NOT_GM, Message::DUMMY_BOY, Message::GM);
158- HTML::OutputResult($title, $body);
159- }
147+ self::ValidateSelfCreateInChange();
148+
160149 DB::$ROOM->ParseOption(true);
161150 }
162151
@@ -163,17 +152,12 @@
163152 //データロード (村作成 / オプション変更時)
164153 private static function LoadCreateInChange() {
165154 Session::Login();
155+
156+ //村情報ロード
166157 DB::SetRoom(RoomManagerDB::Load(true));
158+ self::ValidateRoomCreateInChange();
167159
168- $title = RoomManagerMessage::TITLE_CHANGE . ' ' . Message::ERROR_TITLE;
169- $header = DB::$ROOM->id . GameMessage::ROOM_NUMBER_FOOTER;
170- if (DB::$ROOM->IsFinished()) {
171- HTML::OutputResult($title, $header . RoomManagerMessage::ERROR_FINISHED);
172- }
173- if (false === DB::$ROOM->IsBeforegame()) {
174- HTML::OutputResult($title, $header . RoomManagerMessage::ERROR_CHANGE_PLAYING);
175- }
176-
160+ //ユーザー情報ロード
177161 DB::LoadUser();
178162 if (RQ::Get()->max_user < DB::$USER->Count()) {
179163 $title = sprintf('%s [%s]',
@@ -182,14 +166,36 @@
182166 HTML::OutputResult($title, RoomManagerMessage::ERROR_CHANGE_MAX_USER);
183167 }
184168
169+ //本人情報ロード
185170 DB::LoadSelf();
171+ self::ValidateSelfCreateInChange();
172+
173+ DB::$ROOM->ParseOption(true);
174+ }
175+
176+ //村情報チェック (オプション変更時)
177+ private static function ValidateRoomCreateInChange() {
178+ if (DB::$ROOM->IsFinished()) {
179+ self::OutputCreateInChangeError(self::GetErrorRoom(RoomManagerMessage::ERROR_FINISHED));
180+ }
181+ if (false === DB::$ROOM->IsBeforegame()) {
182+ self::OutputCreateInChangeError(self::GetErrorRoom(RoomManagerMessage::ERROR_CHANGE_PLAYING));
183+ }
184+ }
185+
186+ //本人情報チェック (オプション変更時)
187+ private static function ValidateSelfCreateInChange() {
186188 if (false === DB::$SELF->IsDummyBoy()) {
187189 $body = sprintf(RoomManagerMessage::ERROR_CHANGE_NOT_GM, Message::DUMMY_BOY, Message::GM);
188- HTML::OutputResult($title, $body);
190+ self::OutputCreateInChangeError($body);
189191 }
190- DB::$ROOM->ParseOption(true);
191192 }
192193
194+ //オプション変更時エラー出力
195+ private static function OutputCreateInChangeError($body) {
196+ HTML::OutputResult(self::GetErrorTitle(RoomManagerMessage::TITLE_CHANGE), $body);
197+ }
198+
193199 //村作成呼び出しチェック
194200 private static function ValidateCreate() {
195201 if (ServerConfig::DISABLE_ESTABLISH || DatabaseConfig::DISABLE) { //無効設定
@@ -357,6 +363,21 @@
357363 }
358364 }
359365
366+ //エラーメッセージタイトル取得
367+ private static function GetErrorTitle($str) {
368+ return $str . ' ' . Message::ERROR_TITLE;
369+ }
370+
371+ //エラーメッセージ対象村取得
372+ private static function GetErrorRoom($str) {
373+ return self::GetErrorRoomHeader() . $str;
374+ }
375+
376+ //エラーメッセージ対象村ヘッダー取得
377+ private static function GetErrorRoomHeader() {
378+ return DB::$ROOM->id . GameMessage::ROOM_NUMBER_FOOTER;
379+ }
380+
360381 //テスト用結果表示
361382 private static function p() {
362383 if (true !== ServerConfig::DEBUG_MODE) { //スキップ判定
Show on old repository browser