Compare commits

...

1 Commits

Author SHA1 Message Date
Tim Van Baak 94be9b00cf tmp 2021-10-10 20:28:26 -07:00
4 changed files with 176 additions and 7 deletions

View File

@ -562,7 +562,7 @@ class ArticleContentRuleType(enum.Enum):
# Whether characters can cite themselves # Whether characters can cite themselves
ALLOW_SELF_CITE = 0 ALLOW_SELF_CITE = 0
# Whether characters can write new articles instead of phantoms # Whether characters can write new articles instead of phantoms
ALLOW_NEW_ARTICLE = 1 FORCE_PHANTOM = 1
# Required number of extant articles cited # Required number of extant articles cited
CITE_EXTANT_MIN = 2 CITE_EXTANT_MIN = 2
CITE_EXTANT_MAX = 3 CITE_EXTANT_MAX = 3

View File

@ -274,6 +274,15 @@ def assign_post(lexicon_name):
) )
@bp.get("/constraint/")
@lexicon_param
@editor_required
def constraint(lexicon_name):
return render_template(
"settings.jinja", lexicon_name=lexicon_name, page_name=constraint.__name__
)
@bp.get("/publish/") @bp.get("/publish/")
@lexicon_param @lexicon_param
@editor_required @editor_required

View File

