euchre-live

Euchre web-app for the socially distant family
git clone git://git.alexkarle.com/euchre-live.git
Log | Files | Refs | README | LICENSE

Errors.pm (2622B) [raw]


      1 # Euchre::Errors -- constants and messages for all other objects
      2 use strict;
      3 use warnings;
      4 
      5 package Euchre::Errors;
      6 
      7 # NOTE: Append ONLY for client compatibility
      8 use constant {
      9     SUCCESS         => 0,
     10     STAND_UP        => 1,
     11     START_GAME      => 2,
     12     RESTART_GAME    => 3,
     13     ORDER           => 4,
     14     DEALER_SWAP     => 5,
     15     PLAY_CARD       => 6,
     16     TURN            => 7,
     17     UNIQUE_USER     => 8,
     18     INVALID_SEAT    => 9,
     19     TAKEN_SEAT      => 10,
     20     ALREADY_STANDING => 11,
     21     PARTIAL_GAME    => 12,
     22     VOTE_ON_KITTY   => 13,
     23     VOTE_OFF_KITTY  => 14,
     24     BAD_VOTE        => 15,
     25     FOLLOW_SUIT     => 16,
     26     DONT_HAVE_CARD  => 17,
     27     NOT_IN_GAME     => 18,
     28     BAD_PASS        => 19,
     29     NOT_AT_TABLE    => 20,
     30     CHANGE_SEAT     => 21,
     31     MISSING_PARAM   => 22,
     32 };
     33 
     34 require Exporter;
     35 our @ISA = qw(Exporter);
     36 our @EXPORT = qw(
     37     err_msg
     38     SUCCESS
     39     CHANGE_SEAT
     40     STAND_UP
     41     START_GAME
     42     RESTART_GAME
     43     ORDER
     44     DEALER_SWAP
     45     PLAY_CARD
     46     TURN
     47     UNIQUE_USER
     48     INVALID_SEAT
     49     TAKEN_SEAT
     50     ALREADY_STANDING
     51     PARTIAL_GAME
     52     VOTE_ON_KITTY
     53     VOTE_OFF_KITTY
     54     BAD_VOTE
     55     FOLLOW_SUIT
     56     DONT_HAVE_CARD
     57     NOT_IN_GAME
     58     BAD_PASS
     59     NOT_AT_TABLE
     60     MISSING_PARAM
     61 );
     62 
     63 our @ERR_MSGS = ();
     64 $ERR_MSGS[CHANGE_SEAT]     = "Can't change seats during game";
     65 $ERR_MSGS[STAND_UP]        = "Can't change seats during game";
     66 $ERR_MSGS[START_GAME]      = "Game already started";
     67 $ERR_MSGS[RESTART_GAME]    = "Game hasn't ended";
     68 $ERR_MSGS[ORDER]           = "Not time for a vote";
     69 $ERR_MSGS[DEALER_SWAP]     = "Can't swap with Kitty now";
     70 $ERR_MSGS[PLAY_CARD]       = "Can't play cards yet";
     71 $ERR_MSGS[TURN]            = "Not your turn";
     72 $ERR_MSGS[UNIQUE_USER]     = "Username not unique";
     73 $ERR_MSGS[INVALID_SEAT]    = "Invalid seat";
     74 $ERR_MSGS[TAKEN_SEAT]      = "Seat is taken";
     75 $ERR_MSGS[ALREADY_STANDING] = "Already standing!";
     76 $ERR_MSGS[PARTIAL_GAME]    = "Can't start with empty seats";
     77 $ERR_MSGS[VOTE_ON_KITTY]   = "Must vote on kitty's suit";
     78 $ERR_MSGS[VOTE_OFF_KITTY]  = "Can't vote for kitty card suit after turned down";
     79 $ERR_MSGS[BAD_VOTE]        = "Bad vote";
     80 $ERR_MSGS[FOLLOW_SUIT]     = "Have to follow suit!";
     81 $ERR_MSGS[DONT_HAVE_CARD]  = "You don't have that card!";
     82 $ERR_MSGS[NOT_IN_GAME]     = "You're not in any game";
     83 $ERR_MSGS[BAD_PASS]        = "Game exists, password incorrect";
     84 $ERR_MSGS[NOT_AT_TABLE]    = "Need to be at a table for action";
     85 $ERR_MSGS[MISSING_PARAM]   = "Server received incomplete message";
     86 
     87 sub err_msg {
     88     my ($errno) = @_;
     89     my $msg = defined $ERR_MSGS[$errno] ? $ERR_MSGS[$errno] : 'Unknown Error';
     90 
     91     return $msg;
     92 }
     93 
     94 1;