Exemple #1
0
 def test_normal_usage(s):
     base = stats.build_table(100, 10, 20, 20)
     item = stats.build_table(20, -5, 10, -10)
     assert stats.stack(base, item)['HP'] == 120
     assert stats.stack(base, item)['PW'] == 5
     assert stats.stack(base, item)['DF'] == 30
     assert stats.stack(base, item)['SP'] == 10
Exemple #2
0
 def test_multiple_items(s):
     base = stats.build_table(100, 10, 20, 20)
     item = stats.build_table(20, -5, 10, 5)
     armor = stats.build_table(10, 0, 40, -10)
     potion = stats.build_table(120, 10, -5, 0)
     special = stats.build_table(0, 50, 0, 0)
     assert stats.stack(base, item, armor, potion, special)['HP'] == 250
     assert stats.stack(base, item, armor, potion, special)['PW'] == 65
     assert stats.stack(base, item, armor, potion, special)['DF'] == 65
     assert stats.stack(base, item, armor, potion, special)['SP'] == 15
Exemple #3
0
 def test_defaults(s):
     table = stats.build_table()
     assert len(table.keys()) == 4
     assert table['HP'] == 0
     assert table['PW'] == 0
     assert table['DF'] == 0
     assert table['SP'] == 0
Exemple #4
0
 def test_string_args(s):
     table = stats.build_table('5', '4', '3', '2')
     assert len(table.keys()) == 4
     assert table['HP'] == 5
     assert table['PW'] == 4
     assert table['DF'] == 3
     assert table['SP'] == 2
Exemple #5
0
 def test_keyword_args(s):
     table = stats.build_table(5, 10, 5, 0)
     assert len(table.keys()) == 4
     assert table['HP'] == 5
     assert table['PW'] == 10
     assert table['DF'] == 5
     assert table['SP'] == 0
Exemple #6
0
 def test_float_args(s):
     """If given non-integers, try to type cast. This rounds downwards."""
     table = stats.build_table(5.5, 4.4, 3.3, 2.2)
     assert len(table.keys()) == 4
     assert table['HP'] == 5
     assert table['PW'] == 4
     assert table['DF'] == 3
     assert table['SP'] == 2
Exemple #7
0
 def test_bad_string_args(s):
     """If given arguments that can not be mapped to integers, 
     default to 0."""
     table = stats.build_table('Lots', 'ooo yes gimme that', 'x', 'z')
     assert len(table.keys()) == 4
     assert table['HP'] == 0
     assert table['PW'] == 0
     assert table['DF'] == 0
     assert table['SP'] == 0
Exemple #8
0
def monster():
    hp = random.randint(10, 40)
    pw = random.randint(5, 20)
    df = random.randint(5, 15)
    sp = random.randint(5, 40)
    return stats.build_table(hp, pw, df, sp)
Exemple #9
0
def accessory():
    hp = random.randint(0, 20)
    pw = random.randint(-10, 40)
    df = random.randint(0, 80)
    sp = random.randint(-20, 50)
    return stats.build_table()
Exemple #10
0
def final_boss():
    hp = random.randint(100, 400)
    pw = random.randint(5, 75)
    df = random.randint(40, 80)
    sp = random.randint(0, 30)
    return stats.build_table(hp, pw, df, sp)
Exemple #11
0
 def test_normal_usage(s):
     table = stats.build_table(5, 4, 3, 2)
     assert stats.extract(table) == (5, 4, 3, 2)
Exemple #12
0
 def test_negative_stack(s):
     base = stats.build_table(100, 10, 20, 5)
     item = stats.build_table(0, 0, 10, -10)
     assert stats.stack(base, item)['SP'] == 0