Created
May 31, 2020 07:11
-
-
Save sironekotoro/2e332f39ee4ea60e7371cba8537c9829 to your computer and use it in GitHub Desktop.
RPGの戦闘的な何か
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
# TODO: 素早さでターンを決められるようにする | |
# TODO: どっちかのHPがなくなるまでやる | |
my $fighter = {HP => 10, ATK => 2}; | |
my $ork = {HP => 15, ATK => 1}; | |
# 第1ターン | |
attack($ork, $fighter); | |
# 第2ターン | |
attack($fighter,$ork); | |
# 第3ターン | |
attack($ork, $fighter); | |
print $fighter->{HP} , "\n"; | |
print $ork->{HP} , "\n"; | |
sub attack { | |
my $attacker = shift; | |
my $defender = shift; | |
$defender->{HP} = $defender->{HP} - $attacker->{ATK}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment