Shop UI Functionality & Display - UQdeco2800/2022-studio-3 GitHub Wiki

Overview

The shop UI was created with the purpose of adding game play functionality akin to an RTS game. When the library, blacksmith or barracks are clicked in the game, the player has the option of trading stone, wood and metal resources for options in the shop. The shop UI options and prices for each building:

Library

  • 30 Stone -> Upgrade woods
  • 30 Wood -> Level up building

Blacksmith

  • 30 Metal -> Upgrade units
  • 30 Wood -> Level up building

Barracks

  • 30 Metal -> Spawn units
  • 30 Wood -> Level up building

Display

The shop UI can be found when a building is selected, and appears on the building data component at the bottom left hand corner of the screen. An example for the barracks shop:

Figure 1

image

ShopUIFunctionalityComponent class diagram

image

ShopUIFunctionalityComponent.java test plan

The ShopUIFunctionalityComponent is tested with ShopUIFunctionalityComponentTest.java. It contains the following tests:

spendResourcesTest() -> tests whether the component can correctly tell whether the player has enough resources to buy an item at the shop.

onUnitUpgradeTest() -> tests whether the stats of all unit entities increase when the player selects Unit upgrade from the shop

onWallUpgradeTest() -> tests whether the stats of all wall entities increase when the player selects Wall upgrade from the shop

The following methods were unable to be effectively tested due to being primarily visual or UI components:

removeButton() ->

This method is tested with the following visual inspection:

  • When the shop exit button is clicked, it removes both the building data component (if displayer) and shop interface.

spawnUnits() ->

This method is tested with the following visual inspection:

  • When Spawn unit is selected from baracks, an archer, spearman and hoplite are spawned in the centre of the city.

BuildingUIDataComponent.java test plan

The development done on BuildingUIDataComponent was tested primarily visually. The following criteria must be met for it to be working satisfactorily:

  • Each UI component must align as seen in the shop UI in Figure 1
  • When the shop exit button is clicked, both the building data component and shop interface must disappear. If the building has already been clicked away from, then pressing the exit button must remove the shop UI
  • When different shop buildings are clicked, the shop UI for the new building must override the old.
  • The correct cost values and button labels must be displayed for each building type as outlined in Overview.

Bugs & issues

There was a small flaw in the interaction of the shop UI. When the player selects a valid building the shop UI draws on the building data component, when a player clicks away from the building the data component disappears but the shop UI remains. This flaw was not corrected due to the time constraints of Sprint 4, and the amount of time required to fix this flaw would be too great compared to the game experienced it would provide. It was decided time would be better spent fixing real game play bugs.