no message

This commit is contained in:
SilicaAndPina 2020-10-29 10:19:21 +13:00
parent 180708bb76
commit 5819441222
2 changed files with 124 additions and 0 deletions

View file

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Horse_Isle_Server
{
class Npc
{
public struct NpcReply
{
public int RandomId;
public int Id;
public string ReplyText;
public int GotoChatpoint;
public int RequiresQuestIdCompleted;
public int RequiresQuestIdNotCompleted;
}
public struct NpcChat
{
public int Id;
public string ChatText;
public int ActivateQuestId;
public NpcReply[] Replies;
}
public struct NpcEntry
{
public int Id;
public string Name;
public string AdminDescription;
public string ShortDescription;
public string LongDescription;
public bool Moves;
public int X;
public int Y;
public string StayOn;
public int RequiresQuestIdCompleted;
public int RequiresQuestIdNotCompleted;
public string UDLRScript;
public int UDLRStartX;
public int UDLRStartY;
public bool AdminOnly;
public bool LibarySearchable;
public int IconId;
public NpcChat[] Chatpoints;
}
public static List<NpcEntry> NpcList = new List<NpcEntry>();
public NpcReply GetNpcReply(NpcEntry npc, int randomid)
{
foreach (NpcChat chatpoint in npc.Chatpoints)
{
foreach (NpcReply reply in chatpoint.Replies)
{
if (reply.RandomId == randomid)
return reply;
}
}
throw new KeyNotFoundException("Npc reply with " + randomid + " not found!");
}
public static NpcReply GetNpcReply(NpcChat chatpoint, int randomid)
{
foreach(NpcReply reply in chatpoint.Replies)
{
if (reply.RandomId == randomid)
return reply;
}
throw new KeyNotFoundException("Npc reply with " + randomid + " not found!");
}
public static NpcEntry GetNpcById(int id)
{
foreach(NpcEntry npc in NpcList)
{
if (npc.Id == id)
return npc;
}
throw new KeyNotFoundException("Npc id: " + id + " not found!");
}
public static NpcEntry GetNpcByXAndY(int x, int y)
{
foreach(NpcEntry npc in NpcList)
{
if (npc.X == x && npc.Y == y)
return npc;
}
throw new KeyNotFoundException("Npc at X " + x + ", Y " + y + " not found!");
}
}
}

View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Horse_Isle_Server
{
class RandomID
{
private static int prevId = 0;
public static int NextRandomId(int randomId=-1)
{
int rndmId = 0;
if (randomId == -1)
rndmId = prevId+1;
else
rndmId = randomId;
if (rndmId >= prevId)
prevId = rndmId;
return rndmId;
}
}
}