Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/user/bin/perl -w
- #let's try to make a RPG character and wirte him onto a text file.
- #props to wamurphy for the D&D character creation guide.
- open FILE, ">blah.txt";
- #hash for Character's non-numerical
- #characteristics.
- my %char = (
- 'Name' => undef,
- 'Race' => undef,
- 'Alignment' => undef,
- 'Class' => undef,
- );
- #using three character tags on hash to save typing power.
- #Ability Modifiers and the actual ability stats
- my %abilMod = (
- 'STR' => 0,
- 'CON' => 0,
- 'DEX' => 0,
- 'INT' => 0,
- 'CHR' => 0,
- 'WIS' => 0,
- );
- my %charAtt = (
- 'STR' => 0,
- 'CON' => 0,
- 'DEX' => 0,
- 'INT' => 0,
- 'CHR' => 0,
- 'WIS' => 0,
- );
- #I'm going to make putting an intro to the scripts
- #a habit. Good for mental algorithms.
- print "\nThis a charater creator.
- Here we will collect attributes
- on your character and write them
- in a text file.\n";
- print "To start off, what is your name?\n";
- $char{'Name'} = <STDIN>;
- #let's try to use races too.
- my $temp = undef;
- do {
- print "What is your race?(D&D races)\nHuman, Elf, Dwarf, Gnome,Half-Elf, Half-Orc, Halfling\n";
- $temp = <STDIN>;
- $char{'Race'} = $temp;
- #race adjustments
- if ( $temp eq 'Human' ) {
- while ( ( my $key, my $value ) = each %abilMod ) {
- $abilMod{$key} = 0; #assigns all abilMod to 0.
- }
- }
- elsif ( $temp eq 'Dwarf' ) {
- $abilMod{'CHA'} -= 2;
- $abilMod{'CON'} += 2;
- }
- elsif ( $temp eq 'Elf' ) {
- $abilMod{'DEX'} += 2;
- $abilMod{'CON'} -= 2;
- }
- elsif ( $temp eq 'Gnome' ) {
- $abilMod{'CON'} += 2;
- $abilMod{'STR'} -= 2;
- }
- elsif ( $temp eq 'Half-Elf' ) {
- while ( ( my $key, my $value ) = each %abilMod ) {
- $abilMod{$key} = 0; #assigns all abilMod to 0.
- }
- }
- elsif ( $temp eq 'Half-Orc' ) {
- $abilMod{'STR'} += 2;
- $abilMod{'DEX'} -= 2;
- $abilMod{'CHA'} -= 2;
- }
- elsif ( $temp eq 'Halfling' ) {
- $abilMod{'DEX'} += 2;
- $abilMod{'STR'} -= 2;
- }
- else {
- print "You did not select a valid race. You chose $temp.\n";
- $temp = "ERROR";
- }
- } while ( $temp eq "ERROR" );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement