Skip to content

Turret Selection Screen

SonjaMcNeilly edited this page Oct 3, 2023 · 13 revisions

Introduction

The turret selection screen allows the user to pick 5 turrets from a list of all turrets. (The 5 turret maximum is highly subject to change) turret-select-png

The user is given a description on what each turret does. This is shown when the user hovers over a turret, it will appear in the top right of the screen.

Development

The story screen uses a basic screen model that includes:

  • show()
  • render()
  • resize()
  • dispose()

A

                // Create a TextButton for the turret name
                TextButton turretButton = new TextButton(turret.getTowerName(), skin);
                turretButton.addListener(new ClickListener() {
                    @Override
                    public void clicked(InputEvent event, float x, float y) {
                        logger.info(String.valueOf(selectedTurrets.size()));
                        if (selectedTurrets.size() > MAX_SELECTED_TURRETS) {
                            message.setText("You can only select up to 5 turrets.");
                        } else {
                            message.setText("Select your turrets");
                        }
                        if (selectedTurrets.contains(turret)) {
                            // Turret is already selected, unselect it
                            selectedTurrets.remove(turret);
                            // You can also change the button appearance to indicate unselection
                            logger.info(selectedTurrets.toString());
                            turretsPicked.setText("Turrets picked: " + selectedTurrets.toString());
                        } else if (selectedTurrets.size() == MAX_SELECTED_TURRETS) {
                            // Turret is not selected, but the max number of turrets has been reached
                            message.setText("You can only select up to 5 turrets.");
                        } else if (selectedTurrets.size() < MAX_SELECTED_TURRETS) {
                            // Turret is not selected, select it
                            selectedTurrets.add(turret);
                            turretsPicked.setText("Turrets picked: " + selectedTurrets.toString());
                            logger.info(selectedTurrets.toString());
                        }
                        else {
                            // Turret is not selected, select it
                            selectedTurrets.add(turret);
                            turretsPicked.setText("Turrets picked: " + selectedTurrets.toString());
                            //logger.info(selectedTurrets.toString());

    }

This the main code that handles looping through the enumerate and adding the description, image and tower name.

Test Plan

Due to the state of UI, it cannot be directly JUNIT/mockito tested. Here is a test plan for the screen:

  • Background appears.
  • All turrets appear (that are added in enumumerate).
  • Image, description and turret name correctly display.
  • Clicking a turret correctly adds it to the list of turrets picked.
  • Clicking a turret in the list of turrets picked correctly removes turret from list.
  • Clicking a turret in the list when it exceeds the maximum correctly displays message.
  • Clicking a turret in the list when it exceeds the maximum correctly stops turrets from being added to the list.
  • Clicking continue takes you to the main game screen

The test was manually conducted 3 times, all tests passed (for a single resolution) but a resolution bug was found (See issue #149)

Clone this wiki locally