Skip to content

Commit

Permalink
feat: Add skin tone generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
Starciad committed Jan 24, 2024
1 parent 27add98 commit 92aca4c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
18 changes: 11 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

<!-- Collections -->
<script src="scripts/collections/names/EUANamesCollection.js" type="module"></script>
<script src="scripts/collections/OccupationsCollection.js" type="module"></script>
<script src="scripts/collections/CountriesCollection.js" type="module"></script>
<script src="scripts/collections/CivilStatusCollection.js" type="module"></script>
<script src="scripts/collections/BloodTypeCollection.js" type="module"></script>
<script src="scripts/collections/HeightCollection.js" type="module"></script>
<script src="scripts/collections/WeightCollection.js" type="module"></script>

<script src="scripts/collections/general/OccupationsCollection.js" type="module"></script>
<script src="scripts/collections/general/CountriesCollection.js" type="module"></script>
<script src="scripts/collections/general/CivilStatusCollection.js" type="module"></script>

<script src="scripts/collections/physical/BloodTypeCollection.js" type="module"></script>
<script src="scripts/collections/physical/HeightCollection.js" type="module"></script>
<script src="scripts/collections/physical/WeightCollection.js" type="module"></script>

<script src="scripts/collections/appearance/SkinToneCollection.js" type="module"></script>

<!-- Core -->
<script src="scripts/main.js" type="module" defer></script>
Expand Down Expand Up @@ -219,7 +223,7 @@ <h2 align="center">Spark your imagination by creating unique characters</h2>
<tbody>
<tr>
<td>Skin Tone</td>
<td id="cs-appearence-skin-tone">Empty</td>
<td id="cs-appearance-skin-tone">Empty</td>
</tr>
</tbody>
</table>
Expand Down
16 changes: 16 additions & 0 deletions scripts/collections/appearance/SkinToneCollection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { random } from "../../math/random.js";

export const SkinToneCollection = Object.freeze({
skinTones: [
"Light",
"Fair",
"Medium",
"Olive",
"Tan",
"Black"
],

getRandomSkinTone: function () {
return random.getRandomArrayElement(this.skinTones);
},
});
15 changes: 14 additions & 1 deletion scripts/core/dataGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { OccupationsCollection } from "../collections/general/OccupationsCollect
import { WeightCollection } from "../collections/physical/WeightCollection.js";
import { random } from "../math/random.js";
import { updateCharacterSheetTable } from "./pageUpdater.js";
import { SkinToneCollection } from "../collections/appearance/SkinToneCollection.js";

export function SCSGenerator(nameStyleType, sexType, ageRangeType) {
// General
Expand All @@ -25,6 +26,9 @@ export function SCSGenerator(nameStyleType, sexType, ageRangeType) {
let char_blood_type = getRandomBloodType();
let char_rh_factor = getRandomRhFactor();

// Appearance
let char_appearance_skin_tone = getRandomSkinTone();

updateCharacterSheetTable({
// General
firstName: char_fullname.firstName,
Expand All @@ -41,7 +45,10 @@ export function SCSGenerator(nameStyleType, sexType, ageRangeType) {
height: char_height,
weight: char_weight,
bloodType: char_blood_type,
rhFactor: char_rh_factor
rhFactor: char_rh_factor,

// Appearance
skinTone: char_appearance_skin_tone,
});
}

Expand Down Expand Up @@ -154,4 +161,10 @@ function getRandomBloodType() {
function getRandomRhFactor() {
return BloodTypeCollection.getRandomRhFactor();
}
//#endregion

//#region Appearance
function getRandomSkinTone() {
return SkinToneCollection.getRandomSkinTone();
}
//#endregion
4 changes: 4 additions & 0 deletions scripts/core/pageUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export function updateCharacterSheetTable(characterInfos) {
document.querySelector("#cs-physical-height").innerHTML = characterInfos.height;
document.querySelector("#cs-physical-weight").innerHTML = characterInfos.weight;
document.querySelector("#cs-physical-blood-type").innerHTML = characterInfos.bloodType + characterInfos.rhFactor;

// Appearance
document.querySelector("#cs-appearance-skin-tone").innerHTML = characterInfos.skinTone;

}

function getFormattedDate(date) {
Expand Down

0 comments on commit 92aca4c

Please sign in to comment.