
Games::Traveller::UWP - The Universal World Profile parser for the Traveller role-playing game.

use Games::Traveller::UWP; print "This is UWP $Games::Traveller::UWP::VERSION\n"; my $uwp = new Games::Traveller::UWP; my $line = "My World 0980 X123456-8 N Ri Ag Cp R G"; $uwp->readUwp( $line ); print $uwp->toString(); $uwp->readUwp( 'Foo 1010 A123456-7 B Ri In Da Na R 232 Im K0 V [(G5 D G6 D)] :1010, 1011, 1012' ); print $uwp->toString();

The UWP package is a module that provides access to UWP data by parsing a valid UWP line, stored in a scalar string. The data is parsed and made available to the user via a rich set of accessors, some of which are usable as L-values (but most are read-only).

To create an instance of a UWP:
my $uwp = new Games::Traveller::UWP;
The following accessors can be either RValues (read) or LValues (write):
$uwp->name
$uwp->loc
$uwp->starport
$uwp->size
$uwp->atmosphere
$uwp->hydrographics
$uwp->popDigit
$uwp->government
$uwp->law
$uwp->tl
$uwp->bases
$uwp->codes
$uwp->zone
$uwp->popMult
$uwp->belts
$uwp->ggs
$uwp->allegiance
$uwp->starData (an array ref)
$uwp->routes (an array ref)
starData() returns a four-element array reference, each element of which
contains another array reference to a group of stars:
my $aref = $uwp->starData();
my @array = @$aref;
print $aref[0]->[0] # primary star. always present.
, $aref[0]->[1] # binary companion to primary, if there is one.
, $aref[1]->[0] # first 'near' companion star
, $aref[1]->[1] # second 'near' companion star
, $aref[2]->[0] # far primary star.
, $aref[2]->[1] # binary companion to far primary, if there is one.
, $aref[3]->[0] # first 'near' companion star to far primary
, $aref[3]->[1]; # second 'near' companion star to far primary
These elements (primary, companion, far, far companion) are individually
accessible via these read-write methods:
$uwp->primary
$uwp->companion
$uwp->far
$uwp->farCompanion
These all return array references.
print $uwp->primary->[0], "\n"; # primary star only
print "@{$uwp->primary}\n"; # primary with its binary companion, if any.
print $uwp->companion->[0], "\n"; # first near companion
print "@{$uwp->companion}\n"; # all near companions
print $uwp->far->[0], "\n"; # far primary only
print "@{$uwp->far}\n"; # far primary with binary companion, if any.
print $uwp->farCompanion->[0], "\n"; # first near companion to far primary
print "@{$uwp->farCompanion}\n"; # all near companions to far primary
In addition to the above, there is a large body of read-only accessors:
$uwp->population # calculates the population from the popDigit and popMult
$uwp->col # returns the column component of the hex location
$uwp->row # ibid for the row
$uwp->isNice # returns '1' if the TL < 7, OR
# the atmosphere is pleasant, OR
# the population >= 100 million
$uwp->isGassy # returns '1' if the atmosphere isn't 0 (zero)
$uwp->isaRock # returns '1' if the size is not 0 (zero)
# AND the atmosphere and hydrographics ARE 0 (zero)
$uwp->uwp # returns the core UWP (i.e. "A123456-7")
$uwp->pbg # returns the PBG string (i.e. "323")
$uwp->stars # returns the standard star data string
$uwp->importance # calculates how important the world probably is
$uwp->countBillionsOfPeople # returns the population in billions
$uwp->alphabetizeTradeCodes
$uwp->regenerateTradeCodes # re-does trade codes
The previous method is useful if you've been changing the UWP values around.
$uwp->isBa # returns 'Ba' if the world is Barren
$uwp->isLo # returns 'Lo' if the world is Low-Pop
$uwp->isHi # high pop
$uwp->isAg # agricultural
$uwp->isNa # non-agri
$uwp->isIn # industrial
$uwp->isNi # non-ind
$uwp->isRi # rich
$uwp->isPo # poor
$uwp->isWa # water world
$uwp->isDe # desert
$uwp->isAs # mainworld is asteroid
$uwp->isVa # vacuum world
$uwp->isIc # all water is ice
$uwp->isFl # non-water fluid oceans
$uwp->isCp # subsector capital
$uwp->isCx # sector capital
Finally,
$uwp->toString
returns the UWP data encapsulated in a string, suitable for writing to an output stream.

Pasuuli Immuguna

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

The latest version of this library is likely to be available from CPAN.