diff --git a/app/src/main/java/org/ntlab/irisclient/GameMasterActivity.java b/app/src/main/java/org/ntlab/irisclient/GameMasterActivity.java index e0b32ce..74d7a42 100644 --- a/app/src/main/java/org/ntlab/irisclient/GameMasterActivity.java +++ b/app/src/main/java/org/ntlab/irisclient/GameMasterActivity.java @@ -58,8 +58,6 @@ gameViewModel= new ViewModelProvider(this).get(GameViewModel.class); gameViewModel.setRid(rid); - //ここでカードとかメンバーを表示する - //ボタンの情報を入力 buttonProcesses(); @@ -73,6 +71,10 @@ //タイマースタート呼び出し gameViewModel.start(500,iris); + + + + //hint,openList,max,turnstate,の更新を反映。(gamestate・ゲームの勝敗結果はカードフラグメントが作る) gameViewModel.getTurnLiveData().observe(this, new Observer() { @Override public void onChanged(TurnJson turnJson) { @@ -83,21 +85,28 @@ //時間があれば何をしてほしいのかのアナウンスを入れる //時間があれば背景の色を変える + //ヒントが変更されているか、ターンが切り替わったときに + + //UpdateHint(); + } }); } - public void buttonProcesses(){ + private void buttonProcesses(){ Button SendHintButton = (Button) findViewById(R.id.SendHint); SendHintButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + if(!IsActive){return;}//アクティブのときだけボタンを押せる + EditText Hint = findViewById(R.id.GameHint); EditText HintMax = findViewById(R.id.GameHintMax); + //テキストを適した変数に変更 String hint = Hint.getText().toString(); Integer hintMax; @@ -107,25 +116,24 @@ hintMax = null; } - //ニックネームまたは部屋番号が入力されていない場合エラーメッセージを表示する if (hint.isEmpty()) { Hint.setError("ヒントが入力されていません"); } else if (hintMax == null) { HintMax.setError("数字が入力されていません"); } else { - //ビューモデルにhintとhintMaxを送信する。まとめて送信できるようになるかも知れないので、いったん放置 - gameViewModel.putHint(hint,hintMax); //マスターブランチに修正が入ったらコメントアウトを外す + gameViewModel.putHint(hint,hintMax); } } }); + } //操作可能かどうかを調べる関数。masterとかturnをオブザーブしておいて、変更があれば反映する。 - public boolean CheckActivity(TurnJson turnjson){ + private boolean CheckActivity(TurnJson turnjson){ - IsActive = false; + boolean isActive = false; //最新のゲームの状況を取得 String CurrentTeam = turnjson.getTeam(); @@ -133,10 +141,20 @@ //自分のチームのターンで、かつ「ヒント入力」時間の場合は行動可能 if(CurrentTeam.equals(myTeam) && turnState == 0){ - IsActive = true; + isActive = true; } - return IsActive; + return isActive; + } + + private void UpdateHint(String hint,Integer hintMax){ + + EditText Hint = findViewById(R.id.GameHint); + EditText HintMax = findViewById(R.id.GameHintMax); + + Hint.setText(hint); + HintMax.setText(hintMax); + } } \ No newline at end of file