Assignment 1 - CS Clash

Overview

Your task is to implement the CS Clash game.

CS Clash is a game where the player enters commands to move our Barbarian on the board. During our heroic journey to destroy the Town Hall, the Barbarian will encounter a range of defensive entities. Luckily for us, we also have some tricks up our sleeve!

This game is inspired by Clash of Clans (all trademarks are the property of their respective owners). No prior knowledge of the real game is required to complete this assignment (although if you've played, you might be able to spot some similarities).

The aim of the game is to destroy the key building on the board, the Town Hall!

We will begin by setting up the board, then add functionality to play the game and in the final stages, implement some more interesting mechanics!

Getting Started

  1. Create a new folder for your assignment:
mkdir ass1
cd ass1
  1. Fetch the starter code using the command below.
1511 fetch-activity cs_clash

You should now have a file named cs_clash.c in your ass1 directory.

  1. Check that everything works by running the autotest:
1511 autotest cs_clash

If you want to stop running the autotest before it finishes, press [Ctrl-C].

Program Structure

This is a summary of the program structure. It's included as an introduction to aid your overall understanding of the assignment. Detailed instructions will be included in later sections of the specification.

The program consists of two phases: a Setup Phase, and a Gameplay Phase.

Two Phases: Setup and Gameplay

Setup Phase

When the program starts, the Setup Phase begins, and a new game is created:

  • An empty game board is initialised.
  • The Barbarian is spawned.
  • Entities (Town Hall, Walls, Cannons, Archer Towers, Bombs and Wizards) are added to the board.
  • Upgrades occur.

Gameplay Phase

When the Setup Phase is complete, the Gameplay Phase begins. In this phase, the Barbarian:

  • Moves around the board.
  • Moves into entities to 'attack' them.
  • Takes damage from certain entities.
  • May activate special abilities.

Reference Implementation

To help you understand the game, we've written a complete reference implementation which you can run in any CSE terminal with the command 1511 cs_clash. It implements every stage of the assignment. You can use this to test how your program should behave.

Try the following input in the reference implementation:

1511 cs_clash
7 7
w 5 6
w 5 7
w 5 8
b 4 6
t 4 7
c 4 8
U 4
e
a
a
w
w
w
d
d
d
d

These inputs will:

  • Spawn the Barbarian at board position [7][7].
  • Add Walls at [5][6], [5][7], and [5][8], a Bomb at [4][6], the Town Hall at [4][7], and a Cannon at [4][8].
  • Levels up the Barbarian to Level 5.
  • Start the game.
  • Move the Barbarian around the board, navigating to and destroying the Town Hall.

You don't need to fully understand these inputs yet; they're only provided as a preview.

Starter Code and Data Structures

Starter code has been provided to help you get up and running. It contains a range of useful constants, structs, enums, and functions.

If you haven't done so already, test the 1511 cs_clash reference solution, then open the provided cs_clash.c and follow along with this introduction.

The main() Function

A sample main() function has been provided to get you started.

int main(void) {
    print_welcome();

    struct tile board[ROWS][COLS];
    initialise_board(board);

    print_board(board, NO_BARBARIAN, NO_BARBARIAN);

    return 0;
}

Printing a Welcome Message

The first statement calls a function which prints a welcome message followed by a blank line:

print_welcome();

Declaring the board Array

The next statement declares the game board.

struct tile board[ROWS][COLS];

This means that board is a two-dimensional ROWS-by-COLS array, where each element is a struct tile.

struct tile {
    enum entity entity;
    int attack;
    int health;
};

Each struct tile currently contains three fields, an enum entity, int attack, and int health. This allows each element of the board array to store a game feature (e.g. the Barbarian, a Wall, a Cannon, or the Town Hall), an attack value, and current health.

enum entity {
    TOWN_HALL,
    WALL,
    CANNON,
    ARCHER_TOWER,
    BOMB,
    BOMB_TOWER,
    EMPTY,
    DESTROYED,
    WIZARD,
    FIRE,
    ANGRY_BARBARIAN
};

Each entity corresponds to a feature and a symbol that appears when the board is printed to the terminal:

 Entity Feature Symbol
TOWN_HALL Town Hall /#\
WALL Wall [#]
CANNON Cannon o-=
ARCHER_TOWER Archer Tower -)>
BOMB Bomb (*)
BOMB_TOWER Bomb Tower [*]
EMPTY Empty  . 
DESTROYED Destroyed Building /-\
WIZARD Wizard ~$~
FIRE Fire }^{
ANGRY_BARBARIAN Angry Barbarian >!<

Using the board Array

We can use row and column indices to access board elements.

For example:

  • board[2][3] accesses the struct tile at row 2 and column 3.
  • board[2][3].entity accesses the enum entity of this struct tile.
  • board[2][3].attack accesses the attack value of this struct tile.
  • board[2][3].health accesses the current health of this struct tile.

Similarly:

  • board[8][1] accesses the struct tile at row 8 and column 1.
  • board[8][1].entity accesses the enum entity of this struct tile.
  • board[8][1].attack accesses the attack value of this struct tile.
  • board[8][1].health accesses the current health of this struct tile.

Figure 1 demonstrates how row and column indices can be used to access elements on the game board.

Accessing Array Elements

Figure 1. Accessing entities on the board.

Initialising the board Array

At this point, we have a board array, but it hasn't been initialised with any values. The next statement passes the newly-declared board array to the provided initialise_board() function. This gives every tile entity an initial value of EMPTY and every tile an initial attack/health value of 0:

initialise_board(board);

Printing the Game

Before exiting, main() prints the board in the terminal:

+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+

It does this with the provided print_board() function.

print_board(board, NO_BARBARIAN, NO_BARBARIAN);

The print_board() function takes the following arguments:

  1. The board array.
  2. The row position of the Barbarian. Since the Barbarian has not yet been placed on the board, we use the #define'd constant NO_BARBARIAN.
  3. The column position of the Barbarian. Since the Barbarian has not yet been placed on the board, we use the #define'd constant NO_BARBARIAN.

You will need to know how to use print_board() with different values. For example:

  • print_board(board, 2, 9) displays the board with the Barbarian at row 2, column 9.
  • print_board(board, 0, 5) displays the board with the Barbarian at row 0, column 5.

print_board() checks the enum entity of each struct tile to determine which feature to print. You don't need to understand how it works before starting the assignment.

Other Provided Functions

There are six more provided functions:

  • print_win_message() is a helper function called when the game is won. You will need to use it in your code in Stage 2.5.
  • print_loss_message() is a helper function called when the game is lost. You will need to use it in your code in Stage 3.2.
  • print_board_line() is a helper function called by print_board(). You will not need to use it in your code.
  • print_board_header() is a helper function called by print_board(). You will not need to use it in your code.
  • print_tile_spacer() is a helper function called by print_board(). You will not need to use it in your code.
  • get_name_from_type() is a helper function called by print_entity_stats() and print_win_message(). It converts a given enum to a readable output (string). You will not need to use it in your code.

FAQ

Q: Can I edit the provided code?

Yes! Feel free to modify/replace/discard any of the provided:

  • #define constants,
  • enums,
  • structs, and
  • functions.

For example: you may wish to add fields to the provided struct tile definition.

You are also encouraged to create your own constants, enums, structs, and helper functions.

Q: Can I use pointers?

Yes! You can use pointers, although, they're not required. It's possible to complete every stage of the assignment without using pointers.

Q: Can I use X other C feature?

For everything not taught in the course, check the Style Guide:

  • If the guide says "avoid", it may incur a style mark penalty if not used correctly.
  • If the guide says "illegal" or "do not use", it will result in a style mark penalty (see the Style Marking Rubric).

These rules exist to ensure that everyone develops the required foundational knowledge and to maintain a level playing field for all students.

Stages

The assignment has been divided into incremental stages.

Stage 1: Setup Phase

  • Stage 1.1 - Spawn Barbarian.
  • Stage 1.2 - Validate Barbarian Spawn.
  • Stage 1.3 - Add Simple Entities (Cannon, Archer Tower, Bomb, Bomb Tower & Town Hall).
  • Stage 1.4 - Add Complex Entities (Walls).
  • Stage 1.5 - Validate Entity Spawns.

Stage 2: Gameplay Phase (Barbarian Turn)

  • Stage 2.1 - Barbarian Movement.
  • Stage 2.2 - Validate Barbarian Movement & Attacking.
  • Stage 2.3 - Entity Information.
  • Stage 2.4 - Upgrades.
  • Stage 2.5 - Winning The Battle.

Stage 3: Gameplay Phase (Barbarian Turn + Extra Mechanics)

  • Stage 3.1 - Defence.
  • Stage 3.2 - Losing the Battle.
  • Stage 3.3 - Special Ability.
  • Stage 3.4 - Chain Attacks.

Stage 4: Gameplay Phase (Extra Mechanics)

  • Stage 4.1 - Wizard.
  • Stage 4.2 - King Ability.

Extension (not for marks)

  • SplashKit - Create and Share a Graphical User Interface.

Your Tasks

This assignment consists of four stages. Each stage builds on the work of the previous stage, and each stage has a higher complexity than its predecessor. You should complete the stages in order.

A video explanation to help you get started with the assignment can be found here:

Stage 1

In Stage 1, you will implement the Setup Phase of CS Clash. This milestone has been divided into five substages:

  • Stage 1.1 - Spawn Barbarian.
  • Stage 1.2 - Validate Barbarian Spawn.
  • Stage 1.3 - Add Simple Entities (Cannon, Archer Tower, Bomb, Bomb Tower & Town Hall).
  • Stage 1.4 - Add Complex Entities (Walls).
  • Stage 1.5 - Validate Entity Spawns.

Stage 1.1 - Spawn Barbarian

Task

The first step of the Setup Phase is to spawn the mighty Barbarian. By the end of this substage, your program will prompt the user for the Barbarian's starting position, and then display the Barbarian on the game board.

The starter code:

  • Prints a welcome message to CS Clash.
  • Declares the board array.
  • Initialises the board by setting every tile's entity to be EMPTY and every tile's attack/health to 0.
  • Prints the board without showing the Barbarian.

A description of the starter code can be found in Starter Code and Data Structures.

Description

In this substage, you will modify the starter code to:

  1. Print a heading indicating the start of the Setup Phase:

    "============== Setup Phase ==============\n".

  2. Prompt the user: "Enter the Barbarian's starting position: ".

  3. Scan in two integers [row] [col] as the Barbarian's starting position.

  4. Use the provided print_board() function to display the game board with the Barbarian's position.

  5. Exit the program by returning 0 from main().

For example, if the starting position entered is (5, 5), the Barbarian should appear on the board like so:

Assumptions / Restrictions / Clarifications

When your code is tested in this substage:

  • Only valid array indexes will be used. No out-of-bounds values will be entered for row or col.

For this substage and all future substages:

  • The [row] and [col] entered will always be integers.

Examples

Input:

5 5

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 5 5
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+

Autotest

Stage 1.2 - Validate Barbarian Spawn

Task

In the previous substage, your program allowed the Barbarian to spawn anywhere on the game board. But what happens if the user attempts to spawn the Barbarian outside of the board boundaries?

Give it a try! Test your program with row and column inputs such as 8 15, or -1 6. Should the program allow this?

Description

In this substage, you will modify your Stage 1.1 implementation to handle invalid inputs:

  • A valid spawn position is one that is within the board boundaries.
  • An invalid spawn position is one that is outside the board boundaries.

You will need to:

  1. Create a loop to repeatedly prompt the user for the Barbarian's starting position until a valid position is entered.
  2. If the position entered is invalid:
    • Print "The Barbarian cannot start here!\n".
    • Prompt the user for another starting position by printing "Enter the Barbarian's starting position: ".
  3. Otherwise, if the position is valid:
    • End the loop.
    • Use the provided print_board() function to display the board.
    • Exit the program by returning 0 from the main() function.

Assumptions / Restrictions / Clarifications

  • None

Examples

Input:

0 -1
8 15
-1 6
3 4

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 -1
The Barbarian cannot start here!
Enter the Barbarian's starting position: 8 15
The Barbarian cannot start here!
Enter the Barbarian's starting position: -1 6
The Barbarian cannot start here!
Enter the Barbarian's starting position: 3 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+

Autotest

Stage 1.3 - Add Simple Entities

Task

In the previous substage, your program spawned the Barbarian on the board and checked that the position of the Barbarian was within the bounds of the board. In this substage, the program should now continue with the Setup Phase by adding simple entities such as Cannons, Archer Towers, Bombs, Bomb Towers, and the Town Hall to the board.

Commands

c [row] [col]
a [row] [col]
b [row] [col]
B [row] [col]
t [row] [col]
e

Description

In the previous substage, you will have placed the Barbarian on the board and used the print_board() function to print out the board. In this substage, you will extend your program to:

  1. Prompt the user: "Enter setup commands:\n".
  2. Implement a Setup Loop to repeatedly read-in commands and add features to the board until e is pressed:
    • Given the command c [row] [col], add a CANNON to that tile and update the tile's Health and Attack values.
    • Given the command a [row] [col], add an ARCHER_TOWER to that tile and update the tile's Health and Attack values.
    • Given the command b [row] [col], add a BOMB to that tile and update the tile's Health and Attack values.
    • Given the command B [row] [col], add a BOMB_TOWER to that tile and update the tile's Health and Attack values.
    • Given the command t [row] [col], add a TOWN_HALL to that tile and update the tile's Health and Attack values.
  3. When the user enters e:
    • The Setup Loop should end.
    • The board should be displayed with the provided print_board() function.
    • The program should exit.

Defensive Entity Health and Attack Values:

Entity Type Health Value Attack Value
CANNON 50 15
ARCHER_TOWER 45 15
BOMB 0 15
BOMB_TOWER 30 15
TOWN_HALL 75 0

For example, if:

  • the starting position entered is (9, 3),
  • a cannon is added at position (1, 6),
  • an archer tower is added at position (9, 9),
  • a bomb is added at position (2, 2), and
  • a bomb tower is added at position (4, 5).

The board should appear as follows:

Assumptions / Restrictions / Clarifications

When your code is tested in this substage:

  • All entities will be placed within the map boundaries.
  • No entity will be placed at the same location as another entity.
  • No entity will be placed on the same tile as the Barbarian.
  • One singular TOWN_HALL entity will always be placed on the board.

For this substage and all future substages:

  • Invalid commands will not be tested. For example, a command M will never be entered.
  • Incomplete commands will not be tested. For example, when a c is entered, it will always be followed by a [row] and [col].
  • Commands will always be given arguments of the correct type. For example, [row] and [col] will always be integers.

Examples

Input:

1 1
t 7 7
e

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 1 1
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 7 7
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |/#\|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+

Input:

1 1
c 4 4
a 6 6
b 7 7
B 9 9
t 8 8
e

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 1 1
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
c 4 4
a 6 6
b 7 7
B 9 9
t 8 8
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |o-=|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |-)>|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |(*)|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |/#\|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |[*]|
+===+===+===+===+===+===+===+===+===+===+

