mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 20:25:51 +12:00
Implement "Read Books"
This commit is contained in:
parent
0b06cd1810
commit
6c42c57bfe
6 changed files with 243 additions and 1 deletions
55
Horse Isle Server/HorseIsleServer/Game/Book.cs
Normal file
55
Horse Isle Server/HorseIsleServer/Game/Book.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
public class Book
|
||||
{
|
||||
private static List<Book> libaryBooks = new List<Book>();
|
||||
public static Book[] LibaryBooks
|
||||
{
|
||||
get
|
||||
{
|
||||
return libaryBooks.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public int Id;
|
||||
public string Title;
|
||||
public string Author;
|
||||
public string Text;
|
||||
public Book(int id, string title, string author, string text)
|
||||
{
|
||||
Id = id;
|
||||
Title = title;
|
||||
Author = author;
|
||||
Text = text;
|
||||
libaryBooks.Add(this);
|
||||
}
|
||||
|
||||
public static bool BookExists(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetBookById(id);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static Book GetBookById(int id)
|
||||
{
|
||||
foreach(Book libaryBook in LibaryBooks)
|
||||
{
|
||||
if (libaryBook.Id == id)
|
||||
return libaryBook;
|
||||
}
|
||||
throw new KeyNotFoundException("no book with id: " + id.ToString() + " found.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -185,6 +185,11 @@ namespace HISP.Game
|
|||
public static string MaxJewelryMessage;
|
||||
public static string RemoveJewelry;
|
||||
|
||||
// Books (Libary)
|
||||
public static string BooksOfHorseIsle;
|
||||
public static string BookEntryFormat;
|
||||
public static string BookReadFormat;
|
||||
|
||||
// Awards (Libary)
|
||||
public static string AwardsAvalible;
|
||||
public static string AwardEntryFormat;
|
||||
|
@ -542,6 +547,15 @@ namespace HISP.Game
|
|||
|
||||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatBookReadMeta(string author, string title, string bookText)
|
||||
{
|
||||
return BookReadFormat.Replace("%AUTHOR%", author).Replace("%TITLE%", title).Replace("%TEXT%", bookText);
|
||||
}
|
||||
public static string FormatBookEntry(string title, string author, int id)
|
||||
{
|
||||
return BookEntryFormat.Replace("%TITLE%", title).Replace("%AUTHOR%", author).Replace("%ID%", id.ToString());
|
||||
}
|
||||
public static string FormatIpBannedMessage(string Ip)
|
||||
{
|
||||
return LoginFailedReasonBannedIpFormat.Replace("%IP%", Ip);
|
||||
|
|
|
@ -458,6 +458,26 @@ namespace HISP.Game
|
|||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildBookReadLibary(Book book)
|
||||
{
|
||||
string message = "";
|
||||
message = Messages.FormatBookReadMeta(book.Author, book.Title, book.Text);
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildBooksLibary()
|
||||
{
|
||||
string message = "";
|
||||
message += Messages.BooksOfHorseIsle;
|
||||
foreach(Book libaryBook in Book.LibaryBooks.OrderBy(o => o.Title).ToArray())
|
||||
{
|
||||
message += Messages.FormatBookEntry(libaryBook.Title, libaryBook.Author, libaryBook.Id);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildHorseReleased()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue