~piotr-machura/python-miniprojects

ca429b1d9672484e9e89a0ce27a7cbc9ef898c3c — Piotr Machura 2 years ago de94ee7
Small tweaks
3 files changed, 15 insertions(+), 11 deletions(-)

M LICENSE
M blackjack/exception.py
M collatz/app.py
M LICENSE => LICENSE +1 -1
@@ 17,5 17,5 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
OUT OF OR IN UUCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

M blackjack/exception.py => blackjack/exception.py +10 -5
@@ 1,21 1,26 @@
"""This module contains the custom Exception used to manage game flow"""
"""This module contains the exceptions used to manage game flow"""
from player import Player


class BlackJackException(Exception):
    """The base BlackJackException used to manage game flow."""


class ExitException(BlackJackException):
    """The ExitException used to exit the game."""
    """Used to exit the game."""


class BustedException(BlackJackException):
    """The BustedException used to signify busting."""
    """Used to signify busting."""


class FoldException(BlackJackException):
    """The FoldException used to signify folding."""
    """Used to signify folding."""


class WinException(BlackJackException):
    """The exception used to signify winning."""
    """Used to signify winning."""

    def __init__(self, player: Player):
        super().__init__()
        self.winning_player = player

M collatz/app.py => collatz/app.py +4 -5
@@ 8,11 8,10 @@ from dialog import BrowserDialog

class CollatzApp(QtWidgets.QMainWindow):
    """Main app window."""

    def __init__(self):
        super().__init__()
        self.setWindowTitle(' Collatz')
        self.setFixedSize(550, 700)
        self.setFixedSize(350, 550)
        dir_name = os.path.dirname(os.path.realpath(__file__))
        self.setWindowIcon(QtGui.QIcon(dir_name + os.path.sep + 'icon.svg'))
        self.counter = 0


@@ 98,7 97,7 @@ class CollatzApp(QtWidgets.QMainWindow):
                self.steps_display.insertPlainText('\t| *3 + 1\n')
                self._sequence(int(3 * number + 1))

    @ QtCore.pyqtSlot()
    @QtCore.pyqtSlot()
    def _on_click_start(self):
        """Clear the `stepsDisplay` and start the Collatz sequence."""



@@ 114,7 113,7 @@ class CollatzApp(QtWidgets.QMainWindow):
            f'Terminated after {self.counter} iterations.')
        self.steps_display.moveCursor(QtGui.QTextCursor.End)

    @ QtCore.pyqtSlot()
    @QtCore.pyqtSlot()
    def _on_click_clear(self):
        """Clear the `inputBox` and `stepsDisplay`."""



@@ 122,7 121,7 @@ class CollatzApp(QtWidgets.QMainWindow):
        self.steps_display.clear()
        self.input_box.setFocus()

    @ QtCore.pyqtSlot()
    @QtCore.pyqtSlot()
    def _on_click_info(self):
        """Open a dialog window to acces the relevant Wikipedia article."""