Autotest

Stage 1.4 - Add Complex Entities

Task

You have created the Setup Loop and added support for simple features. In this substage, the Setup Phase should be extended to support more complicated entities such as Walls.

Commands

w [row] [col]
W [row] [col] [direction] [length]

Description

In this substage, you will extend your Setup Loop to handle two new commands:

  1. Given the command w [row] [col], add a WALL to that tile and update the tile's Health and Attack values.
  2. Given the command W [row] [col] [direction] [length], add a WALL to the prescribed tiles and update the tile's Health and Attack values. Walls should be added as per the following rules:
    • If the direction is h, add WALL to the tiles starting at [row] [col] and extending [length] tiles to the right.
    • If the direction is v, add WALL to the tiles starting at [row] [col] and extending [length] tiles upwards.
    • If the direction is u, add WALL to the tiles starting at [row] [col] and extending [length] tiles diagonally toward the top-right of the board.
    • If the direction is d, add WALL to the tiles starting at [row] [col] and extending [length] tiles diagonally toward the bottom-right of the board.

Wall Entity Health and Attack Values:

Entity Type Health Value Attack Value
WALL 0 0

Consistent with the previous stage, when the user enters e:

  • The Setup Loop should end.
  • The board should be displayed with the provided print_board() function.
  • The program should exit.

For example, if:

  • the starting position is (9, 3),
  • a Town Hall is added at position (1, 6),
  • a vertical wall of length 4 is added at position (4, 9),
  • a horizontal wall of length 4 is added at position (0, 5),
  • an up-diagonal wall of length 4 is added at position (9, 0), and
  • a down-diagonal wall of length 4 is added at position (0, 0).

The board should appear as follows:

Assumptions / Restrictions / Clarifications

  • [length] will always be a positive integer.
  • [length] includes the wall placed at [row] [col].
    • Therefore, if [length] = 5, a total of 5 Walls will be placed.

When your code is tested in this substage:

  • All entities will be placed within the map boundaries.
  • No entity will be placed at the same location as another entity.
  • No entity will be placed on the same tile as the Barbarian.
  • One singular TOWN_HALL entity will always be placed on the board.

Examples

Input:

9 9
t 4 4
w 6 6
e

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 9 9
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 4 4
w 6 6
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+

Input:

