From 1ea9e539e44b901eb88349b09985f80fac9d177f Mon Sep 17 00:00:00 2001 From: DavidWylie-ZUK Date: Mon, 8 Jan 2024 15:00:42 +0000 Subject: [PATCH] fix import issue. --- roll_witch/rolling/command/basic.py | 6 ++--- roll_witch/rolling/command/regex.py | 6 ++--- roll_witch/rolling/command/shadow_run.py | 3 +-- roll_witch/rolling/command/token.py | 2 +- roll_witch/rolling/output/base.py | 2 +- roll_witch/rolling/protocols/__init__.py | 3 ++- roll_witch/rolling/protocols/operation.py | 2 +- roll_witch/rolling/roller/operation_result.py | 7 +++--- tests/test_basic_operation.py | 2 +- tests/test_operation_shadowrun.py | 2 +- tests/test_operation_standard.py | 2 +- tests/test_output_parser.py | 25 +++++++++++++++---- 12 files changed, 37 insertions(+), 25 deletions(-) diff --git a/roll_witch/rolling/command/basic.py b/roll_witch/rolling/command/basic.py index 4beb6e7..08c9d2a 100644 --- a/roll_witch/rolling/command/basic.py +++ b/roll_witch/rolling/command/basic.py @@ -1,10 +1,8 @@ from roll_witch.rolling.input import get_basic_rpg_parser from roll_witch.rolling.output import TargetedOutputWriter -from roll_witch.rolling.roller import TargetedRoller +from roll_witch.rolling.roller import TargetedRoller, OperationRollResults from math import ceil, floor -from rolling.protocols import Operation -from rolling.protocols.result import OperationResult -from rolling.roller import OperationRollResults +from roll_witch.rolling.protocols import Operation, OperationResult class BasicOutputWriter(TargetedOutputWriter): diff --git a/roll_witch/rolling/command/regex.py b/roll_witch/rolling/command/regex.py index 5d1bf9c..29c644a 100644 --- a/roll_witch/rolling/command/regex.py +++ b/roll_witch/rolling/command/regex.py @@ -1,9 +1,8 @@ from roll_witch.rolling.input import get_regex_parser from roll_witch.rolling.output import TargetedOutputWriter, StandardOutputWriter from roll_witch.rolling.roller import TargetedRoller, StandardRoller -from rolling.protocols import Operation -from rolling.protocols.result import OperationResult -from rolling.roller import OperationRollResults +from roll_witch.rolling.protocols import Operation, OperationResult +from roll_witch.rolling.roller import OperationRollResults class RegexOperation(Operation): @@ -21,6 +20,7 @@ def execute(self, roll_string: str, user: str) -> OperationResult: result = OperationRollResults(roll_spec) if roll_spec.has_target(): result.append_roll_result(self.targeted_roller.roll(roll_spec)) + result.met_target = self.targeted_roller.met_target(roll_spec, result.total) else: result.append_roll_result(self.standard_roller.roll(roll_spec)) return result diff --git a/roll_witch/rolling/command/shadow_run.py b/roll_witch/rolling/command/shadow_run.py index 23d742b..ed87706 100644 --- a/roll_witch/rolling/command/shadow_run.py +++ b/roll_witch/rolling/command/shadow_run.py @@ -3,8 +3,7 @@ from roll_witch.rolling.roller import RollResult, RollSpec from roll_witch.rolling.roller import StandardRoller from roll_witch.rolling.roller.operation_result import OperationRollResults -from rolling.protocols import Operation -from rolling.protocols.result import OperationResult +from roll_witch.rolling.protocols import Operation, OperationResult class ShadowRunRollResults(OperationRollResults): diff --git a/roll_witch/rolling/command/token.py b/roll_witch/rolling/command/token.py index bc120f3..14299e2 100644 --- a/roll_witch/rolling/command/token.py +++ b/roll_witch/rolling/command/token.py @@ -5,7 +5,7 @@ TargetedRoller, ) from roll_witch.rolling.roller.operation_result import OperationRollResults -from rolling.protocols import Operation +from roll_witch.rolling.protocols import Operation class TokenOperation(Operation): diff --git a/roll_witch/rolling/output/base.py b/roll_witch/rolling/output/base.py index 43a76df..dd66f31 100644 --- a/roll_witch/rolling/output/base.py +++ b/roll_witch/rolling/output/base.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from rolling.protocols.result import OperationResult +from ..protocols.result import OperationResult class BaseOutputWriter(ABC): diff --git a/roll_witch/rolling/protocols/__init__.py b/roll_witch/rolling/protocols/__init__.py index 53c8b08..5e7e216 100644 --- a/roll_witch/rolling/protocols/__init__.py +++ b/roll_witch/rolling/protocols/__init__.py @@ -1,6 +1,6 @@ from .dice_modifier import DiceModifier from .dice_set import DiceSet -from .result import Result +from .result import Result, OperationResult from .targetable import Targetable from .operation import Operation @@ -10,4 +10,5 @@ "Result", "Targetable", "Operation", + "OperationResult", ] diff --git a/roll_witch/rolling/protocols/operation.py b/roll_witch/rolling/protocols/operation.py index a0ce821..8e78714 100644 --- a/roll_witch/rolling/protocols/operation.py +++ b/roll_witch/rolling/protocols/operation.py @@ -1,5 +1,5 @@ from typing import Protocol -from rolling.protocols.result import OperationResult +from .result import OperationResult class Operation(Protocol): diff --git a/roll_witch/rolling/roller/operation_result.py b/roll_witch/rolling/roller/operation_result.py index cb9f810..cec582f 100644 --- a/roll_witch/rolling/roller/operation_result.py +++ b/roll_witch/rolling/roller/operation_result.py @@ -1,7 +1,6 @@ -from roll_witch.rolling.input.spec.operation import OperationSpec -from roll_witch.rolling.roller import RollResult -from rolling.protocols import Result -from rolling.protocols.result import OperationResult +from ..input.spec.operation import OperationSpec +from . import RollResult +from ..protocols import Result, OperationResult class OperationRollResults(OperationResult): diff --git a/tests/test_basic_operation.py b/tests/test_basic_operation.py index f9834e7..396ae76 100644 --- a/tests/test_basic_operation.py +++ b/tests/test_basic_operation.py @@ -1,6 +1,6 @@ from unittest import TestCase from unittest.mock import patch -from rolling.command import BasicOperation +from roll_witch.rolling.command import BasicOperation class TestStandardOperation(TestCase): diff --git a/tests/test_operation_shadowrun.py b/tests/test_operation_shadowrun.py index 29723d1..671ad9c 100644 --- a/tests/test_operation_shadowrun.py +++ b/tests/test_operation_shadowrun.py @@ -1,6 +1,6 @@ from unittest import TestCase from unittest.mock import patch -from rolling.command import ShadowRunOperation +from roll_witch.rolling.command import ShadowRunOperation class TestShadowrunOperation(TestCase): diff --git a/tests/test_operation_standard.py b/tests/test_operation_standard.py index ac2a605..066eb5e 100644 --- a/tests/test_operation_standard.py +++ b/tests/test_operation_standard.py @@ -1,6 +1,6 @@ from unittest import TestCase from unittest.mock import patch -from rolling.command.regex import RegexOperation +from roll_witch.rolling.command.regex import RegexOperation class TestStandardOperation(TestCase): diff --git a/tests/test_output_parser.py b/tests/test_output_parser.py index 53c703e..68b89f0 100644 --- a/tests/test_output_parser.py +++ b/tests/test_output_parser.py @@ -2,19 +2,22 @@ from roll_witch.rolling.output import StandardOutputWriter, TargetedOutputWriter from roll_witch.rolling.input.spec.operation import RollSpec, OperationSpec from roll_witch.rolling.roller import RollResult -from rolling.roller import OperationRollResults +from roll_witch.rolling.roller import OperationRollResults class TestStandardOutputWriter(TestCase): def test_build_result_string(self): writer = StandardOutputWriter() + spec = OperationSpec() roll_spec = RollSpec(dice_sides=10, dice_count=2) + spec.add_part(roll_spec) roll_result = RollResult(spec=roll_spec) roll_result.append_roll(3) roll_result.append_roll(4) - + operation_result = OperationRollResults(spec=spec) + operation_result.append_roll_result(roll_result) result_string = writer.build_result_string( - roll_result=roll_result, total_string="totalString", user="tester" + roll_result=operation_result, total_string="totalString", user="tester" ) expected_result_string = "tester Roll: totalString Result: 7" self.assertEqual(expected_result_string, result_string) @@ -23,14 +26,20 @@ def test_build_result_string(self): class TestTargetedOutputWriter(TestCase): def test_build_result_string_met_target(self): writer = TargetedOutputWriter() + operation_spec = OperationSpec() roll_spec = RollSpec(dice_sides=10, dice_count=2, target_number=5) + operation_spec.add_part(roll_spec) + roll_result = RollResult(spec=roll_spec) roll_result.append_roll(3) roll_result.append_roll(4) roll_result.met_target = True + operation_result = OperationRollResults(spec=operation_spec) + operation_result.append_roll_result(roll_result) + operation_result.met_target = True result_string = writer.build_result_string( - roll_result=roll_result, total_string="totalString", user="tester" + roll_result=operation_result, total_string="totalString", user="tester" ) expected_result_string = "tester Roll: totalString Total: 7 Target: 5 Result: Success" self.assertEqual(expected_result_string, result_string) @@ -38,13 +47,19 @@ def test_build_result_string_met_target(self): def test_build_result_string_missed_target(self): writer = TargetedOutputWriter() roll_spec = RollSpec(dice_sides=10, dice_count=2, target_number=5) + operation_spec = OperationSpec() + operation_spec.add_part(roll_spec) + roll_result = RollResult(spec=roll_spec) roll_result.append_roll(3) roll_result.append_roll(4) roll_result.met_target = False + operation_result = OperationRollResults(spec=operation_spec) + operation_result.append_roll_result(roll_result) + result_string = writer.build_result_string( - roll_result=roll_result, total_string="totalString", user="tester" + roll_result=operation_result, total_string="totalString", user="tester" ) expected_result_string = "tester Roll: totalString Total: 7 Target: 5 Result: Failed" self.assertEqual(expected_result_string, result_string)