예제 #1
0
        public static async Task <MinorExperienceEventRecord> Parse(JsonObject json)
        {
            MinorExperienceEventRecord record = new MinorExperienceEventRecord();
            JsonString characterId            = json["character_id"] as JsonString;
            JsonString otherId       = json["other_id"] as JsonString;
            JsonString loadoutId     = json["loadout_id"] as JsonString;
            JsonString experienceId  = json["experience_id"] as JsonString;
            JsonString timestamp     = json["timestamp"] as JsonString;
            var        characterTask = PS2APIUtils.GetCharacterName(characterId);
            var        otherTask     = PS2APIUtils.GetCharacterName(otherId);

            record.characterLoadout = PS2APIUtils.GetLoadoutName(loadoutId);

            long ts;

            if (timestamp == null || !long.TryParse(timestamp.InnerString, out ts))
            {
                ts = 0;
            }
            record.timestamp = ts;
            record.type      = GetExperienceType(experienceId?.InnerString);

            await Task.WhenAll(characterTask, otherTask);

            record.character = await characterTask;
            record.other     = await otherTask;
            return(record);
        }
예제 #2
0
        public static async Task <VehicleDestroyedEventRecord> Parse(JsonObject json)
        {
            VehicleDestroyedEventRecord record = new VehicleDestroyedEventRecord();
            JsonString characterId             = json["character_id"] as JsonString;
            JsonString attackerId        = json["attacker_character_id"] as JsonString;
            JsonString attackerVehicleId = json["attacker_vehicle_id"] as JsonString;
            JsonString attackerLoadoutId = json["attacker_loadout_id"] as JsonString;
            JsonString attackerWeaponId  = json["attacker_weapon_id"] as JsonString;
            JsonString vehicleId         = json["vehicle_id"] as JsonString;
            JsonString timestamp         = json["timestamp"] as JsonString;
            var        characterTask     = PS2APIUtils.GetCharacterName(characterId);
            var        attackerTask      = PS2APIUtils.GetCharacterName(attackerId);

            record.attackerVehicle     = PS2APIUtils.GetVehicleName(attackerVehicleId);
            record.destroyedVehicle    = PS2APIUtils.GetVehicleName(vehicleId);
            record.attackerLoadoutName = PS2APIUtils.GetLoadoutName(attackerLoadoutId);
            record.weaponName          = PS2APIUtils.GetWeaponName(attackerWeaponId);

            long ts;

            if (timestamp == null || !long.TryParse(timestamp.InnerString, out ts))
            {
                ts = 0;
            }
            record.timestamp = ts;

            await Task.WhenAll(characterTask, attackerTask);

            record.victim   = await characterTask;
            record.attacker = await attackerTask;
            return(record);
        }