9 9
t 4 4
W 4 2 u 3
W 4 5 v 3
e

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 9 9
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 4 4
W 4 2 u 3
W 4 5 v 3
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |[#]|[#]|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[#]|   |[#]|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |[#]|   |/#\|[#]|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+

Input:

9 9
t 8 8
W 4 9 v 4
W 0 5 h 4
W 9 0 u 4
W 0 0 d 4
e

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 9 9
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 8 8
W 4 9 v 4
W 0 5 h 4
W 9 0 u 4
W 0 0 d 4
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|[#]|   |   |   |   |[#]|[#]|[#]|[#]|   |
+---+---+---+---+---+---+---+---+---+---+
|   |[#]|   |   |   |   |   |   |   |[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |[#]|   |   |   |   |   |   |[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[#]|   |   |   |   |   |[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |[#]|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |[#]|   |   |   |   |   |   |/#\|   |
+---+---+---+---+---+---+---+---+---+---+
|[#]|   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+

Autotest

Stage 1.5 - Validate Entity Spawns

Task

During the previous substages, your program added features to the board. However, much like checking that the Barbarian's location is valid, how should the program handle placing a feature in an invalid position?

Description

In this substage, you will update your implementation of Stage 1.3 and 1.4 to ensure that features are only added in valid locations.

A tile is occupied if any of the following are true:

  • The Barbarian is located at the same position as the tile.
  • The tile's entity member is not EMPTY.

Now apply these new rules to your setup phase:

  1. If the user attempts to place an entity in a position that's not on the board:
    • Print "Invalid location: position is not on map!\n".
    • Continue reading the next command without adding the feature.
  2. If the user attempts to place an entity on an occupied tile:
    • Print "Invalid location: tile is occupied!\n".
    • Continue reading the next command without adding the feature.
  3. If the user attempts to place more than one TOWN_HALL entity:
    • Print "Max Limit Exceeded: only one Town Hall allowed.\n" once.
    • Continue reading the next command without adding the feature.
  4. If the user attempts to end the setup phase (by entering e) and a TOWN_HALL entity has not been added:
    • Print "Missing Entity: there is no Town Hall. Please enter a position for the Town Hall: ".
    • Create a loop to repeatedly scan a [row][col] for the TOWN_HALL.
    • Apply rule #1 and #2 to each provided [row][col].
    • Continue until a Town Hall is successfully placed on the board.
    • End the Setup Loop.

Assumptions / Restrictions / Clarifications

  • When using the long wall command W if any tile in the Wall's path:
    • falls outside the board: this satisfies rule #1.
    • is already occupied: this satisfies rule #2.
  • If rule #4 triggers, assume there will be at least one valid tile for the Town Hall to be placed.
  • If adding an entity would break multiple rules, only the error message for the lowest-numbered rule is triggered.

Examples

Input:

9 9
t 5 5
w 9 9
w 5 5
w -1 -1
w 10 10
e

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 9 9
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
w 9 9
Invalid location: tile is occupied!
w 5 5
Invalid location: tile is occupied!
w -1 -1
Invalid location: position is not on map!
w 10 10
Invalid location: position is not on map!
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+

Input:

9 9
w 5 5
e
7 7

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 9 9
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
w 5 5
e
Missing Entity: there is no Town Hall. Please enter a position for the Town Hall: 7 7
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |[#]|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |/#\|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+

Input:

9 9
t 5 5
t 5 5
t 6 6
W 5 0 h 6
W 4 0 h 10
W 3 0 h 11
e

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 9 9
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
t 5 5
Invalid location: tile is occupied!
t 6 6
Max Limit Exceeded: only one Town Hall allowed.
W 5 0 h 6
Invalid location: tile is occupied!
W 4 0 h 10
W 3 0 h 11
Invalid location: position is not on map!
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+===+===+===+===+===+===+===+===+===+===+

Autotest

Testing & Submission

Are you finished with this stage? If so, you should make sure to do the following:

  • Run 1511 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_clash.c
1511 autotest-stage 01 cs_clash
give cs1511 ass1_cs_clash cs_clash.c

Stage 2

In Stage 2, you will begin implementing the Gameplay Phase of CS Clash. This milestone has been divided into five substages:

  • Stage 2.1 - Barbarian Movement.
  • Stage 2.2 - Validate Barbarian Movement & Attacking.
  • Stage 2.3 - Entity Information.
  • Stage 2.4 - Upgrades.
  • Stage 2.5 - Winning the Battle.

Stage 2.1: Barbarian Movement

Task

The first step of the Gameplay Phase is to allow the Barbarian to move. By the end of this substage, your program will allow the user to control the Barbarian and guide them around the game board.

Commands

  • w moves the Barbarian up.
  • a moves the Barbarian left.
  • s moves the Barbarian down.
  • d moves the Barbarian right.
  • r counts as a move without changing the Barbarian's position on the board.

Description

In this substage, you will need to:

  1. Start the Gameplay Phase:

    • Print "============= Gameplay Phase ============\n". This indicates that the Setup Phase is complete, and the user can now start playing the game.
  2. Implement a Gameplay Loop to repeatedly read-in and handle user commands:

    • The first command to add to the Gameplay Loop is q to quit.
    • When the q command is entered by the user, the program should immediately:
      • Print "============= Quitting Game =============\n".
      • Exit without any other outputs.
  3. Move the Barbarian:

    • The next Gameplay Loop commands are Barbarian movements:
      • w moves the Barbarian up.
      • a moves the Barbarian left.
      • s moves the Barbarian down.
      • d moves the Barbarian right.
    • The Gameplay Loop should also handle a rest command:
      • r counts as a move without changing the Barbarian's position on the board.
  4. Finish Round

    • Display the board with the provided print_board() function. This completes the round.
    • Reminder: this is a Gameplay Loop. After each command is processed/handled, the program should continue to read and handle the next user command until q is pressed.

Assumptions / Restrictions / Clarifications

  • Each command will be followed by a newline character (\n) or the ENTER key.
  • When your code is tested in this substage:
    • No movement command will attempt to move the Barbarian onto an entity.
    • No movement command will attempt to move the Barbarian off the board.

Examples

Input:

5 5
t 4 4
e
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 5 5
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 4 4
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
q
============= Quitting Game =============

Input:

5 5
t 4 4
e
w
w
w
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 5 5
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 4 4
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
q
============= Quitting Game =============

Input:

5 5
t 4 4
e
w
w
a
a
r
s
s
d
d
r
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 5 5
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 4 4
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
r
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
r
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
q
============= Quitting Game =============

Autotest

Stage 2.2: Validate Barbarian Movement & Attacking

Task

In the previous substage, your program allowed the user to control the Barbarian’s movements. But what should happen if the Barbarian tries to move into an Entity or off the edge of the board?

Description

First, a destination is considered invalid if it meets any of the following conditions:

  • The tile is a position that is not on the board.
  • The tile contains a WALL entity.

If the Barbarian attempts to move to an invalid destination:

  • The Barbarian should not move.
  • End the Barbarian's turn and call print_board().
  • Wait for the user's next command, continuing the Gameplay Loop.

If the Barbarian attempts to move onto an entity that is not invalid nor an EMPTY, DESTROYED or BOMB entity, the Barbarian 'attacks' the entity:

  • The Barbarian should not change position.
  • The entity's health should decrease by the Barbarian's attack value. The Barbarian's attack value is 15.
  • If the entity's health drops to 0 or below, the tile changes to the DESTROYED entity.
  • End the Barbarian's turn and call print_board().
  • Wait for the user's next command, continuing the Gameplay Loop.

Assumptions / Restrictions / Clarifications

  • The Barbarian can walk over BOMB and DESTROYED tiles.
  • Immediately after destroying an entity and changing the tile to DESTROYED, the Barbarian does not move onto the tile.

Examples

Input:

1 1
t 4 4
e
w
w
a
a
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 1 1
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 4 4
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
q
============= Quitting Game =============

Input:

3 2
t 4 4
w 3 3
e
d
d
s
d
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 3 2
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 4 4
w 3 3
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
q
============= Quitting Game =============

Input:

3 2
t 4 4
a 3 3
e
d
d
d
d
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 3 2
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 4 4
a 3 3
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|-)>|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|-)>|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|-)>|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|:::|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |/#\|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
q
============= Quitting Game =============

Autotest

Stage 2.3: Entity Information

Task

Now that the Barbarian can attack and reduce the health of entities, we need a way to view the Barbarian's stats and the health of each entity. This will enable us to see how later mechanics interact with the Barbarian and entities on the board.

Commands

i [row] [col]
p

Description

Modify the Gameplay Loop to handle two new commands:

  1. Given the command i [row] [col], print out the information of the entity at the given [row] [col]. This includes:
    • Entity Type
    • Entity Row/Column
    • Entity Level
    • Entity Health
    • Entity Attack
    • Total Damage Inflicted (Implemented in 3.1)
  • If the provided [row][col] is out of bounds print "Invalid location: position is not on map!\n".
  • If the tile at the given position is EMPTY, print "Invalid location: No entity at given position.\n".
  1. Given the command p, print out the Barbarian's information. This includes:
    • Barbarian Health
    • Barbarian Attack
    • Barbarian Level
    • Number of Moves Taken
    • Number of Entities Destroyed

The Barbarian's Health is 100.

Assumptions / Restrictions / Clarifications

  • WALL, BOMB and DESTROYED entities should have a health value of 0.
  • TOWN_HALL, WALL, and DESTROYED entities should have an attack value of 0.
  • The Number of Moves Taken field should increase:
    • When the Barbarian moves from one tile to another.
    • On rest moves.
    • When attacking an entity.
  • The Number of Moves Taken field should not increase when:
    • A move is invalid.

During this stage's testing:

  • Total Damage Inflicted field will default to 0. This feature will be implemented in Stage 3.1.
  • The Barbarian and Entity Level field will default to 1. This feature will be implemented in Stage 2.4.

Examples

Input:

4 4
t 5 5
e
p
i 4 4
i 5 5
s
d
d
i 5 5
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 100                     |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 0                       |
|  Destroyed  : 0                       |
+=======================================+
i 4 4
Invalid location: No entity at given position.
i 5 5
+=======================================+
|         >> ENTITY REPORT <<           |
+=======================================+
|  Type     : Town Hall                 |
|  Position : ( 5,  5)                  |
|  Level    : 1                         |
+---------------------------------------+
|  Health   : 75                        |
|  Attack   : 0                         |
|  Damage   : 0                         |
+=======================================+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
i 5 5
+=======================================+
|         >> ENTITY REPORT <<           |
+=======================================+
|  Type     : Town Hall                 |
|  Position : ( 5,  5)                  |
|  Level    : 1                         |
+---------------------------------------+
|  Health   : 45                        |
|  Attack   : 0                         |
|  Damage   : 0                         |
+=======================================+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 100                     |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 3                       |
|  Destroyed  : 0                       |
+=======================================+
q
============= Quitting Game =============

Input:

4 4
t 5 5
e
p
s
d
d
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 100                     |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 0                       |
|  Destroyed  : 0                       |
+=======================================+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 100                     |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 3                       |
|  Destroyed  : 0                       |
+=======================================+
q
============= Quitting Game =============

Autotest

Stage 2.4: Upgrades

Task

It's time to make this more challenging! This stage will allow the user to upgrade the Barbarian and Entities during the setup phase.

Commands

U [levels]
u [row] [col] [levels]

Description

Modify the Setup Loop to handle two new commands:

  1. Given the command U [levels], increase the Barbarian's level by [levels].
  2. Given the command u [row] [col] [levels], increase the Entity at [row] [col] level by [levels].
    1. If the provided [row][col] is out of bounds print "Invalid location: position is not on map!\n".
    2. If there is no entity at the given position print "Invalid location: No entity at given position.\n".
    3. If the given [level] is zero or negative print "Invalid level: Level must be positive.\n".

The maximum level for the Barbarian and all entities is 18. If the level of the Barbarian or entity would exceed this:

  • Set the Barbarian or Entity's level to 18.

Each level increase adds 10 to the Barbarian or entity's health value and 5 to the Barbarian or entity's attack value.

  • To ensure accuracy, the attack values of WALL and TOWN_HALL entities cannot be increased.
  • To ensure accuracy, the health values of WALL and BOMB entities cannot be increased.

Assumptions / Restrictions / Clarifications

  • The Barbarian and all entities start at level 1.
  • All entities can be upgraded. This being said, health and attack values must be edited as specified.
  • You may upgrade the Barbarian or a single entity multiple times.
  • The board should not be printed after an upgrade command.
  • If attempting an upgrade would break multiple rules, only the error message for the lowest-numbered rule is triggered.
  • You cannot upgrade an EMPTY or DESTROYED. Attempting to do so should trigger rule #2.

Examples

Input:

4 4
t 5 5
u 10 10
u -1 -1
e
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
u 10 10
u -1 -1
Invalid location: position is not on map!
e
Invalid location: position is not on map!
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
q
============= Quitting Game =============

Input:

4 4
t 5 5
u 5 5 -1
U -1
e
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
u 5 5 -1
Invalid level: Level must be positive.
U -1
Invalid level: Level must be positive.
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
q
============= Quitting Game =============

Input:

4 4
t 5 5
U 1
e
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
U 1
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 110                     |
|  Attack     : 20                      |
|  Level      : 2                       |
+---------------------------------------+
|  Moves      : 0                       |
|  Destroyed  : 0                       |
+=======================================+
q
============= Quitting Game =============

Input:

4 4
t 5 5
a 8 8
c 9 9
U 5
u 5 5 10
u 8 8 20
u 9 9 30
e
p
i 5 5
i 8 8
i 9 9
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
a 8 8
c 9 9
U 5
u 5 5 10
u 8 8 20
u 9 9 30
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |-)>|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |o-=|
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 150                     |
|  Attack     : 40                      |
|  Level      : 6                       |
+---------------------------------------+
|  Moves      : 0                       |
|  Destroyed  : 0                       |
+=======================================+
i 5 5
+=======================================+
|         >> ENTITY REPORT <<           |
+=======================================+
|  Type     : Town Hall                 |
|  Position : ( 5,  5)                  |
|  Level    : 11                        |
+---------------------------------------+
|  Health   : 175                       |
|  Attack   : 0                         |
|  Damage   : 0                         |
+=======================================+
i 8 8
+=======================================+
|         >> ENTITY REPORT <<           |
+=======================================+
|  Type     : Archer Tower              |
|  Position : ( 8,  8)                  |
|  Level    : 18                        |
+---------------------------------------+
|  Health   : 215                       |
|  Attack   : 100                       |
|  Damage   : 0                         |
+=======================================+
i 9 9
+=======================================+
|         >> ENTITY REPORT <<           |
+=======================================+
|  Type     : Cannon                    |
|  Position : ( 9,  9)                  |
|  Level    : 18                        |
+---------------------------------------+
|  Health   : 220                       |
|  Attack   : 100                       |
|  Damage   : 0                         |
+=======================================+
q
============= Quitting Game =============

Autotest

Stage 2.5 - Winning the Battle

Task

In previous substages, the Barbarian moved around the board and gained the ability to attack and destroy entities. By the end of this stage, your program will allow the Barbarian to win the game.

Description

In this substage, you will need to: Modify the Gameplay Loop to check if the Barbarian has won the game. This occurs when:

  • The TOWN_HALL entity's health drops to or below 0 and becomes DESTROYED:
    • Call the print_win_message() function to print out a message.
    • Call the print_board() function to print out the game board.
    • Print out the Barbarian Information via the print_barbarian_stats() function.
    • Terminate the program.

Assumptions / Restrictions / Clarifications

  • None

Examples

Input:

4 4
t 5 5
e
s
d
d
d
d
d

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+=======================================+
|    *** VICTORY - 3 STAR RAID! ***     |
+=======================================+
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|:::|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 100                     |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 6                       |
|  Destroyed  : 1                       |
+=======================================+

Input:

4 4
t 5 5
U 20
e
s
d

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
U 20
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+=======================================+
|    *** VICTORY - 3 STAR RAID! ***     |
+=======================================+
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|:::|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 270                     |
|  Attack     : 100                     |
|  Level      : 18                      |
+---------------------------------------+
|  Moves      : 2                       |
|  Destroyed  : 1                       |
+=======================================+

Autotest

Testing & Submission

Are you finished with this stage? If so, you should make sure to do the following:

  • Run 1511 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_clash.c
1511 autotest-stage 02 cs_clash
give cs1511 ass1_cs_clash cs_clash.c

Stage 3

In Stage 3, you will continue implementing the Gameplay Phase of CS Clash. This milestone has been divided into four substages:

  • Stage 3.1 - Defence.
  • Stage 3.2 - Losing the Battle.
  • Stage 3.3 - Special Ability.
  • Stage 3.4 - Chain Attacks.

By the end of this stage, you will have brought the core features of CS Clash to life, allowing it to stand on its own while still leaving room for additional features!

Stage 3.1 - Defence

Task

Life is a little too easy for the Barbarian at the moment... It's time for the entities to fire back!

Description

This substage will allow the BOMB, BOMB_TOWER, CANNON, and ARCHER_TOWER entities to deal damage to the Barbarian. Whenever the Barbarian moves (including a rest move):

  • If within range, the CANNON will decrease the Barbarian Health by the CANNON's Attack value.
  • If within range, the ARCHER_TOWER will decrease the Barbarian Health by the ARCHER_TOWER's Attack value.
  • If the Barbarian steps onto a tile with the BOMB entity, the bomb will explode, decreasing the Barbarian Health by the BOMB's Attack value. The tile will then become EMPTY.
  • When the BOMB_TOWER entity is destroyed, it drops a bomb that will affect its surrounding tiles, decreasing the Barbarian Health by the BOMB_TOWER's Attack value.

The ranges of the above mentioned entities are defined as below.

  • The range of a CANNON is a square with centre [row][col] and side length 3.
  • The range of the ARCHER_TOWER is a square with centre [row][col] and side length 5.
  • The range of the explosion when a BOMB_TOWER is destroyed is a square with centre [row][col] and side length 3.

When printing out entity information via the i command, the Damage Inflicted field should represent the amount of damage inflicted on the Barbarian by the entity on a specific tile.

  • If an entity is destroyed, its Damage Inflicted field should be reset to 0.
  • As BOMB entities deal damage when they are removed from the board and BOMB_TOWER entities deal damage when they are destroyed, their Damage Inflicted field remains at 0.

For example,

Assumptions / Restrictions / Clarifications

  • The attack radii of Entities can overlap, meaning a Barbarian can be hit by multiple Entities in a turn. In this case, the order of attack is:
    1. BOMB
    2. Explosion from BOMB_TOWER
    3. CANNON
    4. ARCHER_TOWER
  • Walls do not disrupt the range of Entities.
  • Defences only attack after the Barbarian moves successfully. This means the Barbarian's Number of Moves Taken field is increased.
  • As each entity can be upgraded, each entity's attack can vary.
  • Moving onto a BOMB entity and causing it to explode does not add to the Barbarian's Destroyed Entity count.

Examples

Input:

4 4
t 5 5
c 4 5
e
a
d
p
w
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
c 4 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 85                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 2                       |
|  Destroyed  : 0                       |
+=======================================+
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 70                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 3                       |
|  Destroyed  : 0                       |
+=======================================+
q
============= Quitting Game =============

Input:

4 4
t 5 5
c 4 5
a 3 5
b 3 4
e
a
p
w
p
d
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 4 4
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
c 4 5
a 3 5
b 3 4
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |(*)|-)>|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |(*)|-)>|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 85                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 1                       |
|  Destroyed  : 0                       |
+=======================================+
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|(*)|-)>|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 70                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 2                       |
|  Destroyed  : 0                       |
+=======================================+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|-)>|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 25                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 3                       |
|  Destroyed  : 0                       |
+=======================================+
q
============= Quitting Game =============

Input:

1 1
t 9 9
B 1 2
e
d
d
p
d
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 1 1
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 9 9
B 1 2
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|[*]|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|[*]|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|:::|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 85                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 2                       |
|  Destroyed  : 1                       |
+=======================================+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 85                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 3                       |
|  Destroyed  : 1                       |
+=======================================+
q
============= Quitting Game =============

Autotest

Stage 3.2 - Losing the Battle

Task

Previously, we have allowed for the Barbarian to win the game by destroying the Town Hall. How could the Barbarian lose the game?

Description

In this substage, you will need to:

Modify the Gameplay Loop to check if the Barbarian has lost the game. This occurs when:

  • The Barbarian's health drops to or below 0. When this occurs:
    • Call the print_loss_message() function to print out a message. This message should contain the type of entity that dealt the finishing blow.
    • Call the print_board() function to print out the game board.
    • Print out the Barbarian Information via the print_barbarian_stats() function.
    • Terminate the program.

Assumptions / Restrictions / Clarifications

  • When displaying the Barbarian's stats upon a loss, the Barbarian's health should be 0 even if its health value was below this upon the turn's end.

Examples

Input:

1 1
t 9 9
b 1 2
b 1 3
b 1 4
b 1 5
b 1 6
b 1 7
b 1 8
e
d
d
d
d
d
d
d

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 1 1
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 9 9
b 1 2
b 1 3
b 1 4
b 1 5
b 1 6
b 1 7
b 1 8
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|(*)|(*)|(*)|(*)|(*)|(*)|(*)|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|(*)|(*)|(*)|(*)|(*)|(*)|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|(*)|(*)|(*)|(*)|(*)|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|(*)|(*)|(*)|(*)|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|(*)|(*)|(*)|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |>o<|(*)|(*)|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |>o<|(*)|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+=======================================+
        >> Slain by a Bomb! <<
