回答編集履歴

2

修正

2019/10/09 13:03

投稿

KazuhiroHatano
KazuhiroHatano

スコア7819

test CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  if(empty($teams_has_zero_hp)){return null;}
20
20
 
21
- return array_keys($teams_has_zero_hp ,min($teams_has_zero_hp))[0];
21
+ return array_keys($teams_has_zero_hp ,min($teams_has_zero_hp));
22
22
 
23
23
  }
24
24
 

1

修正

2019/10/09 13:03

投稿

KazuhiroHatano
KazuhiroHatano

スコア7819

test CHANGED
@@ -12,13 +12,13 @@
12
12
 
13
13
  foreach(['red'=>'rhp','green'=>'ghp','blue'=>'bhp','yellow'=>'yhp'] as $color=>$hp_key){
14
14
 
15
- if($this->plugin->game->$hp_key==0){$teams_has_zero_hp[]=$this->$color;}
15
+ if($this->plugin->game->$hp_key==0){$teams_has_zero_hp[$color]=$this->$color;}
16
16
 
17
17
  }
18
18
 
19
- if(!isset($teams_has_zero_hp[0])){return null;}
19
+ if(empty($teams_has_zero_hp)){return null;}
20
20
 
21
- return min($teams_has_zero_hp);
21
+ return array_keys($teams_has_zero_hp ,min($teams_has_zero_hp))[0];
22
22
 
23
23
  }
24
24
 
@@ -31,3 +31,11 @@
31
31
  ゲームクラスは各々のチームをプロパティで持つんじゃなく
32
32
 
33
33
  配列でチームの情報をまとめて持った方が取り回しがいいと思う
34
+
35
+
36
+
37
+ ---
38
+
39
+
40
+
41
+ 仕様を読み違えてたので修正