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() }; } }
/// <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); }
public void RemoveCapacity(CapacityType capacityType) { Capacity capacity = new Capacity(capacityType); Capacities.Remove(capacity); if (capacityType == CapacityType.WeaponMastery) { this.WeaponMastery = WeaponTypes.None; } }
/// <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}"); } }
/// <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); } }
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(); } }
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 + ")"); } }
public static int getEntrySize(CapacityType c) { return(c == CapacityType.Single || c == CapacityType.Party ? PKX.SIZE_1PARTY : PKX.SIZE_1STORED); }
public static int GetDataLength(CapacityType c, bool jp = false) { return getCapacity(c) * (getEntrySize(c) + 1 + 2 * (jp ? PK1.STRLEN_J : PK1.STRLEN_U)) + 2; }
public PokemonList1(CapacityType c = CapacityType.Single, bool jp = false) : this(null, c, jp) { Count = 1; }
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() }; } }
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(); }
/// <summary> /// Changes the type of the capacity. /// </summary> /// <param name="capacityType">Type of the capacity.</param> public virtual void ChangeCapacityType( CapacityType capacityType ) { CapacityType = capacityType; }
/// <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; }
public static int GetDataLength(CapacityType c, bool jp = false) { return(getCapacity(c) * (getEntrySize(c) + 1 + 2 * (jp ? PK1.STRLEN_J : PK1.STRLEN_U)) + 2); }
/// <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(); }
/// <summary> /// Create a Capacity /// </summary> /// <param name="capacityType">The type of the Capacity</param> public Capacity(CapacityType capacityType) { this.CapacityKind = capacityType; }
/// <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())); }
public static int GetDataLength(CapacityType c, bool jp = false) { return(getCapacity(c) * (getEntrySize(c) + 1 + 2 * (jp ? 6 : 0xB)) + 2); }
public static byte getCapacity(CapacityType c) { return(c == CapacityType.Single ? (byte)1 : (byte)c); }
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()); }
public static byte getCapacity(CapacityType c) { return c == CapacityType.Single ? (byte)1 : (byte)c; }
public static int getEntrySize(CapacityType c) { return c == CapacityType.Single || c == CapacityType.Party ? PKX.SIZE_1PARTY : PKX.SIZE_1STORED; }
/// <summary> /// Changes the type of the capacity. /// </summary> /// <param name="capacityType">Type of the capacity.</param> public virtual void ChangeCapacityType(CapacityType capacityType) { CapacityType = capacityType; }
/// <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; }