+=======================================+
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |>o<|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 0                       |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 7                       |
|  Destroyed  : 0                       |
+=======================================+

Autotest

Stage 3.3 - Special Ability

Task

Now that the Barbarian is fighting to stay in the game, they can receive some extra help through the activation of a special ability.

Command

x

Description

The x command activates an ability which grants the Barbarian two perks during their next turn:

  1. They are immune to damage:
    • This means the Barbarian cannot be damaged by the BOMB, CANNON, ARCHER_TOWER, and BOMB_TOWER Entities.
  2. They can jump over walls:
    • If the Barbarian is on a tile adjacent to a wall and they move towards it, they will appear on the other side of the wall. This counts as one move.
    • The Barbarian can jump over a maximum of 3 walls at once, as long as they are all adjacent WALL tiles and the Barbarian lands on an EMPTY tile. The walls must be consecutive in the direction of movement (i.e. in a straight line). An L-shaped or diagonal arrangement cannot be jumped over.
    • If there are 4 walls, they are unable to complete the jump and should stay at their original position.
    • The Barbarian cannot jump off the edge of the board.

When activating the ability print "Special Ability Activated\n". The board should not be printed.

The Barbarian must be at least level 5 to use this ability. If the Barbarian is level 4 or below:

  • Print "Unable to use Ability: Barbarian Level is too low to use this ability.\n".
  • Do not activate the ability.

The Barbarian can only use the ability once. If the Barbarian attempts to use the ability for a second time:

  • Print "Unable to use Ability: Ability has already been used.\n".
  • Do not activate the ability.

If the Barbarian attempts to use the ability while it is currently active (and waiting on the Barbarian to move):

  • Print "Unable to use Ability: Ability has already been used.\n".
  • The ability remains active, waiting for the Barbarian to move.

Assumptions / Restrictions / Clarifications

  • Activating the Special Ability does not act as a move and therefore does not trigger the defences to activate.
  • If the Barbarian attempts to move, the ability is spent, its effects are removed, and the Barbarian's Number of Moves Taken field increases. This includes:
    • When a move is successful (i.e. the Barbarian moves to a different tile, attacks an entity or jumps over a wall).
    • When a move is unsuccessful (i.e. they attempt to jump over 4 walls or the move is blocked by the edge of the board).
    • The Barbarian moves yet no entity attacks the Barbarian.
    • When rest move is used.
  • Printing out entity or Barbarian information does not consume the ability or remove its effects.
  • If the Wall Jump fails due to a tile being occupied by an entity, the Barbarian does not attack the entity.

Examples

Input:

0 0
t 5 5
e
x
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 0
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
t 5 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
x
Unable to use Ability: Barbarian Level is too low to use this ability.
q
============= Quitting Game =============

Input:

0 0
c 0 1
t 5 5
U 5
e
s
x
d
d
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 0
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
c 0 1
t 5 5
U 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|o-=|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |o-=|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
x
Special Ability Activated
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |o-=|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |o-=|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 120                     |
|  Attack     : 40                      |
|  Level      : 6                       |
+---------------------------------------+
|  Moves      : 3                       |
|  Destroyed  : 0                       |
+=======================================+
q
============= Quitting Game =============

Input:

