Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- my $end = undef;
- my $scoreRobot = 0;
- my $scorePlayer = 0;
- my $pointsManche = 0;
- my $scoreManche = 0;
- my $stat1Point = 0.2097907;
- my $stat5Points = 0.409295 + $stat1Point;
- my $stat10Points = 0.07171503 + $stat5Points;
- my $stat15Points = 0.03024561 + $stat10Points;
- my $stat20Points = 0.07119105 + $stat15Points;
- my $stat25Points = 0.0005468955 + $stat20Points;
- my $stat40Points = 0.0007401518 + $stat25Points;
- my $stat60Points = 0.0001006128 + $stat40Points;
- my $stat0Point = 0.2025406 + $stat60Points;
- my $statBanqueroute = 0.003833333 + $stat0Point;
- sub lanceDeDes {
- my $rand = rand();
- my $points = 0;
- if ($rand < $stat1Point) {
- $points = 1;
- } elsif ($rand < $stat5Points) {
- $points = 5;
- } elsif ($rand < $stat10Points) {
- $points = 10;
- } elsif ($rand < $stat15Points) {
- $points = 15;
- } elsif ($rand < $stat20Points) {
- $points = 20;
- } elsif ($rand < $stat25Points) {
- $points = 25;
- } elsif ($rand < $stat40Points) {
- $points = 40;
- } elsif ($rand < $stat60Points) {
- $points = 60;
- } elsif ($rand < $stat0Point) {
- $points = 0;
- } else {
- $points = -1;
- }
- return $points;
- }
- print "Bienvenue dans le jeu du cochon!\n\n";
- while (!$end) {
- print "\nAppuyez sur Entree pour lancer les des, une autre touche pour passer\n";
- my $input = <STDIN>;
- chomp $input;
- if ($input eq "") {
- $pointsManche = lanceDeDes();
- if ($pointsManche > 0) {
- print "Vous avez fait " . $pointsManche . " point\n";
- $scorePlayer += $pointsManche;
- if ($scorePlayer >= 100) {
- print "Vous avez fait 100 points, vous avez gagné !\n\n";
- $end = 1;
- }
- } else {
- print "Vous avez fait faillite, vous avez perdu !\n";
- $scorePlayer = 0;
- $end = 1;
- }
- print "Scores: " . $scorePlayer . " pour vous, " . $scoreRobot . " pour la machine.\n";
- } else {
- $scoreManche = 0;
- while (!$end && $scoreManche < 15) {
- $pointsManche = lanceDeDes();
- if ($pointsManche < 0) {
- print "L'ordinalteur a fait faillite, vous avez gagné !\n";
- $end = 1;
- } else {
- $scoreManche += $pointsManche;
- $scoreRobot += $pointsManche;
- if ($scoreRobot >= 100) {
- print "L'ordinateur a gagné !\n";
- $end = 1;
- }
- print "Scores: " . $scorePlayer . " pour vous, " . $scoreRobot . " pour la machine.\n";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement