add all the help

This commit is contained in:
ajuvercr 2020-04-07 11:31:28 +02:00
parent 93542e4e90
commit 14bd2d5e24
9 changed files with 233 additions and 40 deletions

View file

@ -5,7 +5,7 @@ use rocket_contrib::templates::Template;
use crate::util::*;
const MAX: usize = 3;
const MAX: usize = 6;
#[get("/info")]
fn help_base() -> Redirect {

View file

@ -1,5 +1,6 @@
.content {
justify-content: center;
max-height: 100%;
}
.pointer {
@ -16,14 +17,14 @@
height: 70%;
width: 100%;
clip-path: polygon(100% 0%, 50% 48%, 100% 100%, 50% 100%, 0% 50%, 50% 0);
background-color: #ff7f00;
background-color: #A35200;
}
.p_right {
margin: 5px;
height: 70%;
width: 100%;
background-color: #ff7f00;
background-color: #A35200;
clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0% 100%, 50% 50%, 0% 0%);
}
@ -70,6 +71,11 @@
margin: auto;
}
.help_content {
overflow: auto;
height: 100%;
}
.boxed {
border: 3px #A35200 solid;
border-radius: 50px;
@ -109,6 +115,28 @@
margin: 10px;
}
.help_content_2 {
display: flex;
flex-direction: column;
width: 80%;
justify-content: space-evenly;
margin: 0 auto;
}
.help_content_2 h2 {
margin: 2px 0;
margin-top: 20px;
}
.help_content_2 em {
color: #A35200;
}
.help_content_2 h3 {
margin: 5px;
color: #bbb;
}
.arrow {
width: 20%;
background-color: #A35200;
@ -119,4 +147,36 @@
.arrow>div {
text-align: center;
}
ul {
margin: 10px inherit;
color: #eee;
font-size: 1.5em;
}
li {
margin: 10px 10px;
}
.help_content_1 h2 {
color: #bbb;
margin-top: 2em;
font-size: 1.7;
}
pre {
padding: 0;
margin-bottom: -20px;
}
pre code {
background-color: #333;
border: 1px solid #eee;
display: block;
padding: 20px;
}
.commands {
font-size: 1.3em;
}

View file

@ -2,41 +2,29 @@
{% block header %}
How does it work?
Information
{% endblock %}
{% block help %}
<div class="help_content_1">
<div class="boxed centering">
<div>
Game State
</div>
</div>
<div class="arrow centering">
<div>
stdin
</div>
</div>
<div class="boxed centering">
<div>
Bot (you!)
</div>
</div>
<div class="arrow centering">
<div>
stdout
</div>
</div>
<div class="boxed centering">
<div>
Actions
</div>
</div>
</div>
<div class=help_content_1_sub>
<div>Turn</div>
</div>
<div class="help_content_2">
<h2>Rules</h2>
<ul>
<li>turn-based</li>
<li>planets on 2d plane</li>
<li>players can occupy planets</li>
<li>each turn, an occupied planet constructs a new ship for its owner</li>
<li>spaceship travel time is proportional to the euclidean distance (floor(sqrt(dx * dx - dy * dy)))</li>
<li>combat happens only on planets</li>
</ul>
<h2>Turn Order</h2>
<ul>
<li>ship construction</li>
<li>dispatches</li>
<li>combat resolution</li>
</ul>
</div>
{% endblock %}

View file

@ -2,13 +2,25 @@
{% block header %}
Information
{% endblock %}
{% block help %}
<div class="help_content_2">
<h2>Combat resolution</h2>
<ul>
<li>fleets belonging to the same player are merged</li>
<li>each ship destroys one ship in all other fleets</li>
<li>this means the largest fleet wins, with <em>|fleet| - |second largest fleet|</em> ships remaining</li>
</ul>
<h2>How to win</h2>
<ul>
<li>The last player standing wins!</li>
<li>When the turn limit is reached, all remaining players tie.</li>
</ul>
</div>
{% endblock %}

View file

@ -2,13 +2,46 @@
{% block header %}
Interaction with the game
{% endblock %}
{% block help %}
<div class="help_content_1">
<div class="boxed centering">
<div>
Game State
</div>
</div>
<div class="arrow centering">
<div>
stdin
</div>
</div>
<div class="boxed centering">
<div>
Bot (you!)
</div>
</div>
<div class="arrow centering">
<div>
stdout
</div>
</div>
<div class="boxed centering">
<div>
Actions
</div>
</div>
</div>
<div class=help_content_1_sub>
<div>Turn</div>
</div>
<div class=help_content_1>
<h2>
Format: line-separated JSON (one line for each turn)
</h2>
</div>
{% endblock %}

View file

@ -0,0 +1,42 @@
{% extends "help/base" %}
{% block header %}
Format: Game state
{% endblock %}
{% block help %}
<div class="help_content_2">
<pre>
<code>{
"planets": [
{
“name”: “my cool planet”,
“x”: 42,
“y”: 42,
“owner”: 1,
“ship_count”: 23
}
],
"expeditions": [
{
“id”: 1000,
“origin”: “my boring planet”,
“destination”: “my cool planet”,
“turns_remaining”: 3,
“owner”: 2,
“ship_count”: 18
}
]
}</code>
</pre>
<h3>Player numbers are rotated so that you are always player 1.</h3>
<h3>Note that player numbers are 1-based.</h3>
<h3>Neutral planets exist, they dont have an owner (not in JSON, null, …)</h3>
</div>
{% endblock %}

View file

@ -0,0 +1,30 @@
{% extends "help/base" %}
{% block header %}
Format: Player turn (actions)
{% endblock %}
{% block help %}
<div class="help_content_2">
<pre>
<code>{
“moves”: [
{
“origin”: “my boring planet”,
“destination”: “my cool planet”,
“ship_count”: 23
}
]
}</code>
</pre>
<h3>Invalid commands are ignored by the game implementation.</h3>
<h3>If your bot crashes, you can reconnect but chances of winning are slim.</h3>
<h3>Your bot is allowed one second to compute its turn.</h3>
</div>
{% endblock %}

View file

@ -0,0 +1,28 @@
{% extends "help/base" %}
{% block header %}
How to connect
{% endblock %}
{% block help %}
<div class="help_content_2">
<h2>You run your bot at your own pc and connect over tcp.</h2>
<h3>Follow these commands to connect using <em>simple.py</em>.</h3>
<pre class="commands">
<code>
$ wget mozaic.zeus.gent/bot/runner.py
$ wget mozaic.zeus.gent/bot/simple.py
$ python runner.py -p 9142 --host mozaic.zeus.gent \
-n &lt;Your name&gt; -i &lt;Id from the lobby&gt; \
python simple.py
</code>
</pre>
</div>
{% endblock %}

View file

@ -28,7 +28,7 @@
<h3>Create a game</h3>
</div>
</a>
<a class="step" href='/info'>
<a class="step" href='/info/6'>
<div class="step_content">
<h2>Step 3:</h2>
<h3>Play!</h3>