Esempio n. 1
0
        public static Destination TakeChip(this Destination.Bin self, int chip)
        {
            if (self.Chip > 0)
            {
                throw new InvalidOperationException("Already has a chip");
            }

            self.Chip = chip;

            return(self);
        }
Esempio n. 2
0
        public static Destination.Bin GetOrMakeBin(this Factory self, int binNum)
        {
            var existing = self.Destinations.Any(d => d.Match(bot => false, bin => bin.Number == binNum))
                ? self.Destinations.First(d => d.Match(bot => false, bin => bin.Number == binNum)) as Destination.Bin
                : null;

            if (existing != null)
            {
                return(existing);
            }
            var newBin = new Destination.Bin()
            {
                Factory = self, Number = binNum
            };

            self.Destinations.Add(newBin);
            return(newBin);
        }