Exemplo n.º 1
0
        public static KettlePayload From(IPowerHistoryEntry entry)
        {
            switch (entry.PowerType)
            {
            case PowerType.CREATE_GAME:
                return(new KettleHistoryCreateGame((PowerHistoryCreateGame)entry));

            case PowerType.FULL_ENTITY:
                return(new KettleHistoryFullEntity((PowerHistoryFullEntity)entry));

            case PowerType.SHOW_ENTITY:
                return(new KettleHistoryShowEntity((PowerHistoryShowEntity)entry));

            case PowerType.HIDE_ENTITY:
                return(new KettleHistoryHideEntity((PowerHistoryHideEntity)entry));

            case PowerType.TAG_CHANGE:
                return(new KettleHistoryTagChange((PowerHistoryTagChange)entry));

            case PowerType.BLOCK_START:
                return(new KettleHistoryBlockBegin((PowerHistoryBlockStart)entry));

            case PowerType.BLOCK_END:
                return(new KettleHistoryBlockEnd((PowerHistoryBlockEnd)entry));

            default:
                Console.WriteLine("Error, unhandled powertype " + entry.PowerType.ToString());
                return(null);
            }
        }
        public static string Serialize(IPowerHistoryEntry historyEntry)
        {
            switch (historyEntry.PowerType)
            {
            case PowerType.FULL_ENTITY:
                return(JsonConvert.SerializeObject(historyEntry as PowerHistoryFullEntity));

            case PowerType.SHOW_ENTITY:
                return(JsonConvert.SerializeObject(historyEntry as PowerHistoryShowEntity));

            case PowerType.HIDE_ENTITY:
                return(JsonConvert.SerializeObject(historyEntry as PowerHistoryHideEntity));

            case PowerType.TAG_CHANGE:
                return(JsonConvert.SerializeObject(historyEntry as PowerHistoryTagChange));

            case PowerType.BLOCK_START:
                return(JsonConvert.SerializeObject(historyEntry as PowerHistoryBlockStart));

            case PowerType.BLOCK_END:
                return(JsonConvert.SerializeObject(historyEntry as PowerHistoryBlockEnd));

            case PowerType.CREATE_GAME:
                return(JsonConvert.SerializeObject(historyEntry as PowerHistoryCreateGame));

            case PowerType.META_DATA:
                return(JsonConvert.SerializeObject(historyEntry as PowerHistoryMetaData));

            case PowerType.CHANGE_ENTITY:
            case PowerType.RESET_GAME:
            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 3
0
 public void Add(IPowerHistoryEntry entry)
 {
     Full.Add(entry);
     Last.Add(entry);
 }
Exemplo n.º 4
0
 public static IPowerHistoryEntry Pop(this PowerHistory powerHistory, IPowerHistoryEntry e)
 {
     powerHistory.Full.Remove(e);
     powerHistory.Last.Remove(e);
     return(e);
 }
 public void AddHistoryEntry(IPowerHistoryEntry historyEntry)
 {
     _historyEntries.Enqueue(historyEntry);
 }
Exemplo n.º 6
0
 public static string RequestServerGamePowerHistory(int id, string token, int gameId, int playerId, IPowerHistoryEntry powerHistoryLast)
 {
     return(JsonConvert.SerializeObject(new DataPacket
     {
         Id = id,
         Token = token,
         SendData = JsonConvert.SerializeObject(
             new SendData
         {
             MessageType = MessageType.Game,
             MessageData = JsonConvert.SerializeObject(
                 new GameData
             {
                 GameId = gameId,
                 GameMessageType = GameMessageType.GameRequest,
                 GameMessageData = JsonConvert.SerializeObject(
                     new GameRequest
                 {
                     GameRequestType = GameRequestType.PowerHistory,
                     GameRequestData = JsonConvert.SerializeObject(
                         new GameRequestPowerHistory
                     {
                         PlayerId = playerId,
                         PowerType = powerHistoryLast.PowerType,
                         PowerHistory = PowerJsonHelper.Serialize(powerHistoryLast)
                     })
                 })
             })
         })
     }));
 }