0 0
W 0 1 h 3
t 5 5
U 5
e
d
x
d
a
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 0
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
W 0 1 h 3
t 5 5
U 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
x
Special Ability Activated
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |[#]|[#]|[#]|>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |[#]|[#]|[#]|>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 150                     |
|  Attack     : 40                      |
|  Level      : 6                       |
+---------------------------------------+
|  Moves      : 1                       |
|  Destroyed  : 0                       |
+=======================================+
q
============= Quitting Game =============

Input:

0 6
W 0 7 h 3
t 5 5
a 2 6
U 5
e
x
p
d
p
s
p
x
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 6
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |>o<|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
W 0 7 h 3
t 5 5
a 2 6
U 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |>o<|[#]|[#]|[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |-)>|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
x
Special Ability Activated
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 150                     |
|  Attack     : 40                      |
|  Level      : 6                       |
+---------------------------------------+
|  Moves      : 0                       |
|  Destroyed  : 0                       |
+=======================================+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |>o<|[#]|[#]|[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |-)>|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 150                     |
|  Attack     : 40                      |
|  Level      : 6                       |
+---------------------------------------+
|  Moves      : 1                       |
|  Destroyed  : 0                       |
+=======================================+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |[#]|[#]|[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |>o<|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |-)>|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 135                     |
|  Attack     : 40                      |
|  Level      : 6                       |
+---------------------------------------+
|  Moves      : 2                       |
|  Destroyed  : 0                       |
+=======================================+
x
Unable to use Ability: Ability has already been used.
q
============= Quitting Game =============

Autotest

Stage 3.4 - Chain Attacks

Task

We will now introduce an advanced attack to allow the Barbarian a fighting chance against levelled up entities. This attack will let the Barbarian's attack chain through multiple entities.

Description

The Chain Attack will be applied to every movement where the Barbarian attempts to move into or 'attack' an entity.

If the Barbarian would move into an entity that is not out of bounds, EMPTY, DESTROYED or a BOMB, the Barbarian 'attacks' the entity with the Chain Attack:

  • Attacks may chain through: WALL, TOWN_HALL, CANNON, ARCHER_TOWER, and BOMB_TOWER entities. WALL entities are unaffected by damage, but allow for the chain attack to pass through them.
  • The number of ‘chains’ or entities the attack passes through is equal to: Barbarian’s level - 8. This means:
Barbarian Level Number of Attacks Note
Level 9 1 Attack Attacks like normal
Level 10 2 Attacks Attacks 1 entity then chains to attack 1 more entity
Level 11 3 Attacks Attacks 1 entity then chains to attack 2 more entities
Level 18 10 Attacks Attacks 1 entity then chains to attack 9 more entities
  • When chaining, the next entity to attack is determined by checking cells adjacent to the most recently attacked entity, using the priority order: Up, Right, Down, Left. The first valid entity found in that order is attacked next.
  • Each entity in the chain can only be attacked once per turn, and the chain cannot revisit an entity already attacked or passed through in the same chain.
  • If there is no valid entity to chain to, all unused attacks are discarded and the move is concluded.

Imagine a Barbarian is Level 18 and a board set up as below. The chain follows the Green Arrow due to the Up, Right, Down, Left priority order.

Assumptions / Restrictions / Clarifications

  • The Barbarian must be level 10 or above for this attack to activate.
  • If an entity is damaged by the chain and its health goes to 0 or below, it is destroyed.
  • The chain cannot pass through EMPTY, BOMB, or DESTROYED entities.
  • If the special ability is activated and the Barbarian attempts to move into a wall, the wall jump ability takes precedence over chaining. If the wall jump ability fails, do not attempt a chain attack.
  • Attempting to move off the board does not count as a move.
  • Attempting a chain attack counts as a move and is defined as a successful move. Attempting a chain attack includes when:
    • The Barbarian doesn't change positions due to moving into an entity.
    • The Barbarian moves into a WALL entity.
    • The Barbarian does not deal any damage to entities during the chain attack (attacks only WALL entities).

Examples

Input:

0 0
W 0 1 h 9
t 1 9
U 20
u 1 9 20
e
d
i 0 0
i 1 9
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 0
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
W 0 1 h 9
t 1 9
U 20
u 1 9 20
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
i 0 0
Invalid location: No entity at given position.
i 1 9
+=======================================+
|         >> ENTITY REPORT <<           |
+=======================================+
|  Type     : Town Hall                 |
|  Position : ( 1,  9)                  |
|  Level    : 18                        |
+---------------------------------------+
|  Health   : 145                       |
|  Attack   : 0                         |
|  Damage   : 0                         |
+=======================================+
q
============= Quitting Game =============

Input:

0 0
W 0 1 h 9
w 1 9
t 2 9
U 20
u 2 9 20
e
d
i 0 0
i 1 9
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 0
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
W 0 1 h 9
w 1 9
t 2 9
U 20
u 2 9 20
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |[#]|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
i 0 0
Invalid location: No entity at given position.
i 1 9
+=======================================+
|         >> ENTITY REPORT <<           |
+=======================================+
|  Type     : Wall                      |
|  Position : ( 1,  9)                  |
|  Level    : 1                         |
+---------------------------------------+
|  Health   : 0                         |
|  Attack   : 0                         |
|  Damage   : 0                         |
+=======================================+
q
============= Quitting Game =============

Input:

5 0
W 5 1 h 5
W 3 4 h 3
w 3 3
w 4 4
w 2 5
w 6 3
U 20
t 9 9
B 7 3
B 5 6
B 3 2
B 3 7
B 1 5
e
d
d
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 5 0
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
W 5 1 h 5
W 3 4 h 3
w 3 3
w 4 4
w 2 5
w 6 3
U 20
t 9 9
B 7 3
B 5 6
B 3 2
B 3 7
B 1 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |[*]|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |[#]|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |[*]|[#]|[#]|[#]|[#]|[*]|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |[#]|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|[#]|[#]|[*]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[*]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |:::|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |[#]|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |[*]|[#]|[#]|[#]|[#]|[*]|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |[#]|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|[#]|[#]|[*]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[*]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |:::|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |[#]|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |[*]|[#]|[#]|[#]|[#]|[*]|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |[#]|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|>o<|[#]|[#]|[#]|[#]|[#]|[*]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[#]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |[*]|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
q
============= Quitting Game =============

Autotest

Testing & Submission

Are you finished with this stage? If so, you should make sure to do the following:

  • Run 1511 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_clash.c
1511 autotest-stage 03 cs_clash
give cs1511 ass1_cs_clash cs_clash.c

Stage 4

Welcome to Stage 4! In this stage you will have the opportunity to extend the core functionality of CS Clash with some advanced features. This milestone consists of two substages:

  • Stage 4.1 - Wizard.
  • Stage 4.2 - King Ability.

Stage 4.1 - Wizard

Task

The Barbarian has been wreaking havoc, so it's time to call in some reinforcements. The Wizard has been called upon to make life tricky for the Barbarian by spreading fire across the board.

Command

Z [row] [col]

Description

In this substage, you will need to add the Z command to the Setup loop. Given the command Z [row] [col], add a WIZARD to that tile. The WIZARD can be upgraded according to the rules outlined in Stage 2.4.

Wizard Entity Health and Attack Values:

Entity Type Health Value Attack Value
WIZARD 70 30

Fire Spread

Each time the Barbarian completes a successful move (the Barbarian's Number of Moves Taken field increases), the WIZARD taps their staff, emitting a ring of fire centred on the Wizard's position:

  • Every EMPTY tile on the ring is replaced with a FIRE entity. Tiles out of bounds or with existing entities are unaffected.
  • When the WIZARD is spawned during the setup phase, the ring's radius is 0. During the gameplay loop, it increases by 1 with each staff tap, up to a maximum of 2.
  • Once the maximum radius is reached, subsequent taps no longer emit new fire. Instead, they only advance the lifespan of existing FIRE entities.
  • Each FIRE entity persists for two staff taps before reverting to EMPTY. Once all FIRE entities have reverted to EMPTY, the ring's radius resets to 0 and the cycle begins again on the next staff tap.
  • The WIZARD taps their staff immediately before the Barbarian moves. The WIZARD knows the Barbarian's move ahead of time and will only tap their staff if the Barbarian will move successfully. This means either moving onto a new tile, or attacking an entity.

The propagation of fire each time the Wizard taps their staff looks like:

Fire Damage

During the Entity Damage phase, if the Barbarian occupies a tile containing a FIRE entity, the Barbarian is set on fire. Being on fire applies damage over three turns, scaled to the Wizard's attack.

Turn Damage Dealt
Immediately 2/5 Wizard Attack
+1 turn 2/5 Wizard Attack
+2 turns 1/5 Wizard Attack
  • The attack value of a FIRE entity is equal to the attack of the WIZARD entity that spawned it. Its health should be set to 0 and its level should be set to 1.
  • Stepping off the fire does not extinguish the Barbarian who will continue to burn for the remaining turns.
  • Remaining on or re-entering a FIRE tile resets the burn, restarting the damage loop using the attack value of the WIZARD that spawned the tile.
  • A Barbarian standing in a FIRE tile across multiple turns (e.g. using the rest command r) takes 2/5 of the Wizard's attack every turn.
  • When a FIRE entity inflicts damage, the WIZARD who spawned it has their Damage Inflicted field increased by the amount dealt that turn.
  • If a FIRE entity deals the killing blow, the loss message should state the Barbarian was killed by Fire.

Assumptions / Restrictions / Clarifications

  • If the Barbarian is affected by FIRE damage, the priority order is:
    1. BOMB
    2. Explosion from BOMB_TOWER
    3. CANNON
    4. ARCHER_TOWER
    5. FIRE
  • All entities excluding the Barbarian are unaffected by FIRE tiles.
  • The special ability grants the Barbarian immunity to fire damage for one turn only. This turn does not advance the fire's turn counter, meaning the full three turns of damage are dealt even if the Barbarian gains a turn of immunity while already on fire. The special ability does not prevent the Barbarian from being set on fire.
  • Chain attacks can pass through WIZARD entities but cannot pass through FIRE entities.
  • If the WIZARD entity is killed, change the tile to the DESTROYED entity. The FIRE entities it spawned will continue their lifecycle as if the WIZARD was present to tap their staff. If the FIRE entity deals damage, the Damage Inflicted field of the DESTROYED entity should remain 0.
  • If the fire rings of multiple WIZARD entities overlap, overlapping FIRE entities will refresh. In the case that the WIZARD entities have different damage values, assign the FIRE entity's attack value to the highest one.
    • When deciding which WIZARD to credit a FIRE entity's damage inflicted to, give it to the WIZARD with the highest attack value. If multiple share the same attack, give it to the WIZARD with the leftmost position on the board, then the topmost position on the board.

Examples

Input:

2 2
Z 5 5
w 5 6
t 9 9
e
d
d
d
d
d
d
d
s
s
s
s
s
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 2 2
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
Z 5 5
w 5 6
t 9 9
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |>o<|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |>o<|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |>o<|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |>o<|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |>o<|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |>o<|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |~$~|[#]|   |   |>o<|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |>o<|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |>o<|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
q
============= Quitting Game =============

Input:

2 2
Z 5 5
w 5 6
t 9 9
e
d
d
s
s
p
a
a
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 2 2
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
Z 5 5
w 5 6
t 9 9
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|>o<|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|>o<|   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |~$~|[#]|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 76                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 4                       |
|  Destroyed  : 0                       |
+=======================================+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|~$~|[#]|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 70                      |
|  Attack     : 15                      |
|  Level      : 1                       |
+---------------------------------------+
|  Moves      : 6                       |
|  Destroyed  : 0                       |
+=======================================+
q
============= Quitting Game =============

Autotest

Stage 4.2 - King Ability

Task

In response to the arrival of the Wizard, the Barbarian needs to up their game. In fact, the Barbarian is going to activate the King ability.

Command

K

Description

In this substage, you will need to:

  • Add the K command to the Gameplay loop. Given the command K, activate the 'King Ability'.

The ability will not be activated if:

  1. If the Barbarian's health is at or above 50%. In this case print "Unable to use Ability: Health not below 50%% threshold.\n".
  2. If the Barbarian is level 4 or below. In this case print "Unable to use Ability: Barbarian Level is too low to use this ability.\n".
  3. If the Ability has already been used. In this case print "Unable to use Ability: Ability has already been used.\n".
  4. If the tile the ANGRY_BARBARIAN entity spawns on is occupied (not EMPTY). In this case print "Unable to use Ability: Angry Barbarian cannot be spawned.\n".

If the ability is activated:

  1. Grant the Barbarian 20% of their initial health.
  2. Spawn the Angry Barbarian by adding the ANGRY_BARBARIAN entity in the tile directly above the Barbarian.
  3. Call the print_board() function to print out the game board.
  4. Print "King Ability Activated\n".

Angry Barbarian

The ANGRY_BARBARIAN entity has the same health, attack, and level that the Barbarian had at the start of the gameplay phase. Each turn, the ANGRY_BARBARIAN will locate the closest attackable entity determined by the least number of moves to reach the entity when moving one tile per move. If multiple entities can be reached in the same number of moves, pick the entity with the leftmost position on the board, then the topmost position on the board. Each time the Barbarian moves, the ANGRY_BARBARIAN moves one tile closer to the closest attackable entity along this path. If two moves would bring the ANGRY_BARBARIAN equally close to its target, priority is given to vertical moves over horizontal moves in the specific order: up, down, left, right.

Attackable entities include:

  • TOWN_HALL
  • CANNON
  • ARCHER_TOWER
  • BOMB_TOWER
  • WIZARD

Note that the ANGRY_BARBARIAN cannot move onto several entities which include:

  • WALL
  • DESTROYED
  • FIRE (if implemented in Stage 4.1)
  • The Barbarian (which moves before the ANGRY_BARBARIAN)

As the ANGRY_BARBARIAN calculates the closest attackable entity at the start of each turn, the closest entity can change from turn to turn. The Barbarian moves and attacks before the ANGRY_BARBARIAN chooses its path. The game loop should look like:

Now that there are two ‘attacking’ entities, the CANNON and ARCHER_TOWER entities must decide which to attack. If both ANGRY_BARBARIAN and Barbarian are in range, the ANGRY_BARBARIAN takes priority meaning the Barbarian is not hit. BOMB and BOMB_TOWER damage can affect both the ANGRY_BARBARIAN and Barbarian if they are both in-range.

For example:

In this example, the ANGRY_BARBARIAN follows the green arrows. While there are several equidistant paths to the CANNON entity, at each point the ANGRY_BARBARIAN prioritises the move in the vertical (up) direction.

When the ANGRY_BARBARIAN is removed from the board, each tile (including the ANGRY_BARBARIAN's spawn tile and the tile it was removed from) it visited becomes a FIRE entity. These fire entities have the behaviour defined in Stage 4.1 regarding lifespan and damage. Each FIRE entity's damage should scale to the ANGRY_BARBARIAN's attack value. If damage from a FIRE entity spawned by this mechanic causes the Barbarian to lose the game, the loss message should state the Barbarian was killed by Fire.

  • If any of the tiles on this path are already FIRE entities spawned by a WIZARD, the overlapping FIRE entities will refresh. The attack value of the overlapping FIRE entities will be modified to be the larger of the WIZARD or the now removed ANGRY_BARBARIAN. If they are equal, the attack value remains the same and damage inflicted by the FIRE is given to the WIZARD that spawned it.

The ANGRY_BARBARIAN is fireproof. This means FIRE entities cannot damage the ANGRY_BARBARIAN or move onto the ANGRY_BARBARIAN's tile when the WIZARD taps their staff.

Assumptions / Restrictions / Clarifications

  • If multiple factors prevent the ability from being activated, only print the first message in the order they are presented.
  • Activating the King Ability does not act as a move and therefore does not trigger the defences to activate.
  • The Wizard taps their staff before the ANGRY_BARBARIAN decides the shortest path.
  • The ANGRY_BARBARIAN will only move if the Barbarian's Number of Moves Taken field is increased.
  • The same movement rules that apply to the Barbarian are also applied to the ANGRY_BARBARIAN.
  • If the ANGRY_BARBARIAN cannot find a path to any entity or has no valid tile to move to, it remains stationary. As the Barbarian would have moved beforehand, this still counts as a move for the Barbarian.
  • If the ANGRY_BARBARIAN destroys an entity, the tile the entity occupied is changed to the DESTROYED entity and the ANGRY_BARBARIAN is removed from the board.
  • When activating the Special Ability defined in Stage 3.3, the abilities are given to the Barbarian and are not extended to the ANGRY_BARBARIAN.
  • If the ANGRY_BARBARIAN destroys an entity, this should increase the Barbarian's Entity Destroyed count.
  • When getting information for a tile via the i command, if the tile contains the ANGRY_BARBARIAN, its stats should be printed. The Damage Inflicted statistic should reflect the amount of damage the ANGRY_BARBARIAN has inflicted.
  • In the case where the ANGRY_BARBARIAN is unable to move, the sub-case where the Barbarian attempts to move onto the ANGRY_BARBARIAN's square will be untested and not marked. Optionally, feel free to follow the reference solution's implementation!

Examples

Input:

0 0
b 0 1
b 0 2
b 0 3
u 0 1 5
u 0 2 5
u 0 3 5
U 10
t 3 5
e
d
d
d
s
K
d
d
d
d
d
d

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 0
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
b 0 1
b 0 2
b 0 3
u 0 1 5
u 0 2 5
u 0 3 5
U 10
t 3 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|(*)|(*)|(*)|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|(*)|(*)|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|(*)|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
K
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>!<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
King Ability Activated
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>!<|>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>!<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |>o<|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>!<|   |/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |>o<|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>!<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |>o<|   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>!<|/#\|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
d
+=======================================+
|    *** VICTORY - 3 STAR RAID! ***     |
+=======================================+
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |   |   |>o<|
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|:::|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 120                     |
|  Attack     : 65                      |
|  Level      : 11                      |
+---------------------------------------+
|  Moves      : 10                      |
|  Destroyed  : 1                       |
+=======================================+

Input:

0 0
b 0 1
b 0 2
b 0 3
u 0 1 5
u 0 2 5
u 0 3 5
U 10
c 3 5
Z 5 5
t 9 9
u 5 5 5
u 3 5 5
e
d
d
d
s
K
a
a
d
d
a
w
d
d
d
d
p
q

Input and Output:

dcc cs_clash.c -o cs_clash
./cs_clash
=========================================
 /-----\                         |T|T|T|
 |__T__|  |===================|  |_____|
 |#   #|  |    Welcome to     |  |#   #|
 | [_] |  |     CS CLASH      |  |  #  |
 |#   #|  |===================|  |#   #|
 |_____|                         |_____|
=========================================

============== Setup Phase ==============
Enter the Barbarian's starting position: 0 0
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+===+===+===+===+===+===+===+===+===+===+
Enter setup commands:
b 0 1
b 0 2
b 0 3
u 0 1 5
u 0 2 5
u 0 3 5
U 10
c 3 5
Z 5 5
t 9 9
u 5 5 5
u 3 5 5
e
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|>o<|(*)|(*)|(*)|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |~$~|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
============= Gameplay Phase ============
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|(*)|(*)|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|~$~|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|(*)|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|o-=|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|o-=|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
s
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|o-=|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |~$~|   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
K
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>!<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|o-=|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |~$~|   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
King Ability Activated
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|>!<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |~$~|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |>o<|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>!<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |o-=|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|~$~|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |>!<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|o-=|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>!<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|o-=|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
a
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |>!<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|o-=|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |~$~|   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
w
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |>o<|!^!|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |:::|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |~$~|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |>o<|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |:::|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|~$~|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |!^!|!^!|!^!|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|>o<|   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|:::|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |>o<|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|:::|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|~$~|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
d
+===+===+===+===+===+===+===+===+===+===+
|***   >>>   C S   C L A S H   <<<   ***|
+===+===+===+===+===+===+===+===+===+===+
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |>o<|   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|:::|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |~$~|   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|   |   |   |!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |!^!|!^!|!^!|!^!|!^!|   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |/#\|
+===+===+===+===+===+===+===+===+===+===+
p
+=======================================+
|         >> BARBARIAN STATUS <<        |
+=======================================+
|  Health     : 55                      |
|  Attack     : 65                      |
|  Level      : 11                      |
+---------------------------------------+
|  Moves      : 14                      |
|  Destroyed  : 1                       |
+=======================================+
q
============= Quitting Game =============

Autotest

Testing & Submission

Are you finished with this stage? If so, you should make sure to do the following:

  • Run 1511 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_clash.c
1511 autotest-stage 04 cs_clash
give cs1511 ass1_cs_clash cs_clash.c

Tools

Creating Levels in Separate Files

If you are getting sick of typing in your inputs for a level every single time you run CS Clash, you might want to store your input in a separate file. This allows you to see the result of the Setup Phase or to play your level straight away.

1. Create a file for your input.

First, let's create a file to store in the input for a level that you have created. This isn't a .c file, it's just a regular plain text file, and the file extension .in works nicely for this!

Let's put it in the same directory as your cs_clash.c code.

ls
cs_clash.c 
cs_clash 
my_level.in

2. Add your input to the file

Inside of this file, add the input for the level. Don't add in any of the 'wasd' movement commands as those will come from the terminal (from substage 2.1 onwards).

Your file could look a bit like this:

4 8
w 1 5
b 2 3
g 4 2
s

3. Run the code with your file

Next, instead of just running ./cs_clash, lets tell the computer to first read from the file we created.

If you have completed substage 2.1 then use the following:

cat my_level.in - | ./cs_clash

Otherwise, use the following:

cat my_level.in | ./cs_clash

The dash tells your program that you want to enter more input after what's in the file, allowing you to play the level!

Community Levels

If you want to create your own levels, we encourage you to share them on the Course Forum.

Extension

As an extension, we have set up a starting point to add a texture pack to your game via SplashKit.

Extension activities are NOT worth any marks, nor are there any autotests. They are just for fun!

Getting Started

To get started with SplashKit, complete the SplashKit activities.

Sample Code

First, navigate to your SplashKit directory.

cd splashkit

Create a new directory for your project and cd into it.

mkdir cs_clash
cd cs_clash

Set up your directory for SplashKit with:

1511 setup-splashkit-directory

Run this cp command to retrieve the sample code.

cp -n /web/cs1511/26T2/activities/cs_clash/splashkit_example.c .

This should add the splashkit_example.c sample code to your current directory.

Check that SplashKit Works

Let's check that SplashKit works by running a test file. It should display a white square with a grid inside.

skm clang++ splashkit_example.c -o splashkit_example
./splashkit_example

Have a look inside of splashkit_example.c and note that:

  • At the very top, the the SplashKit library "splashkit.h" is included. If you see an error here, check SplashKit #1 - Getting Started for a solution to set up your VS Code project.
  • In the main() function:
    • open_window("SplashKit Example", 600, 400) creates a 600×400 window for displaying graphics.
    • The while (!window_close_requested(w)) loop keeps running until the user closes the window. Within this loop:
      • process_events() handles input or window-related actions (like closing the window).
      • refresh_screen() updates the window so any graphical changes (like drawing a rectangle) are displayed to the user.

Running Your SplashKit Code

When creating your SplashKit program, give it a distinctive name like splashkit_cs_clash.c.

To compile and run your program, use:

skm clang++ splashkit_cs_clash.c -o splashkit_cs_clash
./splashkit_cs_clash

Writing Your SplashKit Program

Now that you've seen how the sample code works, it’s time to create your own SplashKit program.

If you're not sure where to begin, start by researching the SplashKit Library. The goal at first is not to understand and memorise the entire library. Rather, it's better to skim through the pages to build a broad understanding of the capabilities that SplashKit can bring to your creations.

The Graphics page is a good place to start, and the following sections will be useful:

  • Windows for opening, closing, and controlling the size of windows.
  • Color for using different colours.
  • Graphics for drawing shapes, images, and text.
  • Geometry for handling shapes such as rectangles, circles, lines, and points.
  • Input for capturing and handling user input such as keyboard and mouse events.

SplashKit Gallery

Have you built something fun or interesting using SplashKit? Show it off and inspire your classmates!

Share any screenshots or short videos of your running program in the SplashKit Gallery on the Course Forum. Feel free to add a brief description or reflect on how you made it, so we can all learn from your mistakes journey 😅.

Extra Extension

Finished everything? Here are some extra features you could add to make your game more interesting (not for marks but feel free to show your tutor or post on the course forum!):

  • Different Troops: Add more troops that we're able to control. They could have different abilites with different health, damage, or movement patterns. They could even be autonomous like the Angry Barbarian!
  • Resource Collection: Introduce gold or elixir that players can collect and spend on new troops or upgrades.
  • Defensive Buildings: Add towers or cannons with unique abilites to attack nearby enemy troops each turn.

For extra inspiration, have a look at the reference game, Clash of Clans, and think about which mechanics could be adapted to a simple 2D array-based game. Try to keep any additions manageable and within the scope of your current design. Congratulations on making such good progress!




Assessment

Assignment Conditions

  • Joint work is not permitted on this assignment.

    This is an individual assignment.

    The work you submit must be entirely your own work. Submission of any work even partly written by any other person is not permitted.

    Except, you may use small amounts (< 10 lines) of general purpose code (not specific to the assignment) obtained from a site such as Stack Overflow or other publicly available resources. You should attribute clearly the source of this code in an accompanying comment.

    Assignment submissions will be examined, both automatically and manually for work written by others.

    Do not request help from anyone other than the teaching staff of COMP1511, e.g. in the course forum & help sessions.

    Do not post your assignment code to the course forum - the teaching staff can view assignment code you have recently autotested or submitted with give.

    Rationale: this assignment is designed to develop the individual skills needed to produce an entire working program. Using code written by or taken from other people will stop you learning these skills. Other CSE courses focus on the skill needed for work in a team.

  • The use of code-synthesis tools, such as GitHub Copilot, is not permitted on this assignment.

    The use of Generative AI to generate code solutions is not permitted on this assignment.

    Rationale: this assignment is intended to develop your understanding of basic concepts. Using synthesis tools will stop you learning these fundamental concepts.

  • Sharing, publishing, distributing your assignment work is not permitted.

    Do not provide or show your assignment work to any other person other than the teaching staff of COMP1511. For example, do not message your work to friends.

    Do not publish your assignment code via the internet. For example, do not place your assignment in a public GitHub repository.

    Rationale: by publishing or sharing your work you are facilitating other students using your work which is not permitted. If they submit your work, you may become involved in an academic integrity investigation.

  • Sharing, publishing, distributing your assignment work after the completion of COMP1511 is not permitted.

    For example, do not place your assignment in a public GitHub repository after COMP1511 is over.

    Rationale: COMP1511 sometimes reuses assignment themes using similar concepts and content. Students in future terms find your code and use it which is not permitted and you may become involved in an academic integrity investigation.

Violation of the above conditions may result in an academic integrity investigation with possible penalties, up to and including a mark of 0 in COMP1511 and exclusion from UNSW.

Relevant scholarship authorities will be informed if students holding scholarships are involved in an incident of plagiarism or other misconduct. If you knowingly provide or show your assignment work to another person for any reason, and work derived from it is submitted you may be penalised, even if the work was submitted without your knowledge or consent. This may apply even if your work is submitted by a third party unknown to you.

Note, you will not be penalised if your work is taken without your consent or knowledge.

For more information, read the UNSW Student Code, or contact the course account. The following penalties apply to your total mark for plagiarism:

0 for the assignment Knowingly providing your work to anyone and it is subsequently submitted (by anyone).
0 for the assignment Submitting any other person's work. This includes joint work.
0 FL for COMP1511 Paying another person to complete work. Submitting another person's work without their consent.

Submission of Work

You should submit intermediate versions of your assignment. Every time you autotest or submit, a copy will be saved as a backup. You can find those backups here, by logging in, and choosing the yellow button next to 'cs_clash.c'.

Every time you work on the assignment and make some progress you should copy your work to your CSE account and submit it using the give command below.

It is fine if intermediate versions do not compile or otherwise fail submission tests.

Only the final submitted version of your assignment will be marked.

You submit your work like this:

give cs1511 ass1_cs_clash cs_clash.c

Assessment Scheme

This assignment will contribute 20% to your final mark.

80% of the marks for this assignment will be based on the performance of the code you write in cs_clash.c

20% of the marks for this assignment will come from manual marking of the readability of the C you have written. The manual marking will involve checking your code for clarity, and readability, which includes the use of functions and efficient use of loops and if statements.

Marks for your performance will be allocated roughly according to the below scheme.

100% for Performance Completely Working Implementation, which exactly follows the spec (Stage 1, 2, 3 and 4).
85% for Performance Completely working implementation of Stage 1, 2 and 3.
65% for Performance Completely working implementation of Stage 1 and Stage 2.
35% for Performance Completely working implementation of Stage 1.

The Challenge stage of the assignment is NOT worth any marks, but is something fun for you to work on getting to know a new library and building something more visual!

Style Marking Rubric

0 1 2 3 4
Formatting (/5)
Indentation (/2) - Should use a consistent indentation scheme. Multiple instances throughout code of inconsistent/bad indentation Code is mostly correctly indented Code is consistently indented throughout the program
Whitespace (/1) - Should use consistent whitespace (for example, 3 + 3 not 3+ 3) Many whitespace errors No whitespace errors
Vertical Whitespace (/1) - Should use consistent whitespace (for example, vertical whitespace between sections of code) Code has no consideration for use of vertical whitespace Code consistently uses reasonable vertical whitespace
Line Length (/1) - Lines should be max. 80 characters long Many lines over 80 characters No lines over 80 characters
Documentation (/5)
Comments (incl. header comment) (/3) - Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included No comments provided throughout code Few comments provided throughout code Comments are provided as needed, but some details or explanations may be missing causing the code to be difficult to follow Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included
Function/variable/constant naming (/2) - Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code Functions/variables/constants names do not follow naming conventions in style guide and help in understanding the code Functions/variables/constants names somewhat follow naming conventions in style guide and help in understanding the code Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code
Organisation (/5)
Function Usage (/4) - Code has been decomposed into appropriate functions separating functionalities No functions are present, code is one main function Some code has been moved to functions Some code has been moved to sensible/thought out functions, and/or many functions exceed 50 lines (incl. main function) Most code has been moved to sensible/thought out functions, and/or some functions exceed 50 lines (incl. main function) All code has been meaningfully decomposed into functions of a maximum of 50 lines (incl. The main function)
Function Prototypes (/1) - Function Prototypes have been used to declare functions above main Functions are used but have not been prototyped All functions have a prototype above the main function or no functions are used
Elegance (/5)
Overdeep nesting (/2) - You should not have too many levels of nesting in your code (nesting which is 5 or more levels deep) Many instances of overdeep nesting <= 3 instances of overdeep nesting No instances of overdeep nesting
Code Repetition (/2) - Potential repetition of code has been dealt with via the use of functions or loops Many instances of repeated code sections <= 3 instances of repeated code sections Potential repetition of code has been dealt with via the use of functions or loops
Constant Usage (/1) - Any magic numbers are #defined None of the constants used throughout program are #defined All constants used are #defined and are used consistently in the code
Illegal elements
Illegal elements - Presence of any illegal elements indicated in the style guide CAP MARK AT 16/20

Allowed C Features

In this assignment, there are no restrictions on C Features, except for those in the style guide. If you choose to disregard this advice, you must still follow the style guide.

You also may be unable to get help from course staff if you use features not taught in COMP1511. Features that the Style Guide identifies as illegal will result in a penalty during marking. You can find the style marking rubric above.

Due Date

This assignment is due 13 July 2026 18:00:00. For each day after that time, the maximum mark it can achieve will be reduced by 5% (off the ceiling).
  • For instance, at 1 day past the due date, the maximum mark you can get is 95%.
  • For instance, at 3 days past the due date, the maximum mark you can get is 85%.
  • For instance, at 5 days past the due date, the maximum mark you can get is 75%.
No submissions will be accepted after 5 days late, unless you have special provisions in place.

Change Log

Version 1.0
(2026-06-22 13:00)
  • Assignment released