Exemplo n.º 1
0
class TestStaggeredIncreasesSuccess(unittest.TestCase):
    def setUp(self):
        self.simulator = Simulator({'heroes': [], 'villains': []})
        self.actor = Actor({
            'weapons': ['Knife'],
            'tactics': 'thrust_attack'
        }, 'Heroes', self.simulator)
        self.foe = Actor(
            {
                'weapons': ['Knife'],
                'level': 2,
                'tactics': 'thrust_attack'
            }, 'Villains', self.simulator)
        self.actor.foe = self.foe

    def test_foe_staggered_with_1_success(self):
        self.actor.dice_pool_class = FixedDicePool
        self.foe.add_condition(Condition(ConditionType.STAGGERED))
        decision_state = DecisionState(self.actor)

        FixedDicePool.roll_value = 1
        decision_state.take_turn()

        self.assertEqual(1, self.foe.health)

    def test_foe_staggered_with_2_successes(self):
        self.actor.dice_pool_class = FixedDicePool
        self.foe.add_condition(Condition(ConditionType.STAGGERED))
        decision_state = DecisionState(self.actor)

        FixedDicePool.roll_value = [2, 1]
        decision_state.take_turn()

        self.assertEqual(0, self.foe.health)
Exemplo n.º 2
0
 def instantiate_actor(self, data, faction):
     if isinstance(data, str):
         data = load_data(data, directory="data/actors")[0]
     actor = Actor(data.copy(), faction, self)
     name = actor.name()
     count = self.name_counters.get(name, 1)
     if count > 1:
         actor.suffix_name(count)
     self.name_counters[name] = count + 1
     return actor
Exemplo n.º 3
0
 def setUp(self):
     self.simulator = Simulator({'heroes': [], 'villains': []})
     self.actor = Actor({
         'weapons': ['Knife'],
         'tactics': 'thrust_attack'
     }, 'Heroes', self.simulator)
     self.foe = Actor(
         {
             'weapons': ['Knife'],
             'level': 2,
             'tactics': 'thrust_attack'
         }, 'Villains', self.simulator)
     self.actor.foe = self.foe
Exemplo n.º 4
0
 def test_item_action_included_in_actions(self):
     self.actor = Actor(
         {
             'weapons': ['LongSword'],
             'tactics': 'thrust_attack'
         }, 'Heroes', self.simulator)
     decision_state = DecisionState(self.actor)
     assert "thrust_attack" in decision_state.actions()
     assert "ranged_attack" not in decision_state.actions()
Exemplo n.º 5
0
    def test_action_property_overrides(self):
        self.actor.foe = Actor({'tactics': 'thrust_attack'}, 'Villains',
                               self.simulator)
        decision_state = DecisionState(self.actor)
        decision_state._action_properties["thrust_attack"][
            'vantage'] = lambda ds: self.set_message_and_return(
                "vantage_modified", 3)

        self.messages = []
        decision_state.thrust_attack()
        self.assertEqual("vantage_modified", self.messages[0])
Exemplo n.º 6
0
 def test_can_move_to_attack(self):
     simulator = Mock()
     simulator.faction_position.return_value = 0
     actor = Actor({
         'name': 'attacker',
         'weapons': ['Knife']
     }, "Heroes", simulator)
     actor.dice_pool_class = RiggedDicePool
     simulator.faction_position.return_value = actor.speed()
     foe = Actor({'name': 'defender'}, "Villains", simulator)
     actor.foe = foe
     actor.position = 1
     ds = DecisionState(actor)
     ds.thrust_attack()
     self.assertEquals(1, actor.average("wound_foe"))
Exemplo n.º 7
0
 def test_fleeting_condition_removed_at_end_of_turn(self):
     actor = Actor({'tactics': 'wait'}, 'Heroes', self.simulator)
     actor.add_condition(Condition(ConditionType.PREPARED_FOR, actor))
     self.assertEqual(
         True, actor.has_condition(ConditionType.PREPARED_FOR, actor))
     decision_state = DecisionState(actor)
     decision_state.take_turn()
     self.assertEqual(
         False, actor.has_condition(ConditionType.PREPARED_FOR, actor))
Exemplo n.º 8
0
 def test_with_data(self):
     actor = Actor({}, 'Heroes', Mock())
     actor.track_average('roll', 1)
     actor.track_average('roll', 2)
     self.assertEqual(1.5, actor.average("roll"))
Exemplo n.º 9
0
 def test_no_data(self):
     actor = Actor({}, 'Heroes', Mock())
     self.assertEqual(None, actor.average("roll"))
Exemplo n.º 10
0
 def test_damage_overkill(self):
     actor = Actor({'vitality': 0, 'health': 3}, 'Heroes', self.simulator)
     actor.takes_damage(4)
     self.assertEqual(0, actor.health)
     self.assertEqual(0, actor.vitality)
Exemplo n.º 11
0
 def test_damage_with_lots_of_vitality(self):
     actor = Actor({'vitality': 3, 'health': 3}, 'Heroes', self.simulator)
     actor.takes_damage(2)
     self.assertEqual(3, actor.health)
     self.assertEqual(1, actor.vitality)
Exemplo n.º 12
0
 def test_damage_with_some_vitality(self):
     actor = Actor({'vitality': 1, 'health': 3}, 'Heroes', self.simulator)
     actor.takes_damage(2)
     self.assertEqual(2, actor.health)
     self.assertEqual(0, actor.vitality)