-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.htm
207 lines (189 loc) · 10.7 KB
/
index.htm
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script>
// Convert RSS feed into news list
// http://www.davidjuth.com/rest-demo-jquery-rss.aspx
$( function()
{
$("#feedContainer").empty();
$.get("feed.rss", function(data) {
$('#newsContainer').append("<ul>");
$(data).find('item').slice(0, 4).each(function() {
var $item = $(this);
var title = $item.find('title').text();
var link = $item.find('link').text();
var html = "<a href=\"" + link + "\"><li>" + title + "</a></li>";
$('#newsContainer').append(html);
});
$('#newsContainer').append("</ul>");
});
});
</script>
<script>
function setPlayerCaptions(data) {
n = 12; // is there a nicer way to hardcode this?
// Preconditions:
// We only want candidates with full info (some entries lack xl/race/background/location, so test for xl)
// Check they have a species -- player might be on start screen
// And we need a watch url
candidates = data.filter(function(element) { return "XL" in element && element["species"] != '' && "watchurl" in element});
// There are a two competing goals with the candidate selection:
// * random each refresh
// * picks the best candidates
// To balance this, partition the candidate list into good, ok & bad groups, and select from each in turn as required
// Good: has spectators
// OK: idle < 5 secs
// Bad: everything else
good_candidates = []
ok_candidates = []
bad_candidates = []
_.each(candidates, function(c) {
if (c['viewers'] > 0) {
good_candidates.push(c);
} else if (c['idle'] < 5) {
ok_candidates.push(c);
} else {
bad_candidates.push(c);
}
});
selected_candidates = _.sample(good_candidates, n);
if (selected_candidates.length < n) {
n = n - selected_candidates.length;
selected_candidates = selected_candidates.concat(_.sample(ok_candidates, n));
if (selected_candidates.length < n) {
n = n - selected_candidates.length;
selected_candidates = selected_candidates.concat(_.sample(bad_candidates, n));
}
}
// Note that we might not have enough candidates at this point
if (selected_candidates.length < $( "#tiles div" ).length) {
console.log("Warning: only found " + selected_candidates.length + " candidates.");
}
selected_candidates = _.shuffle(selected_candidates);
// Create & write our tiles
for (var i = 0; i < selected_candidates.length; i++) {
c = selected_candidates[i];
e = $( "<div>" );
e.addClass("col-lg-3 col-md-4 col-sm-6 text-center");
if (i >= 2) {
e.addClass("hidden-xs");
}
if (i >= 4) {
e.addClass("hidden-sm");
}
if (i >= 9) {
e.addClass("hidden-md");
}
e.css("border-radius", "5px");
// image
e.append(
$("<div/>").css('text-align', 'center').css('overflow', 'hidden').css('height', '150px').append(
$("<a/>").attr('href', c["watchurl"]).append(
$("<img/>").attr('src', "splashimgs/dcss-splash-" + i + ".png").css('position', 'relative').css('left', '100%').css('margin-left', '-200%')
)
)
);
// description
e.append(
$("<p/>").addClass("lead").css('margin', '0').append(
$("<a/>").attr('href', c["watchurl"]).text(c["name"] + " the " + c["latest_milestone"]["title"])
)
);
e.append($("<p/>").append($("<em/>").text(getFlavourLine(c))));
$( "#tiles" ).append(e);
// Add in clearfix classes if required
if (i > 0 && i != selected_candidates.length) {
if ((i+1) % 4 == 0) {
$( "#tiles" ).append($("<div/>").addClass("clearfix visible-lg"));
}
if ((i+1) % 3 == 0) {
$( "#tiles" ).append($("<div/>").addClass("clearfix visible-md"));
}
if ((i+1) % 2 == 0) {
$( "#tiles" ).append($("<div/>").addClass("clearfix visible-sm"));
}
}
}
$( "#dcss-online-link" ).text("See all " + data.length + " online games...");
}
function getFlavourLine(game) {
// This function is given a dgl-status game and returns an interesting string about it.
// We do this by generating every line and returning a random one.
// This is sort of inefficient -- is there a smarter way?
m = game["latest_milestone"];
candidates = [];
// These two lines are interesting, so increase their chance
i = "Just " + m['milestone'].slice(0, -1);
candidates.push(i);
candidates.push(i);
i = "Level " + game["XL"] + " " + game["species"] + " " + game["background"] + (m["god"] ? " of " + m["god"] : "");
candidates.push(i);
candidates.push(i);
// location field needs the first letter capitalised
candidates.push(game["location"].charAt(0).toUpperCase() + game["location"].slice(1));
// All other lines will be added to the pool if they're applicable
if (m['zigdeepest'] > 0) {
candidates.push("Reached level " + m['zigdeepest'] + " of a Ziggurat");
}
if (m['zigscompleted'] > 0) {
candidates.push("Completed " + m['zigscompleted'] + " Ziggurats");
}
if ((m['mhp'] * 2) < m['hp']) {
candidates.push("HP: " + m['hp'] + '/' + m['mhp'] + ' MP: ' + m['mp'] + '/' + m['mmp']);
}
if (m['status'].split(",").length > 2) {
candidates.push("Status Effects: " + m['status'].split(",").join(", "));
}
if (m['nrune'] > 1) {
candidates.push("Collected " + m['nrune'] + " runes");
}
if (m['banisher']) {
candidates.push("Banished to the Abyss by " + m['banisher']);
}
if (m['sk']) {
candidates.push("Highest skill: " + m['sk']);
}
return _.sample(candidates, 1);
}
data = $.get("dgl-status.json");
data.done(setPlayerCaptions);
</script>
</head>
<body>
<div class="container">
<div class="page-header">
<center>
<a href="index.htm"><img class="img-responsive" src="logo.png" title="Dungeon Crawl Stone Soup" width="790px" height="152px"></a>
</center>
</div>
<!-- mention free/open-source? -->
<p class="lead text-center">A roguelike adventure through dungeons filled with dangerous monsters in a quest to find the mystifyingly fabulous Orb of Zot.</p>
<center> <!-- XXX: HACKY!!!!! -->
<a href="play.htm" class="btn btn-lg btn-success" style="padding: 20px 32px; font-size: 24px;">Play Online Now!</a>
<br><br>
<p class="text-center">Or download for: <a href="download.htm#windows">Windows</a>, <a href="download.htm#osx">OS X</a>, <a href="download.htm#android">Android</a>, <a href="download.htm#linux">Linux</a>.</p>
</center>
<h2 class="text-center">Live games</h2>
<div class="row" id="tiles"></div>
<a href="watch.htm"><p id="dcss-online-link">See all games...</p></a>
<h2>Latest News</h2>
<div class="container" id="newsContainer"></div>
<p><a href="http://crawl.develz.org/wordpress/blog">All news...</a></p>
<h2>Help & Community</h2>
<ul>
<li><a href="http://crawl.chaosforge.org/">Community Wiki</a>: Up-to-date information on game items & concepts</li>
<li><a href="https://crawl.develz.org/tavern/">Forum</a>: Debate strategy and propose changes on our forums</a></li>
<li><a href="http://webchat.freenode.net/?channels=%23%23crawl">IRC</a>: ##crawl on Freenode is filled with helpful souls offering real-time advice</li>
<li><a href="https://crawl.develz.org/mantis/">Bug Reports</a>: Found a problem? Let us know!</li>
</ul>
<hr>
<p class="small text-right">You are too berserk!</p>
</div>
</body>
</html>