++ed by:
1 non-PAUSE user
Author image sushrut pajai

NAME

Game::RockPaperScissor - object oriented Game::RockPaperScissor!

VERSION

Version 0.01

Game::RockPaperScissor

Game::RockPaperScissor package to output result for Rock - Paper - Scissor game.

SYNOPSIS

    use Game::RockPaperScissor;
    my $rps = Game::RockPaperScissor->new();
    my $game = {
        p1 => 'rock',
        p2 => 'scissor',
    };
   print $rps->get_result($game);

INTRODUCTION

Game::RockPaperScissor package ouputs the result of Rock - Paper - Scissor game for given choice by player 1 and player 2

METHODS

new

        use to create the instace of Game::RockPaperScissor class. Optional args can be passed
        Input : -
                Caller method
        Ouput :- 
                Game::RockPaperScissor class instance 
        

get_result

        used to return the result/ outcome of the game for player 1 only.
        Result belongs to the player 1. It validates the input before calculating outcome.
        Sub will die on invalid input stating the valid option to use.
        call _validate method see pod for more info
        Input :- 
                1) instance of class 
                2) hash ref of game with keys p1 and p2 with values as their respective choices.
        Mandatory input :-
         1) instance of class
         2) Keys p1 and p2
         {
            p1 => 'rock',  #valid choices ('rock|r' | 'paper|p' | 'scissor|s')
            p2 => 'paper'  #valid choices ('rock|r' | 'paper|p' | 'scissor|s')
        }
        Output :-
            return integer values :- 0 or 1 or -1
            0   => Tie
            1   => Win
           -1   => Loose

get_result_modulus

        #believe in TIMTOWTDI
        Yet another method using different algorithm that uses modulus
        used to return the result/ outcome of the game for player 1 only.
        Result belongs to the player 1. It validates the input before calculating outcome.
        Sub will die on invalid input stating the valid option to use.
        call _validate method see pod for more info
        Input :- 
                1) instance of class 
                2) hash ref of game with keys p1 and p2 with values as their respective choices.
        Mandatory input :-
         1) instance of class
         2) Keys p1 and p2
         {
            p1 => 'rock',  #valid choices ('rock|r' | 'paper|p' | 'scissor|s')
            p2 => 'paper'  #valid choices ('rock|r' | 'paper|p' | 'scissor|s')
        }
        Output :-
            return integer values :- 0 or 1 or -1
            0   => Tie
            1   => Win
           -1   => Loose
        

_validate

        internal private method not to be called outside,
        use to validate the input provided to get_result method
        Dies on invalid input
        Input :- hash ref of game with keys p1 and p2 with values as their respective choices.
                    Game hash needed eg. {'p1' =>'s' ,'p2' => 'r'} 
                                        or
                    Game hash needed eg. {'p1' =>'scissor' ,'p2' => 'Rock'}
        output :- 
                nothing

AUTHOR

Sushrut Pajai, <spajai at cpan.org>

BUGS

Please report any bugs or feature requests to bug-game-rockpaperscissor at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Game-RockPaperScissor. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Game::RockPaperScissor

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2020 by Sushrut Pajai.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)