mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-04-25 08:04:27 -05:00
Added public StatValues ctors that take enumerables.
This commit is contained in:
parent
133a77d75f
commit
28876be090
|
|
@ -12,9 +12,8 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
protected ByteStatValues(byte[] s) : base(s)
|
||||
public ByteStatValues(IEnumerable<byte> s) : base(s)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
public IntStatValues(IEnumerable<int> s) : base(s)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
public IvStatValues(IEnumerable<byte> s) : base(s)
|
||||
{
|
||||
foreach (byte b in s)
|
||||
{
|
||||
if (b > 31) throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
public IvStatValues(int ivs) : base(new byte[6])
|
||||
{
|
||||
for (int x = 0; x < 6; x++)
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ namespace PkmnFoundations.Structures
|
|||
|
||||
}
|
||||
|
||||
protected StatValues(T[] s) : base(s)
|
||||
public StatValues(IEnumerable<T> s) : base(s)
|
||||
{
|
||||
if (s.Length != 6) throw new ArgumentException();
|
||||
}
|
||||
|
||||
public T Hp { get { return Stats[0]; } set { Stats[0] = value; } }
|
||||
|
|
|
|||
|
|
@ -7,9 +7,13 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
public abstract class StatValuesBase<T> where T : struct
|
||||
{
|
||||
protected StatValuesBase(T[] s)
|
||||
protected StatValuesBase(IEnumerable<T> s)
|
||||
{
|
||||
Stats = s;
|
||||
// fail without enumerating if possible
|
||||
if (s is IList<T> && ((IList<T>)s).Count != 6) throw new ArgumentException("s must have exactly 6 elements.", "s");
|
||||
var arr = s.ToArray();
|
||||
if (arr.Length != 6) throw new ArgumentException("s must have exactly 6 elements.", "s");
|
||||
Stats = arr;
|
||||
}
|
||||
|
||||
protected StatValuesBase(T s0, T s1, T s2, T s3, T s4, T s5)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user