NAME

Games::Battleship::Craft - A Battleship craft class

SYNOPSIS

use Games::Battleship::Craft;

$craft = Games::Battleship::Craft->new(
    id => 'T',
    name => 'tug boat',
    points => 1,
)

$points_remaining = $craft->hit;

ABSTRACT

A Battleship craft class

DESCRIPTION

A Games::Battleship::Craft object represents a Battleship craft class.

PUBLIC METHODS

new %ARGUMENTS
  • id => $STRING

    A scalar identifier to use to indicate position on the grid. If one is not provided, the uppercased first name characer will be used by default.

    Currently, it is required that this be a single uppercase letter (the first letter of the craft name, probably), since a hit will be indicated by "lowercasing" this mark on a player grid.

  • name => $STRING

    A required attribute provided to give the craft a name.

  • points => $NUMBER

    An attribute used to define the line segment span on the playing grid.

  • position => [$X, $Y]

    The position of the craft's "nose" on the grid.

hit
$points_remaining = $craft->hit;

Increment the craft's hit attribute value and return the difference between the points and hit attribute values.

TO DO

Allow a craft to have a width.

SEE ALSO

Games::Battleship

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2003, Gene Boggs

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.