mirror of
https://github.com/islehorse/HISP.git
synced 2025-06-03 12:27:09 +12:00
Add Feature pt1
This commit is contained in:
parent
a184e4d735
commit
092534e331
131 changed files with 3113 additions and 1418 deletions
168
HorseIsleServer/LibHISP/Game/SwfModules/Brickpoet.cs
Normal file
168
HorseIsleServer/LibHISP/Game/SwfModules/Brickpoet.cs
Normal file
|
@ -0,0 +1,168 @@
|
|||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace HISP.Game.SwfModules
|
||||
{
|
||||
public class Brickpoet
|
||||
{
|
||||
public struct PoetryEntry {
|
||||
public int Id;
|
||||
public string Word;
|
||||
public int Room;
|
||||
|
||||
}
|
||||
|
||||
public class PoetryPeice
|
||||
{
|
||||
public PoetryPeice(int PoetId, int RoomId, string PeiceWord)
|
||||
{
|
||||
if(!Database.GetPoetExist(PoetId, RoomId))
|
||||
{
|
||||
Id = PoetId;
|
||||
x = GameServer.RandomNumberGenerator.Next(0, 365);
|
||||
y = GameServer.RandomNumberGenerator.Next(0, 280);
|
||||
Word = PeiceWord;
|
||||
roomId = RoomId;
|
||||
Database.AddPoetWord(PoetId, x, y, RoomId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Id = PoetId;
|
||||
roomId = RoomId;
|
||||
Word = PeiceWord;
|
||||
x = Database.GetPoetPositionX(Id, roomId);
|
||||
y = Database.GetPoetPositionY(Id, roomId);
|
||||
}
|
||||
}
|
||||
public int Id;
|
||||
public int RoomId
|
||||
{
|
||||
get
|
||||
{
|
||||
return roomId;
|
||||
}
|
||||
}
|
||||
public int X
|
||||
{
|
||||
get
|
||||
{
|
||||
return x;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPoetPosition(Id, value, y, roomId);
|
||||
x = value;
|
||||
}
|
||||
|
||||
}
|
||||
public int Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return y;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPoetPosition(Id, x, value, roomId);
|
||||
y = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string Word;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
private int roomId;
|
||||
|
||||
}
|
||||
|
||||
private static List<PoetryEntry> poetList = new List<PoetryEntry>();
|
||||
private static List<PoetryPeice[]> poetryRooms = new List<PoetryPeice[]>();
|
||||
public static void AddPoetEntry(PoetryEntry poetEntry)
|
||||
{
|
||||
poetList.Add(poetEntry);
|
||||
}
|
||||
public static PoetryEntry[] PoetList
|
||||
{
|
||||
get
|
||||
{
|
||||
return poetList.ToArray();
|
||||
}
|
||||
}
|
||||
public static PoetryPeice[][] PoetryRooms
|
||||
{
|
||||
get
|
||||
{
|
||||
return poetryRooms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private static PoetryEntry[] getPoetsInRoom(int roomId)
|
||||
{
|
||||
List<PoetryEntry> entries = new List<PoetryEntry>();
|
||||
|
||||
foreach(PoetryEntry poet in PoetList)
|
||||
{
|
||||
if(poet.Room == roomId)
|
||||
{
|
||||
entries.Add(poet);
|
||||
}
|
||||
}
|
||||
|
||||
return entries.ToArray();
|
||||
}
|
||||
private static PoetryPeice[] getPoetryRoom(int roomId)
|
||||
{
|
||||
PoetryEntry[] poetryEntries = getPoetsInRoom(roomId);
|
||||
List<PoetryPeice> peices = new List<PoetryPeice>();
|
||||
foreach (PoetryEntry poetryEntry in poetryEntries)
|
||||
{
|
||||
PoetryPeice peice = new PoetryPeice(poetryEntry.Id, roomId, poetryEntry.Word);
|
||||
peices.Add(peice);
|
||||
}
|
||||
|
||||
return peices.ToArray();
|
||||
}
|
||||
|
||||
public static PoetryPeice[] GetPoetryRoom(int roomId)
|
||||
{
|
||||
foreach(PoetryPeice[] peices in PoetryRooms)
|
||||
{
|
||||
if (peices[0].RoomId == roomId)
|
||||
return peices;
|
||||
}
|
||||
throw new KeyNotFoundException("No poetry room of id: " + roomId + " exists.");
|
||||
}
|
||||
public static PoetryPeice GetPoetryPeice(PoetryPeice[] room, int id)
|
||||
{
|
||||
foreach(PoetryPeice peice in room)
|
||||
{
|
||||
if (peice.Id == id)
|
||||
return peice;
|
||||
}
|
||||
throw new KeyNotFoundException("Peice with id: " + id + " not found in room.");
|
||||
}
|
||||
public static void LoadPoetryRooms()
|
||||
{
|
||||
List<int> rooms = new List<int>();
|
||||
foreach(PoetryEntry entry in PoetList)
|
||||
{
|
||||
if (!rooms.Contains(entry.Room))
|
||||
rooms.Add(entry.Room);
|
||||
}
|
||||
|
||||
foreach(int room in rooms)
|
||||
{
|
||||
Logger.InfoPrint("Loading poetry room: " + room.ToString());
|
||||
poetryRooms.Add(getPoetryRoom(room));
|
||||
if (!Database.LastPlayerExist("P" + room))
|
||||
Database.AddLastPlayer("P" + room, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
84
HorseIsleServer/LibHISP/Game/SwfModules/Drawingroom.cs
Normal file
84
HorseIsleServer/LibHISP/Game/SwfModules/Drawingroom.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.SwfModules
|
||||
{
|
||||
class Drawingroom
|
||||
{
|
||||
private static List<Drawingroom> drawingRooms = new List<Drawingroom>();
|
||||
public static Drawingroom[] DrawingRooms
|
||||
{
|
||||
get
|
||||
{
|
||||
return drawingRooms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private string drawing;
|
||||
public string Drawing
|
||||
{
|
||||
get
|
||||
{
|
||||
return drawing;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value.Length < 65535)
|
||||
{
|
||||
Database.SetDrawingRoomDrawing(Id, value);
|
||||
drawing = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new DrawingroomFullException();
|
||||
}
|
||||
}
|
||||
}
|
||||
public int Id;
|
||||
public Drawingroom(int roomId)
|
||||
{
|
||||
|
||||
if (!Database.DrawingRoomExists(roomId))
|
||||
{
|
||||
Database.CreateDrawingRoom(roomId);
|
||||
Database.SetLastPlayer("D" + roomId.ToString(), -1);
|
||||
}
|
||||
|
||||
drawing = Database.GetDrawingRoomDrawing(roomId);
|
||||
Id = roomId;
|
||||
|
||||
drawingRooms.Add(this);
|
||||
}
|
||||
public static void LoadAllDrawingRooms()
|
||||
{
|
||||
// iterate over every special tile
|
||||
foreach(World.SpecialTile tile in World.SpecialTiles)
|
||||
{
|
||||
if(tile.Code != null)
|
||||
{
|
||||
if (tile.Code.StartsWith("MULTIROOM-D"))
|
||||
{
|
||||
int roomId = int.Parse(tile.Code.Substring(11));
|
||||
Logger.InfoPrint("Loading Drawing Room ID: " + roomId.ToString());
|
||||
Drawingroom room = new Drawingroom(roomId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static Drawingroom GetDrawingRoomById(int id)
|
||||
{
|
||||
foreach(Drawingroom room in DrawingRooms)
|
||||
{
|
||||
if (room.Id == id)
|
||||
return room;
|
||||
}
|
||||
throw new KeyNotFoundException("Room with id: " + id + " not found.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
129
HorseIsleServer/LibHISP/Game/SwfModules/Dressup.cs
Normal file
129
HorseIsleServer/LibHISP/Game/SwfModules/Dressup.cs
Normal file
|
@ -0,0 +1,129 @@
|
|||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game.SwfModules
|
||||
{
|
||||
public class Dressup
|
||||
{
|
||||
|
||||
private static List<DressupRoom> dressupRooms = new List<DressupRoom>();
|
||||
public static DressupRoom[] DressupRooms
|
||||
{
|
||||
get
|
||||
{
|
||||
return dressupRooms.ToArray();
|
||||
}
|
||||
}
|
||||
public class DressupRoom
|
||||
{
|
||||
public int RoomId;
|
||||
private List<DressupPeice> dressupPeices;
|
||||
public DressupPeice[] DressupPeices
|
||||
{
|
||||
get
|
||||
{
|
||||
return dressupPeices.ToArray();
|
||||
}
|
||||
}
|
||||
public DressupRoom(int roomId)
|
||||
{
|
||||
RoomId = roomId;
|
||||
dressupPeices = new List<DressupPeice>();
|
||||
|
||||
DressupPeice[] peices = Database.LoadDressupRoom(this);
|
||||
foreach (DressupPeice peice in peices)
|
||||
dressupPeices.Add(peice);
|
||||
|
||||
dressupRooms.Add(this);
|
||||
}
|
||||
|
||||
public DressupPeice GetDressupPeice(int peiceId)
|
||||
{
|
||||
foreach(DressupPeice peice in DressupPeices)
|
||||
{
|
||||
if (peice.PeiceId == peiceId)
|
||||
return peice;
|
||||
}
|
||||
// Else create peice
|
||||
DressupPeice dPeice = new DressupPeice(this, peiceId, 0, 0, false, true);
|
||||
dressupPeices.Add(dPeice);
|
||||
return dPeice;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class DressupPeice
|
||||
{
|
||||
public DressupPeice(DressupRoom room,int peiceId, int x, int y, bool active, bool createNew)
|
||||
{
|
||||
this.baseRoom = room;
|
||||
this.PeiceId = peiceId;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.active = active;
|
||||
|
||||
|
||||
if (createNew)
|
||||
Database.CreateDressupRoomPeice(room.RoomId, peiceId, active, x, y);
|
||||
|
||||
}
|
||||
public DressupRoom baseRoom;
|
||||
public int PeiceId;
|
||||
public int X
|
||||
{
|
||||
get
|
||||
{
|
||||
return x;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetDressupRoomPeiceX(baseRoom.RoomId, PeiceId, value);
|
||||
x = value;
|
||||
}
|
||||
}
|
||||
public int Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return y;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetDressupRoomPeiceY(baseRoom.RoomId, PeiceId, value);
|
||||
y = value;
|
||||
}
|
||||
}
|
||||
public bool Active
|
||||
{
|
||||
get
|
||||
{
|
||||
return active;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetDressupRoomPeiceActive(baseRoom.RoomId, PeiceId, value);
|
||||
active = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private bool active;
|
||||
|
||||
}
|
||||
|
||||
public static DressupRoom GetDressupRoom(int roomId)
|
||||
{
|
||||
foreach(DressupRoom sRoom in DressupRooms)
|
||||
{
|
||||
if (sRoom.RoomId == roomId)
|
||||
return sRoom;
|
||||
}
|
||||
|
||||
// Else create room
|
||||
|
||||
DressupRoom room = new DressupRoom(roomId);
|
||||
return room;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue