From ecf4ed87116829c80f98e3304c1fd68a35245a13 Mon Sep 17 00:00:00 2001 From: Olaf Szmidt Date: Tue, 26 Sep 2017 16:14:20 +0100 Subject: [PATCH] Effects removed. --- aimmo-game/simulation/effects.py | 51 ----------------- aimmo-game/simulation/map_generator.py | 2 - aimmo-game/simulation/pickups.py | 1 - .../tests/test_simulation/test_effects.py | 57 ------------------- .../tests/test_simulation/test_pickups.py | 13 +---- 5 files changed, 1 insertion(+), 123 deletions(-) delete mode 100644 aimmo-game/simulation/effects.py delete mode 100644 aimmo-game/tests/test_simulation/test_effects.py diff --git a/aimmo-game/simulation/effects.py b/aimmo-game/simulation/effects.py deleted file mode 100644 index 5e262cd11..000000000 --- a/aimmo-game/simulation/effects.py +++ /dev/null @@ -1,51 +0,0 @@ -from abc import ABCMeta, abstractmethod - - -class _Effect(object): - __metaclass__ = ABCMeta - - def __init__(self, avatar): - self._avatar = avatar - self.is_expired = False - - @abstractmethod - def on_turn(self): - raise NotImplementedError() - - -class _TimedEffect(_Effect): - __metaclass__ = ABCMeta - EFFECT_TIME = 10 - - def __init__(self, *args): - super(_TimedEffect, self).__init__(*args) - self._time_remaining = self.EFFECT_TIME - - def remove(self): - self._avatar.effects.remove(self) - - def on_turn(self): - self._time_remaining -= 1 - if self._time_remaining <= 0: - self.is_expired = True - - -class InvulnerabilityPickupEffect(_TimedEffect): - def __init__(self, *args): - super(InvulnerabilityPickupEffect, self).__init__(*args) - self._avatar.resistance += 1000 - - def remove(self): - super(InvulnerabilityPickupEffect, self).remove() - self._avatar.resistance -= 1000 - - -class DamagePickupEffect(_TimedEffect): - def __init__(self, damage_boost, *args): - self._damage_boost = damage_boost - super(DamagePickupEffect, self).__init__(*args) - self._avatar.attack_strength += self._damage_boost - - def remove(self): - super(DamagePickupEffect, self).remove() - self._avatar.attack_strength -= self._damage_boost diff --git a/aimmo-game/simulation/map_generator.py b/aimmo-game/simulation/map_generator.py index 009c3c19d..484313dc1 100644 --- a/aimmo-game/simulation/map_generator.py +++ b/aimmo-game/simulation/map_generator.py @@ -9,8 +9,6 @@ from simulation.direction import ALL_DIRECTIONS from simulation.location import Location from simulation.world_map import WorldMap -from simulation.world_map import world_map_static_spawn_decorator -from simulation.world_map import DEFAULT_LEVEL_SETTINGS from simulation.custom_map import BaseGenerator from simulation.custom_map import BaseLevelGenerator diff --git a/aimmo-game/simulation/pickups.py b/aimmo-game/simulation/pickups.py index 217df7316..179c007f9 100644 --- a/aimmo-game/simulation/pickups.py +++ b/aimmo-game/simulation/pickups.py @@ -1,5 +1,4 @@ from abc import ABCMeta, abstractmethod, abstractproperty -import effects class _Pickup(object): diff --git a/aimmo-game/tests/test_simulation/test_effects.py b/aimmo-game/tests/test_simulation/test_effects.py deleted file mode 100644 index 59759a91a..000000000 --- a/aimmo-game/tests/test_simulation/test_effects.py +++ /dev/null @@ -1,57 +0,0 @@ -from __future__ import absolute_import - -import abc -from unittest import TestCase - -from simulation import effects -from .dummy_avatar import DummyAvatar - - -class _BaseCases(object): - class BaseTimedEffectTestCase(TestCase): - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def make_effect(self, avatar): - pass - - def setUp(self): - self.avatar = DummyAvatar(1, None) - self.effect = self.make_effect(self.avatar) - self.avatar.effects.add(self.effect) - - def assertNoEffects(self): - self.assertEqual(len(list(self.avatar.effects)), 0) - - def test_effect_removed(self): - self.effect.remove() - self.assertNoEffects() - - def test_effect_expires(self): - for _ in xrange(10): - self.effect.on_turn() - self.assertTrue(self.effect.is_expired) - - -class TestInvulnerabilityEffect(_BaseCases.BaseTimedEffectTestCase): - def make_effect(self, *args): - return effects.InvulnerabilityPickupEffect(*args) - - def test_resistance_increases(self): - self.assertEqual(self.avatar.resistance, 1000) - - def test_resistance_decreases(self): - self.effect.remove() - self.assertEqual(self.avatar.resistance, 0) - - -class TestDamageEffect(_BaseCases.BaseTimedEffectTestCase): - def make_effect(self, *args): - return effects.DamagePickupEffect(5, *args) - - def test_damage_increases(self): - self.assertEqual(self.avatar.attack_strength, 6) - - def test_damage_decreases(self): - self.effect.remove() - self.assertEqual(self.avatar.attack_strength, 1) diff --git a/aimmo-game/tests/test_simulation/test_pickups.py b/aimmo-game/tests/test_simulation/test_pickups.py index 21701b464..358102355 100644 --- a/aimmo-game/tests/test_simulation/test_pickups.py +++ b/aimmo-game/tests/test_simulation/test_pickups.py @@ -3,7 +3,7 @@ import abc from unittest import TestCase -from simulation import effects, pickups +from simulation import pickups from .dummy_avatar import DummyAvatar from .maps import MockCell @@ -28,17 +28,6 @@ def test_pickup_removed(self): def pickup_class(self): pass - class BasePickupEffectTestCase(BasePickupTestCase): - __metaclass__ = abc.ABCMeta - - @abc.abstractproperty - def effect_class(self): - pass - - def test_effect_added(self): - self.apply_pickup() - self.assertEqual(len(self.avatar.effects), 1) - self.assertIsInstance(list(self.avatar.effects)[0], self.effect_class) class TestDeliveryPickup(_BaseCases.BasePickupTestCase): pickup_class = pickups.DeliveryPickup