feat: implémentation de la section Règles des jeux
Les activités RulesListActivity et RuleDetailActivity étaient des stubs vides (TODO) -> écran noir depuis la migration du hub. - Liste des 3 jeux (Classic, 89++, Papelito) dans le style du hub - Fiche de règles détaillées par jeu (déroulement, valeurs spéciales, conditions de victoire), écrites à partir du comportement réel du code - Bouton «Jouer maintenant» ouvrant directement la configuration du jeu
This commit is contained in:
@@ -1,12 +1,68 @@
|
||||
package com.example.boidelov3.rules;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.boidelov3.R;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
/**
|
||||
* Règles détaillées d'un jeu, avec accès direct à sa configuration
|
||||
*/
|
||||
public class RuleDetailActivity extends AppCompatActivity {
|
||||
|
||||
public class RuleDetailActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// TODO: Implement rule detail screen
|
||||
setContentView(R.layout.activity_rule_detail);
|
||||
|
||||
MaterialToolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> finish());
|
||||
|
||||
String gameId = getIntent().getStringExtra(RulesListActivity.EXTRA_GAME_ID);
|
||||
if (gameId == null) {
|
||||
gameId = RulesListActivity.GAME_CLASSIC;
|
||||
}
|
||||
|
||||
int iconRes = R.drawable.ic_boidelo_classic;
|
||||
int titleRes = R.string.boidelo_classic_title;
|
||||
int summaryRes = R.string.boidelo_classic_description;
|
||||
int detailRes = R.string.rules_classic_detail;
|
||||
Class<?> setupActivity = com.example.boidelov3.games.boideloclassic.BoideloClassicSetupActivity.class;
|
||||
|
||||
switch (gameId) {
|
||||
case RulesListActivity.GAME_89:
|
||||
iconRes = R.drawable.ic_game_89;
|
||||
titleRes = R.string.game_89_title;
|
||||
summaryRes = R.string.game_89_description;
|
||||
detailRes = R.string.rules_89_detail;
|
||||
setupActivity = com.example.boidelov3.games.game89.Game89SetupActivity.class;
|
||||
break;
|
||||
case RulesListActivity.GAME_PAPELITO:
|
||||
iconRes = R.drawable.ic_papelito;
|
||||
titleRes = R.string.rules_papelito_title;
|
||||
summaryRes = R.string.undercover_description;
|
||||
detailRes = R.string.rules_papelito_detail;
|
||||
setupActivity = com.example.boidelov3.games.papelito.PapelitoSetupActivity.class;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
toolbar.setTitle(getString(titleRes));
|
||||
((ImageView) findViewById(R.id.ruleIcon)).setImageResource(iconRes);
|
||||
((TextView) findViewById(R.id.ruleTitle)).setText(titleRes);
|
||||
((TextView) findViewById(R.id.ruleSummary)).setText(summaryRes);
|
||||
((TextView) findViewById(R.id.ruleText)).setText(detailRes);
|
||||
|
||||
MaterialButton playButton = findViewById(R.id.playButton);
|
||||
final Class<?> targetActivity = setupActivity;
|
||||
playButton.setOnClickListener(v ->
|
||||
startActivity(new Intent(this, targetActivity)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,43 @@
|
||||
package com.example.boidelov3.rules;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
|
||||
public class RulesListActivity extends Activity {
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.boidelov3.R;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
|
||||
/**
|
||||
* Liste des règles : une carte par jeu, ouvre le détail des règles
|
||||
*/
|
||||
public class RulesListActivity extends AppCompatActivity {
|
||||
|
||||
/** Identifiant du jeu dont on veut les règles */
|
||||
public static final String EXTRA_GAME_ID = "RULES_GAME_ID";
|
||||
public static final String GAME_CLASSIC = "classic";
|
||||
public static final String GAME_89 = "89";
|
||||
public static final String GAME_PAPELITO = "papelito";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// TODO: Implement rules list screen
|
||||
setContentView(R.layout.activity_rules_list);
|
||||
|
||||
MaterialToolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> finish());
|
||||
|
||||
findViewById(R.id.cardClassic).setOnClickListener(v -> openRules(GAME_CLASSIC));
|
||||
findViewById(R.id.card89).setOnClickListener(v -> openRules(GAME_89));
|
||||
findViewById(R.id.cardPapelito).setOnClickListener(v -> openRules(GAME_PAPELITO));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ouvre l'écran de règles détaillées du jeu choisi
|
||||
*/
|
||||
private void openRules(String gameId) {
|
||||
Intent intent = new Intent(this, RuleDetailActivity.class);
|
||||
intent.putExtra(EXTRA_GAME_ID, gameId);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user