You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.8 KiB
Perl

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/perl
$roles = 10;
open (OUTPUT,">","Game.tex");
print OUTPUT q{\documentclass[oneside,a4paper,12pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage[a4paper]{geometry}
\geometry{tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm,headheight=1cm,headsep=1cm,footskip=0.7cm}
\usepackage{indentfirst}
\usepackage{makeidx}
\begin{document}
\chapterstyle{chappell}
\title{Универсальная игра}
\author{Александр Яковлев}
\maketitle
\tableofcontents
\bigskip
Эта игра генерируется случайно. Вы задаёте необходимое количество игроков -- и получаете готовый сценарий. Уникальный сценарий.
\chapter*{Предыстория}
};
@settings = ('fantasy','horror','normal');
@town_names = ("Майские Раки","Дурдомово",'Сычургино','Марусяно');
print OUTPUT "Игра проходит в деревне ".$town_names[rand @town_names].". ";
$dice = int(rand(10));
$setting = $settings[rand @settings];
if ($setting eq 'horror'){
print OUTPUT "Это обычная тихая деревушка на самом отшибе цивилизации. Но в ней начали происходить странные вещи. ";
@quests = ('werewolf','lost_kids');
for ($i=0;$i<2;$i++){ #генерируем 3 общих квеста
eval('$'.spoink(@quests)." = true;");
}
if ($werewolf){print OUTPUT 'Ходят слухи, что в округе завёлся оборотень.';}
if ($lost_kids){print OUTPUT 'Недавно начали исчезать дети.';}
}
elsif ($setting eq 'fantasy'){
@country_names = ('Нарния', 'Варчения', 'Эрафия', 'Неридел');
print OUTPUT "Это тихая деревушка в волшебной стране ".$country_names[rand @country_names].".";
}
elsif ($setting eq 'normal'){
print OUTPUT 'Это обычная деревня, каких много.';
}
@men_names = ('Марк','Антон','Антуан','Луис','Лука');
@women_names = ('Луиза','Люси','Лора','Лариса','Алиса','Марта');
@surnames = ('Колеватов','Катар','Принтеров');
for ($i=0;$i<$roles;$i++){
if (rand() > 0.5) {$sex = 'man';} else {$sex = 'woman'};
if ($sex eq 'man'){
$name = @men_names[rand @men_names];
$surname = @surnames[rand @surnames];
}
else{
$name = @women_names[rand @women_names];
$surname = @surnames[rand @surnames] . "а";
}
print OUTPUT '\chapter{'.$name.' '.$surname."}\n";
}
print OUTPUT '\end{document}';
close OUTPUT;
system "pdflatex Game.tex";
system "pdflatex Game.tex";
sub spoink(@array){
$i = rand @_;
$return = @_[$i];
splice(@_,$i,$i);
return $return;
}