示例#1
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
示例#2
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"))
示例#3
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))
示例#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()
示例#5
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
示例#6
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])
示例#7
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"))
示例#8
0
 def test_no_data(self):
     actor = Actor({}, 'Heroes', Mock())
     self.assertEqual(None, actor.average("roll"))
示例#9
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)
示例#10
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)
示例#11
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)