@ -27,6 +27,7 @@
<li>{{ settings_page_link("setup", "Game Setup") }}</li> <li>{{ settings_page_link("setup", "Game Setup") }}</li>
<li>{{ settings_page_link("index", "Article Indices") }}</li> <li>{{ settings_page_link("index", "Article Indices") }}</li>
<li>{{ settings_page_link("assign", "Index Assignments") }}</li> <li>{{ settings_page_link("assign", "Index Assignments") }}</li>
<li>{{ settings_page_link("constraint", "Article Constraints") }}</li>
<li>{{ settings_page_link("publish", "Turn Publishing") }}</li> <li>{{ settings_page_link("publish", "Turn Publishing") }}</li>
<li>{{ settings_page_link("article", "Article Requirements") }}</li> <li>{{ settings_page_link("article", "Article Requirements") }}</li>
</ul> </ul>
@ -92,10 +93,10 @@
<h3>Article Indexes</h3> <h3>Article Indexes</h3>
<details class="setting-help"> <details class="setting-help">
<summary>Index definition help</summary> <summary>Index definition help</summary>
<p>An index is a rule that matches the title of a lexicon article based on its <em>index type</em> and <em>pattern</em>. A <em>char</em> index matches a title if the first letter of the title (excluding "A", "An", and "The") is one of the letters in the pattern. A <em>range</em> index has a pattern denoting a range of letters, such as "A-F", and matches a title if the first letter of the title is in the range. A <em>prefix</em> index matches any title that begins with the pattern. An <em>etc</em> index always matches a title.</p> <p>An index is a rule that matches the title of a lexicon article based on its <strong>index type</strong> and <strong>pattern</strong>. A <strong>char</strong> index matches a title if the first letter of the title (excluding "A", "An", and "The") is one of the letters in the pattern. A <strong>range</strong> index has a pattern denoting a range of letters, such as "A-F", and matches a title if the first letter of the title is in the range. A <strong>prefix</strong> index matches any title that begins with the pattern. An <strong>etc</strong> index always matches a title.</p>
<p>When a title is to be sorted under an index, indices are checked in order, sorted first by descending order of <em>logical priority</em>, and then by alphabetical order of index pattern. The title is sorted under the first index that matches it.</p> <p>When a title is to be sorted under an index, indices are checked in order, sorted first by descending order of <strong>logical priority</strong>, and then by alphabetical order of index pattern. The title is sorted under the first index that matches it.</p>
<p>On the contents page, indices and the articles under them are displayed sorted instead by <em>display order</em> and then alphabetically by pattern.</p> <p>On the contents page, indices and the articles under them are displayed sorted instead by <strong>display order</strong> and then alphabetically by pattern.</p>
<p>The <em>capacity</em> of an index is the number of articles that may exist under that index. If an index is at capacity, no new articles may be written or created via phantom citation in that index.</p> <p>The <strong>capacity</strong> of an index is the number of articles that may exist under that index. If an index is at capacity, no new articles may be written or created via phantom citation in that index.</p>
<p>To add an index, fill in the type and pattern in the blank row and save your changes. To remove an index, set the type to blank. Note: If you change the type or pattern of an index, all index assignments will be reset. Avoid changing index definitions during gameplay.</p> <p>To add an index, fill in the type and pattern in the blank row and save your changes. To remove an index, set the type to blank. Note: If you change the type or pattern of an index, all index assignments will be reset. Avoid changing index definitions during gameplay.</p>
</details> </details>
<form action="" method="post" novalidate> <form action="" method="post" novalidate>
@ -168,12 +169,112 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if page_name == "constraint" %}
<h3>Article Constraints</h3>
<details class="setting-help">
<summary>Article constraint help</summary>
<p>The article constraints configured here apply to all players. A constraint's configured value may be overridden on a turn-by-turn basis. On subsequent turns, the most recent overridden value will be used.</p>
<p><strong>Allow self citation</strong>: When this constraint is true, characters can cite extant articles they previously wrote and write phantom articles they previously cited. When this constraint is false, characters can do neither. Defaults to false.</p>
<p><strong>Allow new articles</strong>: When this constraint is true, characters can write articles in their assigned index that have not been cited before. When this constraint is false, characters can only write phantom articles. Defaults to true.</p>
{#
class Setting
settingtype
name
description
#}
</details>
{# <form action="" method="post" novalidate>
{{ form.hidden_tag() }}
<table id="index-definition-table2">
<tr>
<th>Turn</th>
<th>Index</th>
<th>Character</th>
</tr>
{% for rule_form in form.rules %}
<tr>
<td>{{ rule_form.turn() }}</td>
<td>{{ rule_form.index() }}</td>
<td>{{ rule_form.character() }}</td>
</tr>
{% for field in index_form %}
{% for error in field.errors %}
<tr>
<td colspan="5"><span style="color: #ff0000">{{ error }}</span></td>
</tr>
{% endfor %}
{% endfor %}
{% endfor %}
</table>
<p>{{ form.submit() }}</p>
</form> #}
{% for message in get_flashed_messages() %}
<span style="color:#ff0000">{{ message }}</span><br>
{% endfor %}
{% endif %}
{% if page_name == "publish" %} {% if page_name == "publish" %}
<h3>Turn Publishing</h3> <h3>Turn Publishing</h3>
{# <h3>Turn Publishing</h3>
<p>
{{ form.publishDeadlines(autocomplete="off") }}
{{ form.publishDeadlines.label }}<br>
{{ flag_setting(form.publishAsap) }}
{% for error in form.publishDeadlines.errors %}
<span style="color: #ff0000">{{ error }}</span><br>
{% endfor %}
{{ flag_setting(form.publishBlockOnReady) }}
{{ number_setting(form.publishQuorum) }}
<p>
{{ form.turnAssignment.label }}:<br>
{{ form.turnAssignment(class_="fullwidth", rows=10) }}
Transfer editorial control
</p> #}
{% endif %} {% endif %}
{% if page_name == "article" %} {% if page_name == "article" %}
<h3>Article Requirements</h3> <h3>Article Requirements</h3>
{# <h3>Article Requirements</h3>
<p>
{{ flag_setting(form.articleCitationAllowSelf) }}
{{ number_setting(form.articleCitationMinExtant)}}
{{ number_setting(form.articleCitationMaxExtant)}}
{{ number_setting(form.articleCitationMinPhantom)}}
{{ number_setting(form.articleCitationMaxPhantom)}}
{{ number_setting(form.articleCitationMinTotal)}}
{{ number_setting(form.articleCitationMaxTotal)}}
{{ number_setting(form.articleCitationMinChars)}}
{{ number_setting(form.articleCitationMaxChars)}}
{{ number_setting(form.articleWordLimitSoft)}}
{{ number_setting(form.articleWordLimitHard)}}
{{ flag_setting(form.articleAddendumAllowed) }}
{{ number_setting(form.articleAddendumMax) }}
</p> #}
{% endif %} {% endif %}
</section> </section>
{# <p>
Id: {{ g.lexicon.lid }}<br>
Name: {{ g.lexicon.cfg.name }}<br>
Created: {{ g.lexicon.cfg.time.created|asdate }}<br>
Completed: {{ g.lexicon.cfg.time.completed|asdate }}<br>
Players:
{% for uid in g.lexicon.cfg.join.joined %}
{{ uid|user_attr('username') }}{% if not loop.last %},{% endif %}
{% endfor %}<br>
Characters:
{% for char in g.lexicon.cfg.character.values() %}
{{ char.name }}{% if char.player %}
({{ char.player|user_attr('username') }}){% endif %}
{% if not loop.last %},{% endif %}
{% endfor %}<br>
allow addenda
allow posting
make system post
</p> #}
{% endblock %} {% endblock %}

View File

@ -0,0 +1,59 @@
from amanuensis.db import ArticleContentRuleType
class SettingDef:
def __init__(
self: "SettingDef",
setting_type: ArticleContentRuleType,
name: str,
help: str
):
self.setting_type = setting_type
self.name = name
self.help = help
class Settings:
allow_self_cite = SettingDef(
ArticleContentRuleType.ALLOW_SELF_CITE,
"Allow self citation",
"Characters can cite articles they previously wrote and write phantom articles they previously cited."
)
require_phantom
<p>The article constraints configured here apply to all players. A constraint's configured value may be overridden on a turn-by-turn basis. On subsequent turns, the most recent overridden value will be used.</p>
When this constraint is true, characters can cite extant articles they previously wrote and write phantom articles they previously cited. When this constraint is false, characters can do neither. Defaults to false.</p>
<p><strong>Allow new articles</strong>: When this constraint is true, characters can write articles in their assigned index that have not been cited before. When this constraint is false, characters can only write phantom articles. Defaults to true.</p>
# Whether characters can cite themselves
ALLOW_SELF_CITE = 0
# Whether characters can write new articles instead of phantoms
ALLOW_NEW_ARTICLE = 1
# Required number of extant articles cited
CITE_EXTANT_MIN = 2
CITE_EXTANT_MAX = 3
# Required number of phantom articles cited
CITE_PHANTOM_MIN = 4
CITE_PHANTOM_MAX = 5
# Required number of new articles cited
CITE_NEW_MIN = 6
CITE_NEW_MAX = 7
# Required number of characters among authors of articles cited
CITE_CHARS_MIN = 8
CITE_CHARS_MAX = 9
# Required number of citations of any kind
CITE_TOTAL_MIN = 10
CITE_TOTAL_MAX = 11
# Warn player below this wordcount
WORD_MIN_SOFT = 12
# Require player to exceed this wordcount
WORD_MIN_HARD = 13
# Warn player above this wordcount
WORD_MAX_SOFT = 14
# Require player to be under this wordcount
WORD_MAX_HARD = 15