<commit_before>/// Copyright (C) 2012-2014 Soomla Inc.
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///      http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.using System;

using System;
using System.Collections;
using System.Collections.Generic;

namespace Soomla.Levelup
{
	/// <summary>
	/// A representation of one or more <c>Gate</c>s which together define a 
	/// composite criteria for progressing between the game's <c>World</c>s 
	/// or <code>Level</code>s.
	/// </summary>
	public abstract class GatesList : Gate
	{
		/// <summary>
		/// The list of <c>Gate</c>s.
		/// </summary>
		protected List<Gate> Gates = new List<Gate>();

		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="id">GatesList ID.</param>
		public GatesList(string id)
			: base(id)
		{
		}

		/// <summary>
		/// Constructor for GatesList with one gate.
		/// </summary>
		/// <param name="id">ID.</param>
		/// <param name="singleGate">Single gate in this gateslist.</param>
		public GatesList(string id, Gate singleGate)
			: base(id)
		{
			Gates.Add(singleGate);
		}

		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="id">ID.</param>
		/// <param name="gates">List of gates.</param>
		public GatesList(string id, List<Gate> gates)
			: base(id)
		{
			Gates = gates;
		}
		
		/// <summary>
		/// Constructor. 
		/// </summary>
		/// <param name="jsonGate">JSON gate.</param>
		public GatesList(JSONObject jsonGate)
			: base(jsonGate)
		{
			List<JSONObject> gatesJSON = jsonGate[LUJSONConsts.LU_GATES].list;

			// Iterate over all gates in the JSON array and for each one create
			// an instance according to the gate type
			foreach (JSONObject gateJSON in gatesJSON) {
				Gate gate = Gate.fromJSONObject(gateJSON);
				if (gate != null) {
					Gates.Add(gate);
				}
			}
		}
		
		/// <summary>
		/// Converts this gateslist into a JSONObject.
		/// </summary>
		/// <returns>The JSON object.</returns>
		public override JSONObject toJSONObject() {
			JSONObject obj = base.toJSONObject();<commit_msg>GateList constructor with List<Gates> now gates attaches event listeners to individual gates in the list.<commit_after>/// Copyright (C) 2012-2014 Soomla Inc.
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///      http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.using System;

using System;
using System.Collections;
using System.Collections.Generic;

namespace Soomla.Levelup
{
	/// <summary>
	/// A representation of one or more <c>Gate</c>s which together define a 
	/// composite criteria for progressing between the game's <c>World</c>s 
	/// or <code>Level</code>s.
	/// </summary>
	public abstract class GatesList : Gate
	{
		/// <summary>
		/// The list of <c>Gate</c>s.
		/// </summary>
		protected List<Gate> Gates = new List<Gate>();

		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="id">GatesList ID.</param>
		public GatesList(string id)
			: base(id)
		{
		}

		/// <summary>
		/// Constructor for GatesList with one gate.
		/// </summary>
		/// <param name="id">ID.</param>
		/// <param name="singleGate">Single gate in this gateslist.</param>
		public GatesList(string id, Gate singleGate)
			: base(id)
		{
			Gates.Add(singleGate);
		}

		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="id">ID.</param>
		/// <param name="gates">List of gates.</param>
		public GatesList(string id, List<Gate> gates)
			: base(id)
		{
			// Iterate over gates in given list and add them to Gates making a 
			// copy and attaching listeners
			foreach (Gate gate in gates) {
				Gates.Add(gate);
			}
		}
		
		/// <summary>
		/// Constructor. 
		/// </summary>
		/// <param name="jsonGate">JSON gate.</param>
		public GatesList(JSONObject jsonGate)
			: base(jsonGate)
		{
			List<JSONObject> gatesJSON = jsonGate[LUJSONConsts.LU_GATES].list;

			// Iterate over all gates in the JSON array and for each one create
			// an instance according to the gate type
			foreach (JSONObject gateJSON in gatesJSON) {
				Gate gate = Gate.fromJSONObject(gateJSON);
				if (gate != null) {
					Gates.Add(gate);
				}
			}
		}
		
		/// <summary>
		/// Converts this gateslist into a JSONObject.
		/// </summary>
		/// <returns>The JSON object.</returns>
		public override JSONObject toJSONObject() {
			JSONObject obj = base.toJSONObject();
{'fraction_non_alphanumeric': 0.14713740458015268, 'fraction_numerical': 0.004580152671755725, 'mean_word_length': 2.79507603186097, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 84, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4888610', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1568, 'n_words': 524}