Portfolio Code | Clement Colmerauer
Repositories
Site
Kata refactoring
Code
Commits
Branches
Tags
Search
Tree:
f6f626b
Branches
Tags
master
Kata refactoring
build
reports
jacoco
test
html
re.forestier.edu.rpg
UpdatePlayer.java.html
enlever divide de Natural
Clement COLMERAUER
commited
f6f626b
at 2024-10-24 16:52:13
UpdatePlayer.java.html
Blame
History
Raw
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="fr"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>UpdatePlayer.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">kata</a> > <a href="index.source.html" class="el_package">re.forestier.edu.rpg</a> > <span class="el_source">UpdatePlayer.java</span></div><h1>UpdatePlayer.java</h1><pre class="source lang-java linenums">package re.forestier.edu.rpg; import java.util.HashMap; import java.util.Random; <span class="fc" id="L6">public class UpdatePlayer {</span> <span class="fc" id="L8"> public final static String[] objectList = {"Magic bow : Heal by 1/8th of your HP","Lookout Ring : Prevents surprise attacks","Scroll of Stupidity : INT-2 when applied to an enemy", "Draupnir : Increases XP gained by 100%", "Magic Charm : Magic +10 for 5 rounds", "Rune Staff of Curse : May burn your ennemies... Or yourself. Who knows?", "Combat Edge : Well, that's an edge", "Holy Elixir : Recover your HP"</span> }; public static HashMap<String, HashMap<Integer, HashMap<String, Integer>>> abilitiesPerTypeAndLevel() { <span class="fc" id="L12"> HashMap<String, HashMap<Integer, HashMap<String, Integer>>> abilitiesPerTypeAndLevel = new HashMap<>();</span> <span class="fc" id="L14"> HashMap<Integer, HashMap<String, Integer>> adventurerMap = new HashMap<>();</span> <span class="fc" id="L15"> HashMap<String, Integer> adventurerLevel1 = new HashMap<>();</span> <span class="fc" id="L16"> adventurerLevel1.put("INT", 1);</span> <span class="fc" id="L17"> adventurerLevel1.put("DEF", 1);</span> <span class="fc" id="L18"> adventurerLevel1.put("ATK", 3);</span> <span class="fc" id="L19"> adventurerLevel1.put("CHA", 2);</span> <span class="fc" id="L20"> adventurerMap.put(1, adventurerLevel1);</span> <span class="fc" id="L22"> HashMap<String, Integer> adventurerLevel2 = new HashMap<>();</span> <span class="fc" id="L23"> adventurerLevel1.put("INT", 2);</span> <span class="fc" id="L24"> adventurerLevel1.put("CHA", 3);</span> <span class="fc" id="L25"> adventurerMap.put(2, adventurerLevel2);</span> <span class="fc" id="L27"> HashMap<String, Integer> adventurerLevel3 = new HashMap<>();</span> <span class="fc" id="L28"> adventurerLevel3.put("ATK", 5);</span> <span class="fc" id="L29"> adventurerLevel3.put("ALC", 1);</span> <span class="fc" id="L30"> adventurerMap.put(3, adventurerLevel3);</span> <span class="fc" id="L32"> HashMap<String, Integer> adventurerLevel4 = new HashMap<>();</span> <span class="fc" id="L33"> adventurerLevel4.put("DEF", 3);</span> <span class="fc" id="L34"> adventurerMap.put(4, adventurerLevel4);</span> <span class="fc" id="L36"> HashMap<String, Integer> adventurerLevel5 = new HashMap<>();</span> <span class="fc" id="L37"> adventurerLevel5.put("VIS", 1);</span> <span class="fc" id="L38"> adventurerLevel5.put("DEF", 4);</span> <span class="fc" id="L39"> adventurerMap.put(5, adventurerLevel5);</span> <span class="fc" id="L41"> abilitiesPerTypeAndLevel.put("ADVENTURER", adventurerMap);</span> <span class="fc" id="L44"> HashMap<Integer, HashMap<String, Integer>> archerMap = new HashMap<>();</span> <span class="fc" id="L45"> HashMap<String, Integer> archerLevel1 = new HashMap<>();</span> <span class="fc" id="L46"> archerLevel1.put("INT", 1);</span> <span class="fc" id="L47"> archerLevel1.put("ATK", 3);</span> <span class="fc" id="L48"> archerLevel1.put("CHA", 1);</span> <span class="fc" id="L49"> archerLevel1.put("VIS", 3);</span> <span class="fc" id="L50"> archerMap.put(1, archerLevel1);</span> <span class="fc" id="L52"> HashMap<String, Integer> archerLevel2 = new HashMap<>();</span> <span class="fc" id="L53"> archerLevel2.put("DEF", 1);</span> <span class="fc" id="L54"> archerLevel2.put("CHA", 2);</span> <span class="fc" id="L55"> archerMap.put(2, archerLevel2);</span> <span class="fc" id="L57"> HashMap<String, Integer> archerLevel3 = new HashMap<>();</span> <span class="fc" id="L58"> archerLevel3.put("ATK", 3);</span> <span class="fc" id="L59"> archerMap.put(3, archerLevel3);</span> <span class="fc" id="L61"> HashMap<String, Integer> archerLevel4 = new HashMap<>();</span> <span class="fc" id="L62"> archerLevel4.put("DEF", 2);</span> <span class="fc" id="L63"> archerMap.put(4, archerLevel4);</span> <span class="fc" id="L65"> HashMap<String, Integer> archerLevel5 = new HashMap<>();</span> <span class="fc" id="L66"> archerLevel5.put("ATK", 4);</span> <span class="fc" id="L67"> archerMap.put(5, archerLevel5);</span> <span class="fc" id="L69"> abilitiesPerTypeAndLevel.put("ARCHER", archerMap);</span> <span class="fc" id="L72"> HashMap<Integer, HashMap<String, Integer>> dwarf = new HashMap<>();</span> <span class="fc" id="L73"> HashMap<String, Integer> dwarfLevel1 = new HashMap<>();</span> <span class="fc" id="L74"> dwarfLevel1.put("ALC", 4);</span> <span class="fc" id="L75"> dwarfLevel1.put("INT", 1);</span> <span class="fc" id="L76"> dwarfLevel1.put("ATK", 3);</span> <span class="fc" id="L77"> dwarf.put(1, dwarfLevel1);</span> <span class="fc" id="L79"> HashMap<String, Integer> dwarfLevel2 = new HashMap<>();</span> <span class="fc" id="L80"> dwarfLevel2.put("DEF", 1);</span> <span class="fc" id="L81"> dwarfLevel2.put("ALC", 5);</span> <span class="fc" id="L82"> dwarf.put(2, dwarfLevel2);</span> <span class="fc" id="L84"> HashMap<String, Integer> dwarfLevel3 = new HashMap<>();</span> <span class="fc" id="L85"> dwarfLevel3.put("ATK", 4);</span> <span class="fc" id="L86"> dwarf.put(3, dwarfLevel3);</span> <span class="fc" id="L88"> HashMap<String, Integer> dwarfLevel4 = new HashMap<>();</span> <span class="fc" id="L89"> dwarfLevel4.put("DEF", 2);</span> <span class="fc" id="L90"> dwarf.put(4, dwarfLevel4);</span> <span class="fc" id="L92"> HashMap<String, Integer> dwarfLevel5 = new HashMap<>();</span> <span class="fc" id="L93"> dwarfLevel5.put("CHA", 1);</span> <span class="fc" id="L94"> dwarf.put(5, dwarfLevel5);</span> <span class="fc" id="L96"> abilitiesPerTypeAndLevel.put("DWARF", dwarf);</span> <span class="fc" id="L98"> return abilitiesPerTypeAndLevel;</span> } // majFinDeTour met à jour les points de vie public static void majFinDeTour(Player player) { <span class="fc bfc" id="L103" title="All 2 branches covered."> if(player.getCurrentHealthPoints() == 0) {</span> <span class="fc" id="L104"> System.out.println("Le joueur est KO !");</span> <span class="fc" id="L105"> return;</span> } <span class="fc bfc" id="L108" title="All 2 branches covered."> if(player.getCurrentHealthPoints() < player.getMaxHealthPoints()/2) {</span> <span class="pc bpc" id="L109" title="1 of 4 branches missed."> switch(player.getAvatarClass())</span> { case "ADVENTURER" : <span class="fc" id="L112"> player.heal(2);</span> <span class="fc bfc" id="L113" title="All 2 branches covered."> if(player.getLevel() < 3) {</span> <span class="fc" id="L114"> player.hurt(1);</span> } break; case "DWARF" : <span class="fc" id="L118"> player.heal(1);</span> <span class="fc bfc" id="L119" title="All 2 branches covered."> if(player.inventory.contains("Holy Elixir")) {</span> <span class="fc" id="L120"> player.heal(1);</span> } break; case "ARCHER" : <span class="fc" id="L124"> player.heal(1);</span> <span class="fc bfc" id="L125" title="All 2 branches covered."> if(player.inventory.contains("Magic Bow")) {</span> <span class="fc" id="L126"> int potentialHeal = player.getCurrentHealthPoints()/8-1;</span> <span class="fc bfc" id="L127" title="All 2 branches covered."> player.heal(potentialHeal < 0 ? 0 : potentialHeal);</span> } break; } } <span class="fc" id="L132"> }</span> } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.11.202310140853</span></div></body></html>