Skip to content

Commit

Permalink
Multi-game randos displayed separately (#32)
Browse files Browse the repository at this point in the history
* templates cleanup

* multi-game randos
  • Loading branch information
Die4Ever authored Aug 6, 2024
1 parent 2fbec3b commit 4e927ed
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 94 deletions.
36 changes: 4 additions & 32 deletions src/_includes/game.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
{%- assign game_data = include.series.games[include.game] -%}

{%- assign randos = "" | split: "" -%}
{%- for rando in include.series.randomizers -%}
{%- assign matched = false -%}

{%- for g in rando.games -%}
{%- if g == include.game -%}
{%- assign matched = true -%}
{%- endif -%}
{%- endfor -%}

{%- if matched == false -%}
{%- continue -%}
{%- endif -%}

{%- assign randos = randos | push: rando -%}
{%- endfor -%}

{%- if randos.size == 0 -%}
{%- continue -%}
{%- endif -%}
{%- assign game_data = include.series.games[include.game] -%}

{%- unless include.notitle -%}
<h4>
Expand All @@ -30,29 +10,21 @@ <h4>
{%- endif -%}
</h4>
{%- endunless -%}

<p>
{%- if game_data.sub-series -%}
{{ game_data.sub-series }}
{% if game_data.genres.size > 0 || game_data.platforms.size > 0 %}
|
|
{% endif %}
{%- endif -%}
{{ game_data.genres | join: ", " }}
{% if game_data.genres.size > 0 && game_data.platforms.size > 0 %}
|
|
{% endif %}
{{ game_data.platforms | join: ", " }}
</p>

{%- if game_data.comment -%}
<p>{{ game_data.comment | markdownify }}</p>
{%- endif -%}

<ul class="game-list">

{%- assign randos = randos | sort_natural: "identifier" -%}
{%- for rando in randos -%}
{%- include rando.html rando=rando parent_name=include.game -%}
{%- endfor -%}

</ul>
12 changes: 7 additions & 5 deletions src/_includes/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
{%- assign series_sorted = series_sorted | sort_natural: "name" -%}

<ul class="list-group list-group-flush">
{%- for series in series_sorted -%}
{%- for series in series_sorted -%}
<li class="list-group-item">
{%- include series.html series=series -%}
</li>
{%- endfor -%}

<li class="list-group-item">
{%- include series.html series=series -%}
{%- include series.html series=site.data.Multi-series games_merged=true -%}
</li>
{%- endfor -%}
</ul>

{%- include series.html series=site.data.Multi-series games_merged=true -%}
8 changes: 5 additions & 3 deletions src/_includes/rando.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{%- assign rando = include.rando -%}
<li class="rando" id="{{ include.parent_name }}-{{ rando.identifier }}">
<li class="rando" id="{{ include.parent_name | cgi_escape }}-{{ rando.identifier | cgi_escape }}">
<h5><a href="{{ rando.url }}">{{ rando.identifier }}</a></h5>

{%- if include.standalone -%}
<ul>{% for game in rando.games %}
{%- if include.showgames -%}
{%- assign randogames = rando.games | sort_natural -%}
<ul>
{% for game in randogames %}
<li>{{ game }}</li>
{% endfor %}
</ul>
Expand Down
6 changes: 6 additions & 0 deletions src/_includes/randos_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ul class="randos-list">
{%- assign randos = include.randos | sort_natural: "identifier" -%}
{%- for rando in randos -%}
{%- include rando.html rando=rando parent_name=include.parent_name showgames=include.showgames -%}
{%- endfor -%}
</ul>
18 changes: 9 additions & 9 deletions src/_includes/recents.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<ul class="recents-list list-group list-group-flush">
{%- for rando in randos -%}
<li class="list-group-item">
{%- if prev_updated != rando.updated-date -%}
{%- assign prev_updated = rando.updated-date -%}
<h3>Updated {{ prev_updated }}</h3>
{%- endif -%}

<ul>
{%- include rando.html rando=rando parent_name="recents" standalone=true -%}
</ul>
{%- if prev_updated != rando.updated-date -%}
{%- assign prev_updated = rando.updated-date -%}
<h3>Updated {{ prev_updated }}</h3>
{%- endif -%}
<ul>
{%- include rando.html rando=rando parent_name="recents" showgames=true -%}
</ul>
</li>
{%- endfor -%}
</ul>
</ul>
70 changes: 25 additions & 45 deletions src/_includes/series.html
Original file line number Diff line number Diff line change
@@ -1,58 +1,38 @@
{%- assign series = include.series -%}
{%- assign games = "" | split: "" -%}
{%- for game in include.series.games -%}
{%- assign games = games | push: game[0] -%}
{%- endfor -%}
{%- assign games = games | sort_natural -%}

{%- assign seriesText = include.series.name -%}
{%- assign firstGame = nil -%}
{%- if games.size == 1 -%}
{%- assign firstGame = games[0] -%}
{%- comment -%} Series with a different name to the sole game within will have their title appended {%- endcomment -%}
{%- if firstGame != seriesText -%}
{%- assign series_suffix = ' <span class="text-muted">(SERIES)</span>' | replace: "SERIES", seriesText -%}
{%- else -%}
{%- assign series_suffix = null -%}
{%- endif -%}

{%- comment -%} Add release date to game listed if present {%- endcomment -%}
{%- assign game_data = include.series.games[firstGame] -%}
{%- assign release_year = game_data.release-date | split: "-" | first -%}
{%- if release_year != null -%}
{%- assign release_year_suffix = ' <span class="text-muted fs-5">(RELEASE)</span>' | replace: "RELEASE", release_year -%}
{%- else -%}
{%- assign release_year_suffix = null -%}
{%- endif -%}

{%- assign seriesText = firstGame | append: release_year_suffix | append: series_suffix -%}
{%- endif -%}

<h3 id="{{ include.series.name }}" class="my-0"><a href="#{{ include.series.name }}"><i class="bi bi-link-45deg"></i></a> {{ seriesText }}</h3>


{%- if include.series.comment -%}
<p>{{ include.series.comment | markdownify }}</p>
<h3 id="{{ series.name | cgi_escape }}" class="my-0"><a href="#{{ series.name | cgi_escape }}"><i class="bi bi-link-45deg"></i></a>
{% if games.size == 1 %}
{%- assign firstGame = games[0] -%}
{%- assign game_data = series.games[firstGame] -%}
{%- assign release_year = game_data.release-date | split: "-" | first -%}

{{ firstGame }}
{% if release_year %}
<span class="text-muted fs-5">({{ release_year }})</span>
{% endif %}

{%- comment -%} Series with a different name to the sole game within will have their title appended {%- endcomment -%}
{% if firstGame != series.name %}
<span class="text-muted">{{ series.name }}</span>
{% endif %}
{% else %}
{{ series.name }}
{% endif %}
</h3>

{%- if series.comment -%}
<p>{{ series.comment | markdownify }}</p>
{%- endif -%}


<ul class="series-list">
{%- if include.games_merged -%}
{%- assign randos = "" | split: "" -%}
{%- for rando in include.series.randomizers -%}
{%- assign randos = randos | push: rando -%}
{%- endfor -%}
{%- assign randos = randos | sort_natural: "identifier" -%}

{%- for rando in randos -%}
{%- include rando.html rando=rando parent_name=include.series.name standalone=true -%}
{%- endfor -%}
{%- include randos_list.html randos=series.randomizers parent_name=series.name showgames=true -%}
{%- else -%}
{%- if firstGame -%}
{%- include game.html series=include.series game=firstGame notitle=true -%}
{%- else -%}
{%- for game in games -%}
{%- include game.html series=include.series game=game -%}
{%- endfor -%}
{%- endif -%}
{%- include series_games.html series=series -%}
{%- endif -%}
</ul>
28 changes: 28 additions & 0 deletions src/_includes/series_games.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{%- assign series = include.series -%}
{%- assign multirandos = series.randomizers | where_exp:"r", "r.games.size >= 3" -%}

{%- assign cutoff = series.randomizers.size | minus: 2 -%}
{%- if multirandos.size > 0 and multirandos.size > cutoff -%}
{%- assign multirandos = series.randomizers -%}
{%- elsif multirandos.size > 0 -%}
<h4>Multi-Game Randomizers</h4>
{%- endif -%}

{%- if multirandos.size > 0 -%}
{%- include randos_list.html series=series parent_name=series.name randos=multirandos showgames=true -%}
{%- endif -%}

{%- if multirandos.size < series.randomizers.size -%}
{%- assign no_game_titles = false -%}
{%- if games.size == 1 -%}{%- assign no_game_titles = true -%}{%- endif -%}

{%- for game in games -%}
{%- assign randos = series.randomizers | where_exp:"r", "r.games.size < 3" | where_exp:"r","r.games contains game" -%}
{%- if randos.size == 0 -%}
{%- continue -%}
{%- endif -%}

{%- include game.html series=series game=game notitle=no_game_titles -%}
{%- include randos_list.html series=series parent_name=game randos=randos -%}
{%- endfor -%}
{%- endif -%}

0 comments on commit 4e927ed

Please sign in to comment.