Beispiel #1
0
 /// <summary>
 ///  Put this instance to aborted state
 /// </summary>
 /// <param name="date">The date.</param>
 /// <returns></returns>
 public Reproduction ToAborted(DateTime date)
 {
     if ((ActualState.State != ReproductionStateEnum.Initial && ActualState.State != ReproductionStateEnum.Gestating) || this == None)
     {
         return(Reproduction.None);
     }
     return(new Reproduction(Female, Male, date, Type, States.Append(new ReproductionState(ReproductionStateEnum.Aborted, date)), Commentary));
 }
Beispiel #2
0
        /// <summary>
        ///  Put this instance to next state if possible
        /// </summary>
        /// <param name="date">The date.</param>
        /// <returns></returns>
        private Reproduction ToNextState(DateTime date)
        {
            switch (ActualState.State)
            {
            case ReproductionStateEnum.Initial when date > ActualState.Date:
                return(new Reproduction(Female, Male, date, Type, States.Append(new ReproductionState(ReproductionStateEnum.Gestating, date)), Commentary));

            case ReproductionStateEnum.Gestating when date.Subtract(ActualState.Date) >= Female.Breed.Specie.PregnancyDuration:
                return(new Reproduction(Female, Male, date, Type, States.Append(new ReproductionState(ReproductionStateEnum.Complete, date)), Commentary));

            case ReproductionStateEnum.Complete:
                return(this);

            default:
                return(Reproduction.None);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Reproduction"/> class.
 /// </summary>
 /// <param name="female">The female.</param>
 /// <param name="male">The male.</param>
 /// <param name="date">The date.</param>
 /// <param name="type">The type.</param>
 /// <param name="status">The status.</param>
 /// <param name="commentary">The commentary.</param>
 private Reproduction(Female female, Male male, DateTime date,
                      ReproductionTypeEnum type, ReproductionStateEnum status,
                      string commentary)
 {
     if (female != null && female.CanBeMated(date) && status == ReproductionStateEnum.Initial)
     {
         Female = female;
         Male   = male;
         Date   = date;
         Type   = type;
         States.Append(new ReproductionState(status, date));
         Commentary = commentary;
     }
     else
     {
         Female = null;
         Male   = null;
         Date   = DateTime.MinValue;
         Type   = ReproductionTypeEnum.Artificial;
     }
 }
Beispiel #4
0
 public GameHistory With(Turn turn, BoardState nextState)
 => new GameHistory(
     States.Append(nextState).ToArray(),
     Turns.Append(turn).ToArray());