Skip to content

Commit

Permalink
Release v0.4.0
Browse files Browse the repository at this point in the history
Merge pull request #16 from TehGM/dev
  • Loading branch information
TehGM authored Oct 15, 2024
2 parents 9bed798 + 15cd8fb commit a6ce3cf
Show file tree
Hide file tree
Showing 27 changed files with 624 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>TehGM.Randominator.SitemapRenderer</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 21 additions & 3 deletions Randominator/Features/Player/PlayerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ public class PlayerOptions
"fCxrkkFv1qw", // r33mix rainbow
"FJITHvAmS_Y", // BPM level 5
"LXIWRan3XGY", // type o negative - I don't wanna be me
"gi1CASWEkt4", // drg leave no dwarf behind
"WBuDIqpBB7A", // the final catdown
"NUYvbT6vTPs", // Cat Vibing To Ievan Polkka
"TUxYTdlcUMw", // cat vibing to aaaaahhhh
Expand Down Expand Up @@ -261,7 +260,6 @@ public class PlayerOptions
"p0rXznBDfJM", // monkey driving golf cart, GTASA music, 10h
"isYt-BWrQfk", // apple cat running 1h
"oe6b5tMMw1k", // cat with headphones 10h
"bhsgn1v79as", // phonk trollge 1h
"XaO_3GcQyiE", // plague doctor dance
"DrxdjxXXZug", // burning memory but depressing 1h
"rmHDhAohJlQ", // the prodigy - breathe
Expand All @@ -273,7 +271,6 @@ public class PlayerOptions
"o8hYrNsRoTs", // karen metal
"rCSkWIdTONA", // karen metal 2
"tnLLrnZVwFI", // karen metal 4
"E5nsRs1e_q0", // our table it's broken
"c7BVtGnlxT8", // why do I hear boss music original
"V58fBGcbaCs", // meet my son hecker jr
"jYO503VGd6k", // 5 inches deep in your mum
Expand Down Expand Up @@ -433,6 +430,27 @@ public class PlayerOptions
"69Hitt9Dw4Y", // discord cats - hecker finds beluga's password
"OhvCJGRBX1A", // discord cats - pablo vs flat earther
"TovdjYooStg", // discord cats - beluga gets unmodded
"etK-4BzIGQc", // cat vibing to lobotomy corp
"1a6igLUYYCI", // welcome to eft
"w376YBdKAGE", // camau - teaching girlfriend to camp
"QhmR7hPbNnY", // camau - disguising as a scav
"wCRftfx62uY", // boi what - neon tide
"KinnMF7uwQs", // alex terrible - livin la vida loca
"eDQ4dUQegqw", // big enough trombone champ
"U1yN3imHxKI", // don't shoot i'm eating chipotle

// replacements - see old ones below
"JvgcVg1NaXk", // phonk trollge 10h
"0rAdDjlH3u4", // drg leave no dwarf behind

/***
* Expired videos
* They are no longer embeddable for whatever reason.
* Keeping them here just for future reference. Maybe they'll come back or something.
***/
//"bhsgn1v79as", // phonk trollge 1h
//"gi1CASWEkt4", // drg leave no dwarf behind
//"E5nsRs1e_q0", // our table it's broken
};
}
}
2 changes: 1 addition & 1 deletion Randominator/Features/Player/PlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public string BuildYoutubeURL(string videoID)
{ "autoplay", true },
{ "loop", true },
{ "modestbranding", true },
{ "disablekb", this._options.EnableControls },
{ "disablekb", !this._options.EnableControls },
{ "playsinline", true },
{ "rel", false },
{ "fs", false }, // fullscreen
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using TehGM.Randominator.Generators.BookTitle;
using TehGM.Randominator.Generators.BookTitle.Services;

