Skip to content

Testing Planning for create two characters for selection

Vu Khanh Vy Ho edited this page Sep 10, 2024 · 1 revision

Objective

The purpose of this plan is to ensure that the createTwoPlayers method in the PlayerSelection class returns a list of two players based on their respective configuration files, and that these players can be retrieved and initialized successfully.

Current Challenges

Performing a comprehensive JUnit test at this stage is difficult due to the complexity of mocking multiple inputs. However, the method's functionality can be effectively tested manually by utilizing the MainGameScreen. Below are detailed instructions on how to manually test the functionality of this class.

Instructions for Manual Testing

Each player character is generated from separate JSON configuration files, located in the assets/configs/ directory. The first player's configuration is stored in player.json, while the second player's configuration is found in player_2.json.

A sample structure of the configuration file is as follows:

{
  "name": "default",
  "health": 100,
  "favouriteColour": "peach",
  "textureFilename": "images/player/player.png",
  "textureAtlasFilename": "images/player/player.atlas",
  "melee": "pickaxe",
  "ranged": "shotgun"
}

Both players are expected to share default configuration values for attributes such as health and weapons. However, they differ in the textureFilename and textureAtlasFilename, which specify the paths to their respective animations.

Calling the Method

To test the method, the following code should be executed within MainGameScreen.java:

PlayerSelection playerSelection = new PlayerSelection();
List<Entity> players = playerSelection.createTwoPlayers();

This method invocation returns a list of two players that can be retrieved and displayed on the game screen.

Expected Behavior

Retrieving the First Player

When retrieving the first player using the following code:

Entity player = players.get(0);

The player should spawn on the screen with the statistics declared in the configuration file. The player's health and attributes should match those defined in player.json, as illustrated in the corresponding game UI.

Screenshot 2024-09-10 at 8 41 53 pm

Retrieving the Second Player

When retrieving the second player using:

Entity player = players.get(1);

The second player should also spawn with the statistics specified in player_2.json. However, due to the current absence of animations for the second character, the second player's health is set to 70 to differentiate it from the first player. When starting the game with the second player, the health bar should display a value lower than 70. If the health does not reflect this, it indicates an issue with the method’s functionality.

Screenshot 2024-09-10 at 8 45 33 pm

Conclusion

After manually testing the method, it was confirmed that the createTwoPlayers method functions as expected. Both players are correctly created from their respective configuration files, and their statistics are properly displayed in the game.

Plan for the Next Sprint

Currently, the game lacks animations for the second character, so the distinction between the two players is made by assigning different health values (70 for the second player). The goal for the next sprint is to implement animations for the second player, allowing both characters to be differentiated by their respective animations rather than health values.

Table of Contents

Home

Design

Design Document

Design Choices

Game Wiki

Gameplay

Controls

Game Features

Utilities
Animals
Menus/screens
Character
Map
Weapon
Projectile
Items
Music/sound

User Guide

Starting the game

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Enhancement of Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally