-
Notifications
You must be signed in to change notification settings - Fork 0
/
book.php
70 lines (61 loc) · 2.26 KB
/
book.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<title>Hyloe's Book of Games: NaNoGenMo 2019</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="hyloe.css">
<link href="https://fonts.googleapis.com/css?family=Crimson+Text|Vollkorn&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<?
error_reporting(E_ALL);
ini_set('display_errors', True);
include("textfunctions.php");
include("villagenames.php");
include("otherwords.php");
include("cardgame.php");
?>
<?
$body = "";
$index = "";
$wordcount = 0;
$wordgoal = 50000;
$gametype = 1;
$games = array();
while ($wordcount<$wordgoal)
{
$gametext = generateCardGame($gametype);
if (preg_match("/<h2>(.+)<\/h2>/",$gametext,$matches))
{ $gamename = $matches[1]; }
else
{ $gamename = "Unnamed Game"; }
$games[$gamename] = $gametext;
$words = count(preg_split("/[^\p{L}\p{N}\']+/u",strip_tags($gametext)));
$wordcount += $words;
if (($gametype==1 && $wordcount>$wordgoal*.25) || ($gametype==2 && $wordcount>$wordgoal*.5) || ($gametype==3 && $wordcount>$wordgoal*.75) || $wordcount>=$wordgoal)
{
ksort($games);
$index .= "<h2 class=\"indhead\">".ucfirst(gametypename($gametype))." games</h2><ul class=\"index\">";
$body .= "<h2 class=\"secthead\">".ucfirst(gametypename($gametype))." games</h2>";
foreach ($games as $title => $game)
{
$link = strtolower(preg_replace("/[^A-Za-z]/", "", $title));
$index .= "<li><a href=\"#$link\">$title</a></li> ";
$body .= "<div class=\"game\" id=\"$link\"/>".$game."</div>";
}
$index .= "</ul>";
$games = array();
$gametype++;
}
}
?>
<div class="titlebox">
<h1>Hyloe's Book of Games</h1>
<div class="subtitle"><?=preg_replace("/(\d+)(\d\d\d)/","$1,$2",$wordcount)?> words of fictional card games autogenerated for NaNoGenMo 2019 from <a href="https://github.com/kevandotorg/nanogenmo-2019">a script</a> written by <a href="http://kevan.org">Kevan Davis</a>.<br>
This edition was generated on the <?=date('dS', time());?> of <?=date('F Y', time());?>.</div>
</div>
<?
print "<div class=\"index\">$index</div>";
print $body;
?>
</body></html>