Esempio n. 1
0
        public PokemonList1(byte[] d, CapacityType c = CapacityType.Single, bool jp = false)
        {
            Japanese   = jp;
            Data       = d ?? getEmptyList(c, Japanese);
            Capacity   = getCapacity(c);
            Entry_Size = getEntrySize(c);

            if (Data.Length != DataSize)
            {
                Array.Resize(ref Data, DataSize);
            }

            Pokemon = new PK1[Capacity];
            for (int i = 0; i < Capacity; i++)
            {
                int    base_ofs = 2 + Capacity;
                byte[] dat      = Data.Skip(base_ofs + Entry_Size * i).Take(Entry_Size).ToArray();
                Pokemon[i] = new PK1(dat, null, jp)
                {
                    otname = Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * i).Take(StringLength).ToArray(),
                    nick   = Data.Skip(base_ofs + Capacity * Entry_Size + StringLength * Capacity + StringLength * i)
                             .Take(StringLength).ToArray()
                };
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Check if the Hero posses a Capacity
 /// </summary>
 /// <param name="capacity"></param>
 /// <returns>True if he does, False else</returns>
 public bool PossesCapacity(CapacityType capacity)
 {
     foreach (Capacity Capa in this.Capacities)
     {
         if (Capa.CapacityKind == capacity)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 3
0
        public void RemoveCapacity(CapacityType capacityType)
        {
            Capacity capacity = new Capacity(capacityType);

            Capacities.Remove(capacity);

            if (capacityType == CapacityType.WeaponMastery)
            {
                this.WeaponMastery = WeaponTypes.None;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This method calls a method to release capacity back
        /// based on whether it was a successful response or a successful retry response. This is invoked by a retry request response.
        /// </summary>
        /// <param name="capacityType">Specifies what capacity type cost to use for adding capacity</param>
        /// <param name="retryCapacity">Contains the RetryCapacity object for the said ServiceURL.</param>
        public void ReleaseCapacity(CapacityType capacityType, RetryCapacity retryCapacity)
        {
            switch (capacityType)
            {
            case CapacityType.Retry:
                ReleaseCapacity(retryCost, retryCapacity);
                break;

            case CapacityType.Timeout:
                ReleaseCapacity(timeoutRetryCost, retryCapacity);
                break;

            case CapacityType.Increment:
                ReleaseCapacity(noRetryIncrement, retryCapacity);
                break;

            default:
                throw new NotSupportedException($"Unsupported CapacityType {capacityType}");
            }
        }
Esempio n. 5
0
        /// <summary>
        /// This method acquires a said retry capacity if the container has the capacity.
        /// </summary>
        /// <param name="retryCapacity">Contains the RetryCapacity object for the said ServiceURL.</param>
        /// <param name="capacityType">Specifies what capacity type cost to use for obtaining capacity</param>
        public bool TryAcquireCapacity(RetryCapacity retryCapacity, CapacityType capacityType)
        {
            var capacityCost = capacityType == CapacityType.Timeout ? timeoutRetryCost : retryCost;

            if (capacityCost < 0)
            {
                return(false);
            }
            lock (retryCapacity)
            {
                if (retryCapacity.AvailableCapacity - capacityCost >= 0)
                {
                    retryCapacity.AvailableCapacity -= capacityCost;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        public static bool CheckInsertedMediaType(ProjectType aProjectType, Burner aSelectedBurner)
        {
            CapacityType CurrentType = aSelectedBurner.CurrentMediaInfo.CurrentCapacityType;

            switch (aProjectType)
            {
            case ProjectType.Autoselect:
                return(CurrentType != CapacityType.Unknown);

            case ProjectType.DataCD:
                return(CurrentType == CapacityType.CDR);

            case ProjectType.AudioCD:
                return(CurrentType == CapacityType.CDR);

            case ProjectType.PhotoCD:
                return(CurrentType == CapacityType.CDR);

            case ProjectType.IsoCD:
                return(CurrentType == CapacityType.CDR);

            case ProjectType.DataDVD:
                return(CurrentType == CapacityType.DVDR);

            case ProjectType.VideoDVD:
                return(CurrentType == CapacityType.DVDR);

            case ProjectType.IsoDVD:
                return(CurrentType == CapacityType.DVDR);

            case ProjectType.LargeDataDVD:
                return(CurrentType == CapacityType.DualDVDR);

            case ProjectType.LargeIsoDVD:
                return(CurrentType == CapacityType.DualDVDR);

            default:
                return(false);
            }
        }
Esempio n. 7
0
        public PokemonList(byte[] d, CapacityType c = CapacityType.Single, bool jp = false)
        {
            JP         = jp;
            Data       = d ?? getEmptyList(c, JP);
            Capacity   = getCapacity(c);
            Entry_Size = getEntrySize(c);

            if (Data.Length != DataSize)
            {
                Array.Resize(ref Data, DataSize);
            }

            Pokemon = jp ? new JPK1[Capacity] : new PK1[Capacity];
            for (int i = 0; i < Capacity; i++)
            {
                int    base_ofs = 2 + Capacity;
                byte[] dat      = Data.Skip(base_ofs + Entry_Size * i).Take(Entry_Size).ToArray();
                Pokemon[i]          = jp ? new JPK1(dat) : new PK1(dat);
                Pokemon[i].OT_Name  = Data.Skip(base_ofs + Capacity * Entry_Size + (JP ? 6 : 0xB) * i).Take((JP ? 6 : 0xB)).ToArray();
                Pokemon[i].Nickname = Data.Skip(base_ofs + Capacity * Entry_Size + (JP ? 6 : 0xB) * Capacity + (JP ? 6 : 0xB) * i).Take((JP ? 6 : 0xB)).ToArray();
            }
        }
Esempio n. 8
0
        public void AddCapacity(CapacityType capacityType)
        {
            if (this.MaxNumberOfCapacities > this.Capacities.Count)
            {
                if (!PossesCapacity(capacityType))
                {
                    Capacity capacity = new Capacity(capacityType);
                    Capacities.Add(capacity);

                    if (capacityType == CapacityType.WeaponMastery)
                    {
                        while (this.WeaponMastery == WeaponTypes.None)
                        {
                            this.WeaponMastery = GlobalFunction.RandomEnumValue <WeaponTypes>();
                        }
                    }
                }
            }
            else
            {
                throw new MaxNumberOfCapacitiesReached(GlobalTranslator.Instance.Translator.ProvideValue("TooManyCapacities") + " (" + MaxNumberOfCapacities + ")");
            }
        }
Esempio n. 9
0
 public static int getEntrySize(CapacityType c)
 {
     return(c == CapacityType.Single || c == CapacityType.Party
         ? PKX.SIZE_1PARTY
         : PKX.SIZE_1STORED);
 }
Esempio n. 10
0
File: PK1.cs Progetto: kwsch/PKHeX
 public static int GetDataLength(CapacityType c, bool jp = false)
 {
     return getCapacity(c) * (getEntrySize(c) + 1 + 2 * (jp ? PK1.STRLEN_J : PK1.STRLEN_U)) + 2;
 }
Esempio n. 11
0
File: PK1.cs Progetto: kwsch/PKHeX
 public PokemonList1(CapacityType c = CapacityType.Single, bool jp = false)
     : this(null, c, jp)
 {
     Count = 1;
 }
Esempio n. 12
0
File: PK1.cs Progetto: kwsch/PKHeX
        public PokemonList1(byte[] d, CapacityType c = CapacityType.Single, bool jp = false)
        {
            Japanese = jp;
            Data = d ?? getEmptyList(c, Japanese);
            Capacity = getCapacity(c);
            Entry_Size = getEntrySize(c);

            if (Data.Length != DataSize)
            {
                Array.Resize(ref Data, DataSize);
            }

            Pokemon = new PK1[Capacity];
            for (int i = 0; i < Capacity; i++)
            {
                int base_ofs = 2 + Capacity;
                byte[] dat = Data.Skip(base_ofs + Entry_Size * i).Take(Entry_Size).ToArray();
                Pokemon[i] = new PK1(dat, null, jp)
                {
                    otname = Data.Skip(base_ofs + Capacity*Entry_Size + StringLength*i).Take(StringLength).ToArray(),
                    nick = Data.Skip(base_ofs + Capacity*Entry_Size + StringLength*Capacity + StringLength*i)
                            .Take(StringLength).ToArray()
                };
            }
        }
Esempio n. 13
0
File: PK1.cs Progetto: kwsch/PKHeX
 private byte[] getEmptyList(CapacityType c, bool is_JP = false)
 {
     int cap = getCapacity(c);
     return new[] { (byte)0 }.Concat(Enumerable.Repeat((byte)0xFF, cap + 1)).Concat(Enumerable.Repeat((byte)0, getEntrySize(c) * cap)).Concat(Enumerable.Repeat((byte)0x50, (is_JP ? PK1.STRLEN_J : PK1.STRLEN_U) * 2 * cap)).ToArray();
 }
Esempio n. 14
0
 /// <summary>
 /// Changes the type of the capacity.
 /// </summary>
 /// <param name="capacityType">Type of the capacity.</param>
 public virtual void ChangeCapacityType( CapacityType capacityType )
 {
     CapacityType = capacityType;
 }
Esempio n. 15
0
 /// <summary>
 /// A BuffEvent that happen if the player posses an Item
 /// </summary>
 /// <param name="requieredItem">The item required to have the buff</param>
 /// <param name="debuff">The amount of Agility added (minus than 0 for a malus)</param>
 public BuffOrDebuffEvent(CapacityType requieredCapacity, int debuff)
 {
     this.RequieredCapacity = requieredCapacity;
     this.CapacityRequiered = true;
     this.Debuff            = debuff;
 }
Esempio n. 16
0
 public static int GetDataLength(CapacityType c, bool jp = false)
 {
     return(getCapacity(c) * (getEntrySize(c) + 1 + 2 * (jp ? PK1.STRLEN_J : PK1.STRLEN_U)) + 2);
 }
Esempio n. 17
0
 /// <summary>
 /// Create a CapacityEvent
 /// </summary>
 /// <param name="destinationNumber">The Paragraph Number the Player will be send to</param>
 /// <param name="capacityType">The required CapacityType in order to see the Event</param>
 public CapacityEvent(int destinationNumber, CapacityType capacityType)
 {
     this.DestinationNumber = destinationNumber;
     this.capacityType      = capacityType;
     this.TriggerMessage    = GlobalTranslator.Instance.Translator.ProvideValue("UseCapacity") + capacityType.GetTranslation();
 }
Esempio n. 18
0
        /// <summary>
        /// Create a Capacity
        /// </summary>
        /// <param name="capacityType">The type of the Capacity</param>
        public Capacity(CapacityType capacityType)

        {
            this.CapacityKind = capacityType;
        }
Esempio n. 19
0
 /// <summary>
 /// Get the Name of the CapacityType in the adequate language
 /// </summary>
 /// <param name="capacity">The CapacityType</param>
 /// <returns>the Name of the CapacityType in the adequate language</returns>
 public static String GetTranslation(this CapacityType capacity)
 {
     return(GlobalTranslator.Instance.Translator.ProvideValue(capacity.ToString()));
 }
Esempio n. 20
0
 public static int GetDataLength(CapacityType c, bool jp = false)
 {
     return(getCapacity(c) * (getEntrySize(c) + 1 + 2 * (jp ? 6 : 0xB)) + 2);
 }
Esempio n. 21
0
 public static byte getCapacity(CapacityType c)
 {
     return(c == CapacityType.Single ? (byte)1 : (byte)c);
 }
Esempio n. 22
0
        private byte[] getEmptyList(CapacityType c, bool is_JP = false)
        {
            int cap = getCapacity(c);

            return(new[] { (byte)0 }.Concat(Enumerable.Repeat((byte)0xFF, cap + 1)).Concat(Enumerable.Repeat((byte)0, getEntrySize(c) * cap)).Concat(Enumerable.Repeat((byte)0x50, (is_JP ? PK1.STRLEN_J : PK1.STRLEN_U) * 2 * cap)).ToArray());
        }
Esempio n. 23
0
File: PK1.cs Progetto: kwsch/PKHeX
 public static byte getCapacity(CapacityType c)
 {
     return c == CapacityType.Single ? (byte)1 : (byte)c;
 }
Esempio n. 24
0
 public PokemonList1(CapacityType c = CapacityType.Single, bool jp = false)
     : this(null, c, jp)
 {
     Count = 1;
 }
Esempio n. 25
0
File: PK1.cs Progetto: kwsch/PKHeX
 public static int getEntrySize(CapacityType c)
 {
     return c == CapacityType.Single || c == CapacityType.Party
         ? PKX.SIZE_1PARTY
         : PKX.SIZE_1STORED;
 }
Esempio n. 26
0
 /// <summary>
 /// Changes the type of the capacity.
 /// </summary>
 /// <param name="capacityType">Type of the capacity.</param>
 public virtual void ChangeCapacityType(CapacityType capacityType)
 {
     CapacityType = capacityType;
 }
Esempio n. 27
0
 /// <summary>
 /// Create a CapacityEvent
 /// </summary>
 /// <param name="destinationNumber">The Paragraph Number the Player will be send to</param>
 /// <param name="capacityType">The required CapacityType in order to see the Event</param>
 /// <param name="triggerMessage">The message that will be displayed to the Player to start the event</param>
 public CapacityEvent(int destinationNumber, CapacityType capacityType, string triggerMessage)
 {
     this.DestinationNumber = destinationNumber;
     this.capacityType      = capacityType;
     this.TriggerMessage    = triggerMessage;
 }