|
| 1 | +defmodule DndCharacterTest do |
| 2 | + use ExUnit.Case |
| 3 | + |
| 4 | + import DndCharacter, only: [modifier: 1, ability: 0, character: 0] |
| 5 | + |
| 6 | + # canonical data version: 1.1.0 |
| 7 | + |
| 8 | + describe "ability modifier" do |
| 9 | + # @tag :pending |
| 10 | + test "for score 3 is -4" do |
| 11 | + assert modifier(3) === -4 |
| 12 | + end |
| 13 | + |
| 14 | + @tag :pending |
| 15 | + test "for score 4 is -3" do |
| 16 | + assert modifier(4) === -3 |
| 17 | + end |
| 18 | + |
| 19 | + @tag :pending |
| 20 | + test "for score 5 is -3" do |
| 21 | + assert modifier(5) === -3 |
| 22 | + end |
| 23 | + |
| 24 | + @tag :pending |
| 25 | + test "for score 6 is -2" do |
| 26 | + assert modifier(6) === -2 |
| 27 | + end |
| 28 | + |
| 29 | + @tag :pending |
| 30 | + test "for score 7 is -2" do |
| 31 | + assert modifier(7) === -2 |
| 32 | + end |
| 33 | + |
| 34 | + @tag :pending |
| 35 | + test "for score 8 is -1" do |
| 36 | + assert modifier(8) === -1 |
| 37 | + end |
| 38 | + |
| 39 | + @tag :pending |
| 40 | + test "for score 9 is -1" do |
| 41 | + assert modifier(9) === -1 |
| 42 | + end |
| 43 | + |
| 44 | + @tag :pending |
| 45 | + test "for score 10 is 0" do |
| 46 | + assert modifier(10) === 0 |
| 47 | + end |
| 48 | + |
| 49 | + @tag :pending |
| 50 | + test "for score 11 is 0" do |
| 51 | + assert modifier(11) === 0 |
| 52 | + end |
| 53 | + |
| 54 | + @tag :pending |
| 55 | + test "for score 12 is +1" do |
| 56 | + assert modifier(12) === 1 |
| 57 | + end |
| 58 | + |
| 59 | + @tag :pending |
| 60 | + test "for score 13 is +1" do |
| 61 | + assert modifier(13) === 1 |
| 62 | + end |
| 63 | + |
| 64 | + @tag :pending |
| 65 | + test "for score 14 is +2" do |
| 66 | + assert modifier(14) === 2 |
| 67 | + end |
| 68 | + |
| 69 | + @tag :pending |
| 70 | + test "for score 15 is +2" do |
| 71 | + assert modifier(15) === 2 |
| 72 | + end |
| 73 | + |
| 74 | + @tag :pending |
| 75 | + test "for score 16 is +3" do |
| 76 | + assert modifier(16) === 3 |
| 77 | + end |
| 78 | + |
| 79 | + @tag :pending |
| 80 | + test "for score 17 is +3" do |
| 81 | + assert modifier(17) === 3 |
| 82 | + end |
| 83 | + |
| 84 | + @tag :pending |
| 85 | + test "for score 18 is +4" do |
| 86 | + assert modifier(18) === 4 |
| 87 | + end |
| 88 | + end |
| 89 | + |
| 90 | + describe "random ability" do |
| 91 | + @tag :pending |
| 92 | + test "is within range" do |
| 93 | + Enum.each(1..200, fn _ -> assert ability() in 3..18 end) |
| 94 | + end |
| 95 | + end |
| 96 | + |
| 97 | + describe "random character" do |
| 98 | + setup do |
| 99 | + %{character: character()} |
| 100 | + end |
| 101 | + |
| 102 | + @tag :pending |
| 103 | + test "has valid hitpoints", %{character: character} do |
| 104 | + assert character.hitpoints === 10 + modifier(character.constitution) |
| 105 | + end |
| 106 | + |
| 107 | + @tag :pending |
| 108 | + test "has each ability only calculated once", %{character: character} do |
| 109 | + assert character.strength === character.strength |
| 110 | + end |
| 111 | + end |
| 112 | +end |
0 commit comments