paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 7e960941beb67cd4f2ec2d35712a13dde7830c64
parent fbd5fe84d597ea3a0618262abe1790d7e8312a9e
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Sat, 10 Aug 2019 00:56:13 -0400

Migrate Morrowind Character Generator to new site

Also add feed link to Recently Updated section on homepage.

Diffstat:
Mbuild/base.css | 43++++++++++++++++++++++++++++++++++++++++++-
Mpages/home.md | 10+++++++++-
Mpages/projects.md | 5+++++
Apages/projects/morrowind-character-roller.md | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apublic/js/generator.js | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 192 insertions(+), 2 deletions(-)

diff --git a/build/base.css b/build/base.css @@ -128,6 +128,19 @@ kbd { height: 85px; } +.rss-icon { + display: inline-block; + margin-left: 0.5em; +} + +.feed-candidate { + display: inline-block; +} + +.feed-wrapper { + height: 3em; +} + #downtime-banner { background-color: #b00; font-color: #fff; @@ -154,7 +167,7 @@ kbd { padding: 0 15% 0 15%; } -#content > p, #content > ul, #content > ol, #content > pre { +#content > p, #content > ul, #content > ol, #content > pre, #content>div { max-width: 60%; } @@ -318,6 +331,34 @@ kbd { /* End initative.html specific css */ /* =============================== */ +/* ================================================== */ +/* Begin morrowind-character-roller.html specific css */ +/* ================================================== */ + +#genButton { + margin: 0.5em 0 0 7.7em; + width: 16.5em; +} + +.fieldTitle { + font-weight: bold; + padding: 0 1em 0 0; + text-align: right; +} + +.charField { + color: #eee; + background-color: #5b5b5b; + border: 2px inset black; + padding: 0.1em; + width: 16em; + height: 1.5em; +} + +/* ================================================ */ +/* End morrowind-character-roller.html specific css */ +/* ================================================ */ + /* Ensure proper scaling with differently-sized displays */ @media all and (max-width: 900px) { #side-bar { diff --git a/pages/home.md b/pages/home.md @@ -13,7 +13,15 @@ things that I find interesting or think people should know more about. If you are interested and have the time, check out the stuff below. There may be something that interests you! -### Recently Updated +<div class="feed-wrapper"> + <h3 class="feed-candidate">Recently Updated:</h3> + <a class="rss-icon" href="/share/sitewide-feed.xml"> <img + src="/img/feed-icon.png" width="15px" height="15px" alt="RSS_ICON"></img> + </a> +</div> + +<a href="projects/morrowind-character-roller">New Project: Morrowind Character +Roller</a> <a href="guides/debian-with-btrfs">New Guide: Installing Debian 10 Buster with Encrypted LVM and btrfs Subvolumes</a> diff --git a/pages/projects.md b/pages/projects.md @@ -7,9 +7,14 @@ Below is a selection of links to my various projects and places where you can find them hosted. +Some of the projects below require Javascript to be enabled since they are small +tools/scripts meant to be run on the web page. A warning should pop up on those +pages if you do not have Javascript enabled. + <ul> <li><a href="https://git.sr.ht/~jbauer/">My Sourcehut (preferred git service)</a></li> <li><a href="https://github.com/JakeMBauer/">My GitHub</a></li> + <li><a href="projects/morrowind-character-roller">Morrowind Character Roller</a></li> <li class="sublist-header">Dungeons & Dragons <ul> <li><a href="projects/dnd/roll">D&D Simple Dice Roller</a></li> diff --git a/pages/projects/morrowind-character-roller.md b/pages/projects/morrowind-character-roller.md @@ -0,0 +1,57 @@ +## Morrowind Character Roller + +[//]: # "Generate a random scenario for role-playing a character in TES III: Morrowind. " + +[//]: # "base.min.css" + +<script type="text/javascript" src=/js/generator.js></script> +<noscript>Your browser must support or enable Javascript for this applet to +function.</noscript> + +Here is a small project of mine from when I was first learning Javascript. It +generates a random scenario for playing a character in the much-adored classic +RPG "The Elder Scrolls III: Morrowind" (which you can play on Linux using the +FOSS engine <a href="https://openmw.org/">OpenMW</a>). It chooses from a list of +factions, classes, hometowns, birthsigns, and races to generate a unique +scenario for when you want to play but are stuck on what your character should +do or who they should be. Also included is a link to a name generator. + +This project was inspired by Reddit user ihategoose's <a +href="https://old.reddit.com/r/Morrowind/comments/7l93rm/">Improved Morrowind +Random Character Roller</a>. + +<div id="mainDiv"> + <table id="fields"> + <tr> + <td class="fieldTitle">Name: </td> + <td> <a href="https://insane0hflex.github.io/TesNameGenerator/">Link + to Generate A Name</a></td> + </tr> + <tr> + <td class="fieldTitle">Faction 1: </td> + <td class="charField" id="factionField1"></td> + </tr> + <tr> + <td class="fieldTitle">Faction 2: </td> + <td class="charField" id="factionField2"></td> + </tr> + <tr> + <td class="fieldTitle">Class: </td> + <td class="charField" id="classField"></td> + </tr> + <tr> + <td class="fieldTitle">Hometown: </td> + <td class="charField" id="hometownField"></td> + </tr> + <tr> + <td class="fieldTitle">Birthsign: </td> + <td class="charField" id="birthsignField"></td> + </tr> + <tr> + <td class="fieldTitle">Race: </td> + <td class="charField" id="raceField"></td> + </tr> + </table> + <button id="genButton" type="button" onClick="charGen()">Generate New + Character</button> +</div> diff --git a/public/js/generator.js b/public/js/generator.js @@ -0,0 +1,79 @@ +/* +* generator.js +* Contains backend code for generation of game parameters +* +* This file is part of MorrowindGameGen +* Copyright (C) 2019 Jake Bauer +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + +function charGen() { + + const factions = ["Great House Redoran", "Great House Hlaalu", "Great \ + House Telvanni", "Vampire Clan Aundae", "Vampire Clan Berne", "Vampire \ + Clan Quarra", "Tribunal Temple", "Imperial Cult", "Sixth House or a Daedra \ + Cult", "Fighter's Guild", "Mage's Guild", "Thieves Guild", "Blades", + "Morag Tong", "Imperial Legion", "East Empire Company"]; + + const classes = ["Acrobat", "Agent", "Archer", "Assassin", "Barbarian", + "Bard", "Battlemage", "Crusader", "Healer", "Knight", "Mage", "Monk", + "Nightblade", "Pilgrim", "Rogue", "Scout", "Sorcerer", "Spellsword", + "Thief", "Warrior", "Witchhunter"]; + + const hometowns = ["Ald Velothi", "Ald'ruhn", "Balmora", "Caldera", + "Dagon Fel", "Ebonheart", "Gnisis", "Hla Oad", "Khuul", "Maar Gan", + "Molag Mar", "Mournhold", "Pelagiad", "Sadrith Mora", "Seyda Neen", + "Skaal Village", "Suran", "Tel Aruhn", "Tel Branora", "Tel Fyr", + "Tel Mora", "Vivec", "Vos"]; + + const birthsigns = ["Warrior", "Mage", "Thief", "Serpent", "Lady", "Steed", + "Lord", "Apprentice", "Atronach", "Ritual", "Lover", "Shadow", "Tower"]; + + const races = ["Altmer", "Argonian", "Bosmer", "Breton", "Dunmer", + "Imperial", "Khajiit", "Nord", "Orc", "Redguard"]; + + let firstFaction = Math.floor(Math.random() * factions.length); + document.getElementById("factionField1").innerHTML = factions[firstFaction]; + document.getElementById("factionField2").innerHTML = factions[secondFaction(firstFaction, factions)]; + document.getElementById("classField").innerHTML = classes[Math.floor(Math.random()*classes.length)]; + document.getElementById("hometownField").innerHTML = hometowns[Math.floor(Math.random()*hometowns.length)]; + document.getElementById("birthsignField").innerHTML = birthsigns[Math.floor(Math.random()*birthsigns.length)]; + document.getElementById("raceField").innerHTML = races[Math.floor(Math.random()*races.length)]; +} + +function secondFaction(firstFaction, factions){ + let result = firstFaction; + // If the player has already been assigned a great house, choose a non-great + // house faction instead (player cannot be a member of more than one). + if (firstFaction <= 2) + while (result <= 2) + result = Math.floor(Math.random()*factions.length); + // If player is a member of one of the vampire clans, choose another faction + // that isn't a vampire clan (player cannot be a member of more than one). + else if (firstFaction >= 3 && firstFaction <= 5) + while (result >= 3 && result <= 5) + result = Math.floor(Math.random()*factions.length); + // If a player is a member of one of the cults, choose another faction that + // isn't another cult (otherwise it wouldn't make sense roleplay-wise). + else if (firstFaction >= 6 && firstFaction <= 8) + while (result >= 6 && result <= 8) + result = Math.floor(Math.random()*factions.length); + // If none of the above conditions are true, choose any faction other than + // the one already chosen. + else + while (result === firstFaction) + result = Math.floor(Math.random()*factions.length); + return (result); +}