Giter VIP home page Giter VIP logo

fantasybattle-refactoring-kata's Introduction

Fantasy Battle Refactoring Kata

This code is part of a larger fantasy battle game. Players in the game will fight monsters using the equipment they are wearing. The type of equipment will affect how much damage they do to the monsters. Monsters also vary according to what armour and equipment they are wearing. This part of the code is concerned with calculating how much damage the player is doing to a monster when they fight.

The kata is designed to teach you something about the Law of Demeter. The 'Player' class perhaps doesn't follow this law very well.

Try to write a test for the method 'calculateDamage' on the Player class, without changing any of the production code. Use the description below to help you design a test scenario. Note there are two example test cases to start from. Choose the one you prefer. Give yourself a time box of 10 minutes, then reflect on why this method is hard to test.

When you have reflected, you should refactor the 'calculateDamage' method to better follow the Law of Demeter. Also add test cases to cover the functionality in the Player class.

When you feel that you are done, depending on how much time you have, you may continue to implement tests until you have good coverage or look through the TODO in the code (Alt+6 in IntelliJ). Reflect on which of these TODO hints will now be easier to address compared with before your refactoring work, then try to implement those features.

Example Data for use in Test cases

Example equipment:

Where What Base Damage Damage Modifier
right hand flashy sword of danger 10 1.0
right hand excalibur 20 1.5
left hand round shield 0 1.4
feet ten league boots 0 0.1
head helmet of swiftness 0 1.2
chest breastplate of steel 0 1.4

At present the only kind of enemy supported is a SimpleEnemy. This kind of target has one Buff with a soakModifier of 1.0 and damage modifier of 1.0. It wears an Armor with a Damage Soak of 5.

fantasybattle-refactoring-kata's People

Contributors

neppord avatar dependabot[bot] avatar codecop avatar larseckart avatar reasu avatar nolwennd avatar paucls avatar emilybache avatar eeppuj avatar fpellet avatar xrecoba avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.