-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
175 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
Check failure on line 1 in Sanara/Database/SqliteContext.cs GitHub Actions / build
|
||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Sanara.Database; | ||
|
||
public class SqliteContext : DbContext | ||
Check failure on line 6 in Sanara/Database/SqliteContext.cs GitHub Actions / build
|
||
{ | ||
protected override void OnConfiguring(DbContextOptionsBuilder options) | ||
Check failure on line 8 in Sanara/Database/SqliteContext.cs GitHub Actions / build
|
||
=> options.UseSqlite("Data Source=Sqlite.db"); | ||
} | ||
|
||
public class ServerContext | ||
{ | ||
[Key] public ulong Id { set; get; } = 0; | ||
|
||
public bool TranslateUsingFlags { set; get; } = false; | ||
public Dictionary<int, ulong> Subscriptions { set; get; } = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace Sanara.Game; | ||
|
||
public abstract class AGame | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Sanara.Game; | ||
|
||
public struct GameSettings | ||
{ | ||
public GameSettings(Lobby lobby) | ||
{ | ||
Lobby = lobby; | ||
} | ||
|
||
public Lobby Lobby { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using Discord; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Sanara.Command.SlashCommand.Converter; | ||
using Sanara.Command.SlashCommand.Impl; | ||
using Sanara.Game.Preload; | ||
using Sanara.Game.Result; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Sanara.Game.Impl; | ||
|
||
public class ShiritoriPreload : IPreload | ||
{ | ||
public string Name => "Shiritori"; | ||
|
||
public bool IsSafe => true; | ||
|
||
public AGame CreateGame(IMessageChannel msgchan, IUser user, GameSettings settings) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string Rules | ||
=> "Shiritori is a Japanese game where you must find a word starting by the last syllable of the previous one.\n" + | ||
"Words must be noun, must not end by a ん(n), must not have been already said and must be more than one syllabe.\n" + | ||
"For example if someone say りゅう (ryuu, dragon) you have to say a word starting by う (u), like うさぎ (usagi, rabbit).\n" + | ||
"First player must start by saying しりとり (shiritori)"; | ||
|
||
public void Init(IServiceProvider provider) | ||
{ | ||
var http = provider.GetRequiredService<HttpClient>(); | ||
var converter = provider.GetRequiredService<JapaneseConverter>(); | ||
if (!File.Exists("Saves/Game/ShiritoriJapanese.txt")) | ||
File.WriteAllBytes("Saves/Game/ShiritoriJapanese.txt", http.GetByteArrayAsync("https://files.zirk.eu/Sanara/ShiritoriJapanese.txt").GetAwaiter().GetResult()); | ||
string[] lines = File.ReadAllLines("Saves/Game/ShiritoriJapanese.txt"); | ||
_words = []; | ||
foreach (var l in lines) | ||
{ | ||
string[] curr = l.Split('$'); | ||
string word = curr[0]; | ||
_words.Add(new ShiritoriPreloadResult(word, converter.ToRomaji(word), curr[1])); | ||
} | ||
for (int i = 5; i >= 1; i--) | ||
{ | ||
if (!File.Exists($"Saves/Game/Jlpt{i}Vocabulary.txt")) | ||
File.WriteAllBytes($"Saves/Game/Jlpt{i}Vocabulary.txt", http.GetByteArrayAsync("https://files.zirk.eu/Sanara/Jlpt" + i + "Vocabulary.txt").GetAwaiter().GetResult()); | ||
string[] jlptLines = File.ReadAllLines($"Saves/Game/Jlpt{i}Vocabulary.txt"); | ||
foreach (var l in jlptLines) | ||
{ | ||
string[] curr = l.Split('$'); | ||
string word = curr[0]; | ||
var value = _words.Find(x => x.Word == word); | ||
if (value == null) | ||
{ | ||
value = new ShiritoriPreloadResult(word, converter.ToRomaji(word), curr[1]); | ||
_words.Add(value); | ||
} | ||
value.LearningLevels.Add(i); | ||
} | ||
} | ||
_words = _words.Where(x => !x.Word.EndsWith("ん") && x.Word.Length > 1).ToList(); | ||
} | ||
|
||
public IEnumerable<IPreloadResult> Load() | ||
{ | ||
return _words; | ||
} | ||
|
||
private List<ShiritoriPreloadResult> _words; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace Sanara.Game; | ||
|
||
public class Lobby | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Discord; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Sanara.Game.Preload; | ||
|
||
public interface IPreload | ||
{ | ||
public void Init(IServiceProvider provider); | ||
/// <summary> | ||
/// Load the game dictionary | ||
/// </summary> | ||
public IEnumerable<IPreloadResult> Load(); | ||
public string Name { get; } | ||
/// <summary> | ||
/// Create a new instance of a game and return it | ||
/// </summary> | ||
public AGame CreateGame(IMessageChannel msgchan, IUser user, GameSettings settings); | ||
/// <summary> | ||
/// Returns the game rules | ||
/// </summary> | ||
public string Rules { get; } | ||
/// <summary> | ||
/// Can the game be played in SFW channels | ||
/// </summary> | ||
public bool IsSafe { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace Sanara.Game.Preload; | ||
|
||
public interface IPreloadResult | ||
{ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Sanara.Game.Preload; | ||
|
||
namespace Sanara.Game.Result; | ||
|
||
public class ShiritoriPreloadResult : IPreloadResult | ||
{ | ||
public ShiritoriPreloadResult(string word, string wordEnglish, string meanings) | ||
{ | ||
Word = word; | ||
WordEnglish = wordEnglish; | ||
Meanings = meanings; | ||
LearningLevels = new(); | ||
} | ||
|
||
/// <summary> | ||
/// Word in the local language | ||
/// </summary> | ||
public string Word { get; } | ||
/// <summary> | ||
/// Word in latin alphabet (ex: romaji for japanese) | ||
/// </summary> | ||
public string WordEnglish { get; } | ||
/// <summary> | ||
/// What the word mean | ||
/// </summary> | ||
public string Meanings { get; } | ||
/// <summary> | ||
/// JLPT levels | ||
/// </summary> | ||
public List<int> LearningLevels { get; } | ||
} |