Ejemplo n.º 1
0
 public KettleHistoryBlockBegin(PowerHistoryBlockStart p)
 {
     EffectCardId = p.EffectCardId;
     Index        = p.Index;
     Source       = p.Source;
     Target       = p.Target;
     Type         = (int)p.BlockType;
 }
        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);
        }