Esempio n. 1
0
        public Blood Store(Blood value)
        {
            if (value < new Blood())
            {
                return(-Consume(-value));
            }

            if (currentValue + value > capacity)
            {
                value       -= capacity - currentValue;
                currentValue = capacity;
                return(value);
            }

            currentValue += value;
            return(new Blood());
        }
Esempio n. 2
0
        public Blood Consume(Blood value)
        {
            if (value < new Blood())
            {
                return(-Store(-value));
            }

            if (currentValue - value < new Blood())
            {
                value       -= currentValue;
                currentValue = new Blood();
                return(value);
            }

            currentValue -= value;
            return(new Blood());
        }
Esempio n. 3
0
 public static Blood Max(Blood a, Blood b) => a > b ? a : b;
Esempio n. 4
0
 public BloodStorage(Blood capacity)
 {
     this.capacity = capacity;
 }
Esempio n. 5
0
 public static Blood Min(Blood a, Blood b) => a < b ? a : b;