public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jsonObject = JObject.Load(reader);
            IPowerHistoryEntry history;

            switch ((PowerType)jsonObject["PowerType"].Value <int>())
            {
            case PowerType.FULL_ENTITY:
                history = new PowerHistoryFullEntity();
                break;

            case PowerType.SHOW_ENTITY:
                history = new PowerHistoryShowEntity();
                break;

            case PowerType.HIDE_ENTITY:
                history = new PowerHistoryHideEntity();
                break;

            case PowerType.TAG_CHANGE:
                history = new PowerHistoryTagChange();
                break;

            case PowerType.BLOCK_START:
                history = new PowerHistoryBlockStart();
                break;

            case PowerType.BLOCK_END:
                history = new PowerHistoryBlockEnd();
                break;

            case PowerType.CREATE_GAME:
                history = new PowerHistoryCreateGame();
                break;

            case PowerType.META_DATA:
                history = new PowerHistoryMetaData();
                break;

            case PowerType.CHANGE_ENTITY:
                history = new PowerHistoryChangeEntity();
                break;

            case PowerType.RESET_GAME:
            default:
                throw new ArgumentOutOfRangeException();
            }

            serializer.Populate(jsonObject.CreateReader(), history);
            return(history);
        }
Esempio n. 2
0
 public KettleHistoryTagChange(PowerHistoryTagChange p)
 {
     EntityId = p.EntityId;
     Tag      = (int)p.Tag;
     Value    = p.Value;
 }
Esempio n. 3
0
        private static void TagChange(Game game, PowerHistoryTagChange history)
        {
            IPlayable entity;

            switch (history.EntityId)
            {
            case 1:
                game[history.Tag] = history.Value;
                return;

            case 2:
                ControllerTagChange(game.Player1, history.Tag, history.Value);
                return;

            case 3:
                ControllerTagChange(game.Player2, history.Tag, history.Value);
                return;

            default:
                entity = game.IdEntityDic[history.EntityId];
                entity[history.Tag] = history.Value;
                break;
            }


            switch (history.Tag)
            {
            case GameTag.ZONE:
                entity.Zone?.Remove(entity);
                entity.ActivatedTrigger = null;                         // Headcrack
                var zone = (Zone)history.Value;
                if (zone == Zone.PLAY)
                {
                    if (entity is Minion m)
                    {
                        entity.Controller.BoardZone.MoveTo(m);
                        entity.ZonePosition = entity.Controller.BoardZone.Count - 1;
                    }
                }
                else
                {
                    entity.Controller.ControlledZones[zone].MoveTo(entity, -1);
                    if (zone == Zone.HAND)
                    {
                        entity.ZonePosition = entity.Controller.HandZone.Count - 1;
                    }
                }
                break;

            case GameTag.ZONE_POSITION:
                int newPos = history.Value - 1;
                if (newPos == entity.ZonePosition)
                {
                    return;
                }
                switch (entity.Zone)
                {
                case HandZone handZone:
                    handZone.Swap(entity, handZone[newPos]);
                    break;

                case BoardZone boardZone:
                    boardZone.Swap((Minion)entity, boardZone[newPos]);
                    break;
                }
                break;
            }
        }