def test_detect_mismatch_in_collection(self):
        """
        Test that matcher can detect a mismatch in collection
        """
        collection = EffectsCollection()
        handle1 = EffectHandle(trigger='on drink',
                               effect=None,
                               parameters=None,
                               charges=1)

        handle2 = EffectHandle(trigger='on kick',
                               effect=None,
                               parameters=None,
                               charges=1)

        handle3 = EffectHandle(trigger='on burn',
                               effect=None,
                               parameters=None,
                               charges=1)

        collection.add_effect_handle(handle1)
        collection.add_effect_handle(handle2)

        matcher = ContainsEffectHandle([handle1, handle2, handle3])

        assert_that(matcher._matches(collection), is_(equal_to(False)))
示例#2
0
 def __init__(self):
     """
     Default constructor
     """
     self.targets = []
     self.effects = EffectsCollection()
     self.spirit = 0
    def test_mismatch_any(self):
        """
        Test that matcher can mismatch to any handle
        """
        collection = EffectsCollection()

        matcher = ContainsEffectHandle(None)

        assert_that(matcher._matches(collection), is_(equal_to(False)))
    def test_match_any(self):
        """
        Test that matcher can match to any handle
        """
        collection = EffectsCollection()
        handle1 = EffectHandle(trigger='on drink',
                               effect=None,
                               parameters=None,
                               charges=1)

        collection.add_effect_handle(handle1)

        matcher = ContainsEffectHandle(None)

        assert_that(matcher._matches(collection), is_(equal_to(True)))
    def test_match_single_handle(self):
        """
        Test that single handle can be matched
        """
        collection = EffectsCollection()
        handle = EffectHandle(trigger='on drink',
                              effect=None,
                              parameters=None,
                              charges=1)

        collection.add_effect_handle(handle)

        matcher = ContainsEffectHandle(handle)

        assert_that(matcher._matches(collection), is_(equal_to(True)))
示例#6
0
    def build(self):
        """
        Build item

        Returns:
            Item
        """
        item = Item(effects_collection=EffectsCollection())

        item.name = self.name
        item.appearance = self.appearance
        item.location = self.location
        item.icon = self.icon
        item.tags = self.tags

        if self.weapon_data is not None:
            item.weapon_data = self.weapon_data
            item.tags.append('weapon')

        if self.armour_data is not None:
            item.armour_data = self.armour_data
            item.tags.append('armour')

        if self.ammunition_data is not None:
            item.ammunition_data = self.ammunition_data
            item.tags.append('ammunition')

        if self.trap_data is not None:
            item.trap_data = self.trap_data
            item.tags.append('trap bag')

        if self.boots_data is not None:
            item.boots_data = self.boots_data
            item.tags.append('boots')

        for handle in self.effect_handles:
            item.add_effect_handle(handle)

        for effect in self.effects:
            item.add_effect(effect)

        return item
    def test_detect_sinle_mismatch(self):
        """
        Test that missing a single handle is detected correctly
        """
        collection = EffectsCollection()
        handle1 = EffectHandle(trigger='on drink',
                               effect=None,
                               parameters=None,
                               charges=1)

        collection.add_effect_handle(handle1)

        handle2 = EffectHandle(trigger='on kick',
                               effect=None,
                               parameters=None,
                               charges=1)

        matcher = ContainsEffectHandle(handle2)

        assert_that(matcher._matches(collection), is_(equal_to(False)))
    def test_match_multiple_handles(self):
        """
        Test that matcher can match multiple handlers
        """
        collection = EffectsCollection()
        handle1 = EffectHandle(trigger='on drink',
                               effect=None,
                               parameters=None,
                               charges=1)

        handle2 = EffectHandle(trigger='on kick',
                               effect=None,
                               parameters=None,
                               charges=1)

        collection.add_effect_handle(handle1)
        collection.add_effect_handle(handle2)

        matcher = ContainsEffectHandle([handle1, handle2])

        assert_that(matcher._matches(collection), is_(equal_to(True)))
示例#9
0
    def __init__(self):
        """
        Default constructor
        """
        super().__init__()
        self.hit_points = 10
        self.max_hp = 10
        self.spirit = 5
        self.max_spirit = 5
        self.model = mock()

        self.speed = 1
        self.tick = 0
        self.attack = 1
        self.body = 1
        self.mind = 1
        self.finesse = 1
        self.size = 'medium'

        self.name = 'prototype'

        self.level = None
        self.location = ()

        self.items = []
        self.weapon = None

        self.effect_handles = []
        self.effects = []
        self.effects_collection = EffectsCollection()
        self.player_character = False

        self.listeners = []
        self.update_listeners = []

        self.domains = {}
        self.spell_entries = []

        self.cooldowns = {}