Skip to content

Commit

Permalink
fix import issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidWylie-ZUK committed Jan 8, 2024
1 parent 5c0cd08 commit 1ea9e53
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 25 deletions.
6 changes: 2 additions & 4 deletions roll_witch/rolling/command/basic.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
6 changes: 3 additions & 3 deletions roll_witch/rolling/command/regex.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions roll_witch/rolling/command/shadow_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion roll_witch/rolling/command/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion roll_witch/rolling/output/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from rolling.protocols.result import OperationResult
from ..protocols.result import OperationResult


class BaseOutputWriter(ABC):
Expand Down
3 changes: 2 additions & 1 deletion roll_witch/rolling/protocols/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -10,4 +10,5 @@
"Result",
"Targetable",
"Operation",
"OperationResult",
]
2 changes: 1 addition & 1 deletion roll_witch/rolling/protocols/operation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Protocol
from rolling.protocols.result import OperationResult
from .result import OperationResult


class Operation(Protocol):
Expand Down
7 changes: 3 additions & 4 deletions roll_witch/rolling/roller/operation_result.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_basic_operation.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_operation_shadowrun.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_operation_standard.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
25 changes: 20 additions & 5 deletions tests/test_output_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -23,28 +26,40 @@ 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)

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)
Expand Down

0 comments on commit 1ea9e53

Please sign in to comment.