namespace Microsoft.Extensions.DependencyInjection
{
public static class BookTitleDependencyInjectionExtensions
{
public static IServiceCollection AddBookTitleGenerator(this IServiceCollection services, Action<BookTitleOptions> configureOptions = null)
{
if (configureOptions != null)
services.Configure(configureOptions);

services.AddRandomizer();
services.AddTransient<IBookTitleGenerator, BookTitleGenerator>();

return services;
}
}
}
57 changes: 57 additions & 0 deletions Randominator/Generators/BookTitle/BookTitleGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
namespace TehGM.Randominator.Generators.BookTitle.Services
{
public class BookTitleGenerator : IBookTitleGenerator
{
private readonly IOptionsMonitor<BookTitleOptions> _options;
private readonly IRandomizer _random;
private readonly ILogger _log;

public BookTitleGenerator(IOptionsMonitor<BookTitleOptions> options, ILogger<BookTitleGenerator> log, IRandomizer randomizer)
{
this._options = options;
this._random = randomizer;
this._log = log;
}

public string Generate()
{
BookTitleOptions options = this._options.CurrentValue;
ICollection<string> segments = new List<string>(3);
//pick if it's A or An for the first word
bool useAWordSet = _random.RollChance(0.5); // 50% chance to pick either list

string article = useAWordSet ? "A" : "An";
string word1 = useAWordSet
? this._random.GetRandomValue(options.AWordSet)
: this._random.GetRandomValue(options.AnWordSet);

//Second or third word
string word2 = this._random.GetRandomValue(options.SecondThirdWordSet);
string word3 = this._random.GetRandomValue(options.SecondThirdWordSet);

//we probably don't want it to be the same one twice
while (word2 == word3)
word3 = this._random.GetRandomValue(options.SecondThirdWordSet);
// combine it
segments.Add($"{article} {this.CapitalizeSegment(word1)} of {this.CapitalizeSegment(word2)} and {this.CapitalizeSegment(word3)}");
return string.Join(' ', segments);
}




private string CapitalizeSegment(string value)
{
string[] segmentParts = value.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < segmentParts.Length; i++)
{
if (string.IsNullOrWhiteSpace(segmentParts[i]))
continue;
char[] wordChars = segmentParts[i].ToLowerInvariant().ToCharArray();
wordChars[0] = char.ToUpperInvariant(wordChars[0]);
segmentParts[i] = new string(wordChars);
}
return string.Join(' ', segmentParts);
}
}
}
43 changes: 43 additions & 0 deletions Randominator/Generators/BookTitle/BookTitleOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace TehGM.Randominator.Generators.BookTitle
{
public class BookTitleOptions
{
// List of words that follow "A"
public ICollection<string> AWordSet { get; set; } = new string[]
{
"Song", "Court", "Dream", "Whisper", "Memory", "Battle",
"Shadow", "Curse", "Vision", "Blade", "King", "Story",
"Legend", "Quest", "Kingdom", "Echo", "Fable", "Journey",
"Saga", "Chronicle", "Hero", "Tale", "Legacy", "Prophecy",
"Night", "Dawn", "Frost", "Glimmer", "Light", "Wanderer",
"Bard", "Oath", "Dancer", "Heroine", "Beast", "Mystic",
"Ballad", "House", "Child", "Queen", "Wraith", "Reaper",
"Spark", "World", "Planet", "Plane", "Place", "Space"
};

// List of words that follow "An"
public ICollection<string> AnWordSet { get; set; } = new string[]
{
"Echo", "Honor", "Empire", "Oath", "Adventure", "Allegory",
"Invitation", "Eclipse", "Epic", "Artifact",
"Oracle", "Endeavor", "Era", "Idyll", "Insight", "Infinity",
"Anomaly", "Ambush", "Artifice", "Alliance", "Awakening",
"Atmosphere", "Anthem", "Enigma", "Enlightenment", "Elysium",
"Asylum", "Earth",
};

// Shared word set for the second and third parts of the title
public ICollection<string> SecondThirdWordSet { get; set; } = new string[]
{
"Fire", "Ice", "Thorns", "Roses", "Dreams", "Storms",
"Shadows", "Seas", "Stars", "Chains", "Tides", "Sands",
"Winds", "Bones", "Mysteries", "Legends", "Whispers", "Secrets",
"Embers", "Echoes", "Visions", "Fires", "Legacies", "Fables",
"Fury", "Hopes", "Dusk", "Dawn", "Desires", "Frost",
"Sorrow", "Nights", "Dangers", "Wonders", "Myths",
"Havens", "Hues", "Pathways", "Fates", "Mirrors",
"Blood", "Light", "Tempests", "Voices", "Vices",
"Mirages", "Tales"
};
}
}
7 changes: 7 additions & 0 deletions Randominator/Generators/BookTitle/IBookTitleGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace TehGM.Randominator.Generators.BookTitle
{
public interface IBookTitleGenerator
{
string Generate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public string Apply(string beforeBrackets, string withinBrackets, BracketsStyle
else if (style == BracketsStyle.Clean || style == BracketsStyle.JavaScript)
{
builder.AppendLine();
builder.Append("}");
builder.Append('}');
}

return builder.ToString();
Expand Down
2 changes: 1 addition & 1 deletion Randominator/Generators/UniqueID/UniqueIdGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public UniqueIdValue Generate()
Guid value = Guid.NewGuid();
UniqueIdValue result = new UniqueIdValue(value);
this._log.LogDebug("Generated Unique ID: {ID}", value);
return new UniqueIdValue(value);
return result;
}
}
}
11 changes: 7 additions & 4 deletions Randominator/Generators/UniqueID/UniqueIdValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ public UniqueIdValue(Guid value)
this.HashCodeValue = this.Value.GetHashCode();
this.NumberValue = new BigInteger(bytes);
using (SHA1 sha1 = SHA1.Create())
this.SHA1Value = string.Concat(sha1.ComputeHash(bytes).Select(x => x.ToString("X2")));
this.SHA1Value = Compute(sha1);
using (SHA256 sha256 = SHA256.Create())
this.SHA256Value = string.Concat(sha256.ComputeHash(bytes).Select(x => x.ToString("X2")));
this.SHA256Value = Compute(sha256);
using (SHA384 sha384 = SHA384.Create())
this.SHA384Value = string.Concat(sha384.ComputeHash(bytes).Select(x => x.ToString("X2")));
this.SHA384Value = Compute(sha384);
using (SHA512 sha512 = SHA512.Create())
this.SHA512Value = string.Concat(sha512.ComputeHash(bytes).Select(x => x.ToString("X2")));
this.SHA512Value = Compute(sha512);
this.Base64Value = Convert.ToBase64String(bytes);

