CS代考 COMP2511 Project: Dungeon Mania

# COMP2511 Project: Dungeon Mania

## Contents

Copyright By PowCoder代写 加微信 powcoder

This specification is broken into four parts:

  1. Introduction
  2. Product Specification
  3. Technical Specification
  4. Assessment
  5. ### Table of Contents

    # Part I) Introduction

    ## 0. Changelog

    – Tue 28 Jun 11:30am – Correct descriptions for `tick` overloads in interface, add note about keeping branches when squashing and fix formatting in link, add setup images
    – Tue 28 Jun 6pm – Replace `gameMode` parameter with `configName` in new game method i.e. `newGame(String dungeonName, String configName)`
    – Tue 28 Jun 8:00pm – Fix two battle calculation tests in `ExampleTests`
    – Wed 29 Jun 9:30pm – Fix front-end config selector in starter code
    – Thu 30 Jun 10:30pm – Add `player` to dungeon input entities
    – Sat 2 Jul 12pm – Allies provide attack/defence bonuses
    – Sat 2 Jul 12:30pm – Add coverage extraction
    – Mon 4 Jul 9pm – Clarify square blast radius for bombs and mercenary bribing
    – Mon 4 Jul 11pm – Nesting of compound goals
    – Tue 5 Jul 7pm – Fix wording of complex goals in 3.7.2
    – Tue 5 Jul 10pm – Fix provided config files for allies
    – Mon 11 Jul 1pm – Fix `getEntitiesStream` in `TestUtils` to check prefixes instead of entire entity type
    – Sun 10 Jul 9am – Fix confusing exception and add precondiction in the JavaDoc for `FileLoader.loadResourceFile()`
    – Tue 12 Jul 4pm – Fix sample battle test to have positive delta instead of negative for health in `RoundResponse`
    – Tue 12 Jul 6pm – Clarify `isInteractable` behaviour with allies, zombie toast spawner behaviour if there’s no open square and removal of items from inventory
    – Tue 12 Jul 8pm – If a spider is stuck between two boulders in its movement path, it should remain still
    – Tue 12 Jul 10pm – Improve wording of effects of bows in battles
    – Wed 13 Jul 9am – Fix the typo in the example battle test
    – Thu 14 Jul 6am – Add image for green portal
    – Thu 14 Jul 10pm – Fix triggering interactions multiple times from the front-end
    – Sat 16 Jul 9am – Add error tolerant to battle calculation
    – Mon 18 Jul 8am – Add Milestone 3 (search for ð��� to find all product/technical spec changes)

    ## 1. Aims

    * Apply software design principles and patterns to create well-maintained software solutions
    * Synthesise and adapt to changes in requirements
    * Practice software design and development in a dynamic team environment using Agile principles
    * Work with the Java Programming Language and Java Class Libraries
    * Build medium-scale persistent web applications from scratch
    * Appreciate issues in the design and development of software

    ## 2. Overview

    For many years, Penguin Pty Ltd (a small software business run by ) has dominated the native application gaming market with hit games. However in recent years, advancements in web technologies mean that the new generation of consumers don’t want to download and run a native application, but instead want to play games online. To adapt to the ever-changing market, Penguin Pty Ltd has decided to take users back to the 1980s and develop a new game called *Dungeon Mania*, but with a modern twist – designed as a web application.

    Penguin Pty Ltd has sub-contracted two software firms:

    * BlueBottle Pty Ltd to develop a web-based frontend to the game
    * YourTeam Pty Ltd (a team of talented misfits completing COMP2511 in 22T2), who will build the backend Java application.

    Furthermore, there is a rival company called Ltd which has already produced a solution which you can refer to as a possible sample solution.

    # Part II) Product Specification

    ## 3. Rules of the Game

    In Dungeon Mania you control a Player and have to complete various goals within a series of dungeons to complete the game!

    The simplest form of such a puzzle is a maze, where the Player must find their way from the starting point to the exit.

    More advanced puzzles may contain things like boulders that need to be pushed onto floor switches,

    enemies that need to be fought with weapons, or collectables like potions and treasure.

    ### 3.1 Player

    The Player, can be moved up, down, left and right into cardinally adjacent squares, provided another entity doesn’t stop them (e.g. a wall). The Player begins the game with a set amount of health and attack damage. The Player spawns at a set ‘entry location’ at the beginning of a game.

    ### 3.2 Static Entities

    The game contains the following static entities.

    | Entity | Image | Description |
    | ——— | —– | ———– |
    | Wall | | Blocks the movement of the Player, enemies and boulders. |
    | Exit | | If the Player goes through it, the puzzle is complete. |
    | Boulder | | Acts like a wall in most cases. The only difference is that it can be pushed by the Player into cardinally adjacent squares. The Player is only strong enough to push one boulder at a time. When the player pushes a boulder, they move into the spot the boulder was previously in. Boulders can be pushed onto collectable entities. |
    | Floor Switch | | Switches behave like empty squares, so other entities can appear on top of them. When a boulder is pushed onto a floor switch, it is triggered. Pushing a boulder off the floor switch untriggers. |
    | Door | | Exists in conjunction with a single key that can open it. If the Player holds the key, they can open the door by moving through it. Once open, it remains open. |
    | Portal | | Teleports entities to a corresponding portal. The player must end up in a square cardinally adjacent to the corresponding portal. The square they teleport onto must also be within movement constraints – e.g. the player cannot teleport and end up on a wall. If all squares cardinally adjacent to the corresponding portal are walls, then the player should remain where they are. |
    | Zombie Toast Spawner | | Spawns zombie toasts in an open square cardinally adjacent to the spawner. The Player can destroy a zombie spawner if they have a weapon and are cardinally adjacent to the spawner. If all the cardinally adjacent cells to the spawner are walls, then the spawner will not spawn any zombies. |

    ### 3.3 Moving Entities

    In addition to the Player, the game contains the following moving entities.

    All enemy entities can be created as part of the initial dungeon. Each tick, all enemies move according to their respective behaviour.

    | Entity | Image | Description |
    | ——— | —– | ———– |
    Spider | | Spiders spawn at random locations in the dungeon from the beginning of the game. When the spider spawns, they immediately move the 1 square upwards (towards the top of the screen) and then begin ‘circling’ their spawn spot (see a [visual example here](images/spider_movement_1.png)). Spiders are able to traverse through walls, doors, switches, portals, exits (which have no effect), but not boulders, in which case it will reverse direction (see a [visual example here](images/spider_movement_2.png)). When it comes to spawning spiders, since the map is technically infinite you can spawn them anywhere – however for better gameplay we suggest you make an assumption and pick a four co-ordinate box to spawn spiders in. If a spider is stuck between two boulders in its movement path, it should remain still. |
    | Zombie Toast | | Zombies spawn at zombie spawners and move in random directions. Zombies are limited by the same movement constraints as the Player, except portals have no effect on them. |
    | Mercenary | | Mercenaries do not spawn; they are only present if created as part of the dungeon. They constantly move towards the Player, stopping only if they cannot move any closer (they are able to move around walls). Mercenaries are limited by the same movement constraints as the Player. All mercenaries are considered hostile, unless the Player can bribe them with a certain amount of gold; in which case they become allies. Mercenaries must be within a certain radius of the player in order to be bribed, which is formed by the diagonally and cardinally adjacent cells in a “square” fashion, akin to the blast radius for bombs. As an ally, once it reaches the Player it simply follows the Player around, occupying the square the player was previously in. |

    ### 3.3.1 Bosses �

    Bosses are moving entities which are harder to defeat/conquer than normal enemies.

    | Entity | Image | Description |
    | ——— | ————–| ————|
    | Assassin | | Assassins are exceptionally powerful mercenaries which deal significantly more damage. When bribing an Assassin, there is a certain chance that the bribe will fail; the gold will be wasted and the Assassin will remain hostile. Assassins are also capable of seeing and moving towards the Player when they are invisible, if they are within a certain radius. |
    | Hydra | | Hydras are generally considered to be a special creatures similar to Zombies. Hydras are limited by the same movement constraints as Zombies. When a hydra is attacked by the player, there is a certain chance that its health will increase rather than decrease by the given amount, [as two heads have grown back when one is cut off](https://simple.wikipedia.org/wiki/Lernaean_Hydra). |

    ### 3.4 Collectable Entities

    | Entity | Image | Description |
    | ——— | —– | ———– |
    | Treasure | | Can be collected by the Player. |
    | Key | | Can be picked up by the player when they move into the square containing it. The Player can carry only one key at a time, and only one door has a lock that fits the key. Keys disappear once used in any context i.e. opening a door, building an item. If a key is used before opening its door, its corresponding door will be locked forever. |
    | Invincibility Potion | | When a Player picks up an Invincibility potion, they may consume it at any time. Any battles that occur when the Player has the effects of the potion end immediately after the first round, with the Player immediately winning. Because of this, Mercenaries and Zombies will run away from the Player when they are invincible. Movement of spiders and bribed mercenaries remains unaffected. The effects of the potion only last for a limited time. |
    | Invisibility Potion | | When a player picks up an invisibility potion, they may consume it at any time and they immediately become invisible and can move past all other entities undetected. Battles do not occur when a player is under the influence of an invisibility potion. Since mercenaries typically follow the player, their movement becomes the same as a Zombie when the player is invisible. |
    | Wood | | Can be collected by the player. |
    | Arrows | | Can be picked up by the player. |
    | Bomb | | Can be collected by the player. When removed from the inventory it is placed on the map at the player’s location. When a bomb is cardinally adjacent to an active switch, it destroys all entities in diagonally and cardinally adjacent cells, except for the player, forming a “square” blast radius. The bomb should detonate when it is placed next to an already active switch, or placed next to an inactive switch that then becomes active. The bomb explodes on the same tick it becomes cardinally adjacent to an active switch. A bomb cannot be picked up once it has been used. |
    | Sword | | A standard melee weapon. Swords can be collected by the Player and used in battles, increasing the amount of damage they deal by an additive factor. Each sword has a specific durability that dictates the number of battles it can be used before it deteriorates and is no longer usable. |

    It is possible for a player to use another potion while the effects of an existing potion are still lasting (can be of the same or a different type of potion). In this case, the effects are not registered immediately but are instead ‘queued’ and will take place the tick following the previous potion wearing of. For example, on tick 0 the Player consumes an invinsibility potion that lasts for 5 ticks and becomes invisible to enemies moving that tick, on tick 3 they use an invincibility potion, at the end of tick 4 (after all enemy movements) the player becomes visible again and becomes invincible.

    ### 3.4.1 Further Collectable Entities �

    In Milestone 3, the following collectable entities have been added:

    | Entity | Image | Description |
    | ——— | ————–| ————|
    | Sun Stone | | Can be picked up by the player, and can be used to open doors and interchangeably with treasure; except it cannot be used to bribe mercenaries or assassins. Since the sun stone is classed as treasure it counts towards the treasure goal. When used in place of a key, it is retained after use. |

    ### 3.5 Buildable Entities

    Some entities can be built using a ‘recipe’ by the player, where entities are combined to form more complex and useful entities. Once a buildable item has been constructed, it is stored in a player’s inventory. For all buildable entities, once the item is constructed the materials used in that construction have been consumed and disappear from the player’s inventory.

    | Entity | Image | Description |
    | ——— | ————–| ——————|
    | Bow | | Can be crafted with 1 wood + 3 arrows. The bow has a durability which deteriorates after a certain number of battles. Bows give the Player double damage in each round, to simulate being able to attack an enemy at range (it can’t actually attack an enemy at range). |
    | Shield | | Can be crafted with 2 wood + (1 treasure OR 1 key). Shields decrease the effect of enemy attacks. Each shield has a specific durability that dictates the number of battles it can be used before it deteriorates. |

    ### 3.5.1 Further Buildable Entities �

    In Milestone 3, the following collectable entities have been added:

    | Entity | Image | Description |
    | ——— | ————–| ————|
    | Sceptre | | Can be crafted with one wood or two arrows, one key or one treasure, and one sun stone. A character with a sceptre does not need to bribe mercenaries or assassins to become allies, as they can use the sceptre to control their minds. The effects only last for a certain number of ticks. |
    | Midnight Armour | | Can be crafted with a sword and a sun stone if there are no zombies currently in the dungeon. Midnight armour provides extra attack damage as well as protection. |

    ### 3.6 battle takes place when the Player and an enemy are in the same cell at any point within a single tick. The conditions for a battle occurring are the same regardless of whether the player moves onto the same tile as the enemy, or vice versa.

    A ’round’ of a battle occurs as follows:

    Player Health = Player Health – (Enemy Attack Damage / 10)
    Enemy Health = Enemy Health – (Player Attack Damage / 5)

    If the Player’s health is <= 0, then the Player dies, is removed from the game and the game is over. If the enemy's health is <= 0, then the enemy dies and is removed from the game. If after the above 'round', neither the Player nor the enemy is dead, the round repeats until either the Player or enemy is dead. In battles, allies provide an attack and defence bonus to the player. ### 3.6.1 Weapons in Battle An example of a bow, sword and shield being used in battle is as follows: player health = 10 player base attack damage = 5 bow attack damage = 2 sword attack damage = 1 shield defence = 2 enemy health = 10 enemy attack damage = 5 Battle occurs: - Round 1 enemy health = 10 - ((2 * (5 + 1)) / 5) = 7.6 player health = 10 - ((5 - 2) / 10) = 9.7 - Round 2 enemy health = 7.6 - ((2 * (5 + 1)) / 5) = 5.2 player health = 9.7 - ((5 - 2) / 10) = 9.4 - Round 3 ... All additive/reductive bonuses from weapons are processed before multiplicative bonuses. ### 3.7 Goals In addition to its layout, each dungeon also has a goal that defines what must be achieved by the player for the dungeon to be considered complete. Basic goals are: * Getting to an exit; * Destroying a certain number of enemies (or more) AND all spawners; * Having a boulder on all floor switches; * Collecting a certain number of treasure items (or more); Goals are only evaluated after the first tick. If getting to an exit is one of a conjunction of conditions, it must be done last. For example, if the condition is to destroy all enemies AND get to an exit, the player must destroy the enemies THEN get to the exit. #### 3.7.2 Complex Goals More complex goals can be built by logically composing goals. For example: * Destroying a certain number of enemies and spawners AND getting to an exit * Collecting a certain number of treasure OR having a boulder on all floor switches * Getting to an exit AND (destroying all enemies OR collecting all treasure) All compound goals are binary (they contain two and only two subgoals). If getting to an exit is one of a conjunction of conditions, it must be done last. For example, if the condition is to collect 3 treasure AND get to an exit, the player must collect at least 3 treasures THEN get to the exit. It is possible for a subgoal to become un-achieved, for example if the dungeon goal is `boulders AND exit` and all boulders are pushed onto switches, then the boulders subgoal becomes complete. However, if a boulder is then moved off a switch, the boulders subgoal is no longer complete. ### 3.8 Winning & Losing The game is won when all the goals are achieved. The game is lost when the player dies and is removed from the map. ### 3.9 Advanced Movement ð��� During the development process the engineering team discovered issues in the requirements of the movement of mercenaries and decided that they should follow a specific path to move towards the player. In this Milestone, the movement of mercenaries (and by extension assassins) must follow a Djikstra's algorithm to take the shortest path towards the player. You can view pseudocode for the algorithm here.

    > Note: This is not necessarily optimal (A* is probably a better algorithm for our common maze like dungeons), but since this is a design course and not an algorithms course, this is fine.

    function Dijkstras(grid, source):
    let dist be a Map
    let prev be a Map

    for each Position p in grid:
    dist[p] := infinity
    previous[p] := null
    dist[source] := 0

    let queue be a Queue of every position in grid
    while queue is not empty:
    u := next node in queue with the smallest dist
    for each cardinal neighbour v of u:
    if dist[u] + cost(u, v) < dist[v]: dist[v] := dist[u] + cost(u, v) previous[v] := u return previous

    程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com