Example #1
0
def test_screep_ranged_attacks_correct_dmg():
    s1 = Screep(REDTEAM, 3, move=1, range_att=1)
    s2 = Screep(BLUETEAM, 0)
    start_hp = s2.hp
    s1.set_target([s2])
    s1.attack([s2])
    assert s2.hp == start_hp - s1.range_att_mods * RANGED_ATT_DMG
Example #2
0
def test_screep_melee_attacks_correct_dmg():
    s1 = Screep(REDTEAM, 1, move=1, melee_att=1)
    s2 = Screep(BLUETEAM, 0)
    start_hp = s2.hp
    s1.set_target([s2])
    s1.attack([s2])
    assert s2.hp == start_hp - s1.melee_att_mods * MELEE_ATT_DMG
Example #3
0
def test_screep_does_not_move_when_dead():
    s1 = Screep(REDTEAM, 4, move=1, move_func=screep.maint_dist_to_target)
    s2 = Screep(BLUETEAM, 0)
    s1.set_target([s2])
    s1.move([s2])
    assert s1.posn == 3
    s1.hp = 0
    s1.move([s2])
    assert s1.posn == 3
Example #4
0
def test_screep_ranged_attacks_only_when_in_range():
    s1 = Screep(REDTEAM, 4, move=1, range_att=1, move_func=screep.maint_dist_to_target)
    s2 = Screep(BLUETEAM, 0)
    start_hp = s2.hp
    s1.set_target([s2])
    s1.attack([s2])
    assert s2.hp == start_hp
    s1.move([s2])
    s1.attack([s2])
    assert s2.hp == start_hp - s1.range_att_mods * RANGED_ATT_DMG
Example #5
0
def test_closest_to_target_selector_targets_closest_with_one_en():
    melee_screep = Screep(REDTEAM, 10, move=2, melee_att=4)
    ranged_screep = Screep(BLUETEAM, 0, move=1, range_att=2)

    screeps = [melee_screep, ranged_screep]

    melee_screep.set_target(screeps)
    ranged_screep.set_target(screeps)

    assert melee_screep.target == ranged_screep.uuid
    assert ranged_screep.target == melee_screep.uuid
Example #6
0
def test_screep_does_not_attack_when_dead():
    s1 = Screep(REDTEAM, 1, range_att=1)
    s2 = Screep(BLUETEAM, 0)
    start_hp = s2.hp
    s1.set_target([s2])
    s1.attack([s2])
    assert s2.hp < start_hp
    start_hp = s2.hp
    s1.hp = 0
    s1.attack([s2])
    assert s2.hp == start_hp
Example #7
0
def test_screep_maints_distance_from_approching_target():
    s1 = Screep(REDTEAM, 8, move=2, move_func=lambda self, screeps:screep.maint_dist_to_target(self, screeps, 6))
    s2 = Screep(BLUETEAM, 0, move=1, move_func=screep.maint_dist_to_target)
    screeps = [s1, s2]
    s1.set_target(screeps)
    s2.set_target(screeps)
    s1.move(screeps)
    s2.move(screeps)
    # s1 move closer to get into range
    assert s1.posn == 6
    assert s2.posn == 1
    s1.move(screeps)
    s2.move(screeps)
    # s1 move 1 farther, to keep range
    assert s1.posn == 7
    assert s2.posn == 2
    s1.move(screeps)
    s2.move(screeps)
    # s1 move 1 farther, to keep range
    assert s1.posn == 8
    assert s2.posn == 3
Example #8
0
def test_closest_to_target_selector_targets_closest_with_mult_en():
    en_melee_screep = Screep(REDTEAM, 10, move=2, melee_att=4)
    en_ranged_screep = Screep(REDTEAM, 11, move=1, range_att=2)
    
    ranged_screep = Screep(BLUETEAM, 0, move=1, range_att=2)
    
    screeps = [en_melee_screep, en_ranged_screep, ranged_screep]

    en_melee_screep.set_target(screeps)
    en_ranged_screep.set_target(screeps)
    ranged_screep.set_target(screeps)

    assert en_melee_screep.target == ranged_screep.uuid
    assert en_ranged_screep.target == ranged_screep.uuid
    assert ranged_screep.target == en_melee_screep.uuid
Example #9
0
def test_maint_dist_to_target_moves_closer_with_pos_numbers():
    s1 = Screep(REDTEAM, -1,move=1, move_func=screep.maint_dist_to_target)
    s2 = Screep(BLUETEAM, -10)
    s1.set_target([s1,s2])
    s1.move([s1, s2])
    assert s1.posn == -2