string Compute(HashAlgorithm algo)
=> string.Concat(algo.ComputeHash(bytes).Select(x => x.ToString("X2")));
}
}
}
8 changes: 6 additions & 2 deletions Randominator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using TehGM.Randominator.Generators.Dare;
using TehGM.Randominator.Generators.MobileGameName;
using TehGM.Randominator.Generators.ProgrammingStandards;
using TehGM.Randominator.Generators.BookTitle;
using Serilog.Settings.Configuration;

namespace TehGM.Randominator;

Expand Down Expand Up @@ -64,6 +66,7 @@ private static void ConfigureOptions(IServiceCollection services, IConfiguration
services.Configure<DareGeneratorOptions>(configuration.GetSection("Generators:Dare"));
services.Configure<MobileGameNameOptions>(configuration.GetSection("Generators:MobileGameName"));
services.Configure<ProgrammingStandardsOptions>(configuration.GetSection("Generators:ProgrammingStandards"));
services.Configure<BookTitleOptions>(configuration.GetSection("Generators:BookTitle"));
}

private static void ConfigureServices(IServiceCollection services, string baseAddress, IConfiguration configuration)
Expand All @@ -72,6 +75,7 @@ private static void ConfigureServices(IServiceCollection services, string baseAd
ConfigureOptions(services, configuration);

// utilities
services.AddUserSettings();
services.AddRandomizer();
services.AddClipboard();
services.AddGeneratorMemory();
Expand All @@ -82,7 +86,7 @@ private static void ConfigureServices(IServiceCollection services, string baseAd
services.AddProgrammingStandardsGenerator();
services.AddUniqueIdGenerator();
services.AddDareGenerator();

services.AddBookTitleGenerator();
// features
services.AddPlayer();
}
Expand All @@ -92,7 +96,7 @@ private static void ConfigureLogging(WebAssemblyHostBuilder builder)
Serilog.Debugging.SelfLog.Enable(m => Console.Error.WriteLine(m));

Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration, "Logging")
.ReadFrom.Configuration(builder.Configuration, new ConfigurationReaderOptions() { SectionName = "Logging" })
.CreateLogger();

builder.Logging.ClearProviders();
Expand Down
23 changes: 13 additions & 10 deletions Randominator/Randominator.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>TehGM.Randominator</RootNamespace>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<Version>0.3.1</Version>
<Version>0.4.0</Version>
<Authors>TehGM</Authors>
<Description>A Blazor website containing a random collection of generators (generating random or non-random stuff).</Description>
<Company>TehGM</Company>
Expand Down Expand Up @@ -64,14 +64,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BlazorWasmPreRendering.Build" Version="1.0.0-preview.22.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.2.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Serilog.Sinks.BrowserConsole" Version="1.0.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.10" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.BrowserConsole" Version="8.0.0" />
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
Expand Down
46 changes: 46 additions & 0 deletions Randominator/UI/Components/Inputs/OnOffToggle.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<div class="form-group input-group @this.CssClass">
@if (!string.IsNullOrEmpty(this.Label))
{
<FormInputPrepend CssClass="@this.LabelCssClass">@this.Label</FormInputPrepend>
}

<input id="@this.ID" type="checkbox" class="btn-check" autocomplete="off" value="@this.Value" checked="@this.Value" @onchange="this.OnClickAsync" disabled="@this.Disabled" />
<label class="btn @this.ToggleCssClass @this.CurrentToggleCssClass" for="@this.ID">@this.CurrentToggleText</label>
</div>

@code {
[Parameter]
public Guid ID { get; set; } = Guid.NewGuid();
[Parameter]
public bool Disabled { get; set; }
[Parameter]
public string CssClass { get; set; }
[Parameter]
public string LabelCssClass { get; set; }
[Parameter]
public string ToggleCssClass { get; set; }
[Parameter]
public string Label { get; set; }
[Parameter]
public string OnText { get; set; } = "On";
[Parameter]
public string OffText { get; set; } = "Off";
[Parameter]
public string OnCssClass { get; set; } = "btn-success";
[Parameter]
public string OffCssClass { get; set; } = "btn-danger";

private string CurrentToggleText => this.Value ? this.OnText : this.OffText;
private string CurrentToggleCssClass => this.Value ? this.OnCssClass : this.OffCssClass;

[Parameter]
public bool Value { get; set; }
[Parameter]
public EventCallback<bool> ValueChanged { get; set; }

private Task OnClickAsync()
{
this.Value = !this.Value;
return ValueChanged.InvokeAsync(this.Value);
}
}
Loading

0 comments on commit a6ce3cf

Please sign in to comment.