Пример #1
0
 public Thing With(
     long?id = null,
     ThingTypes?thingType = null,
     string name          = null,
     ISlotList validSlots = null,
     IMaybe <EquipmentSlots> equipedAs          = null,
     IMaybe <CombatStatistics> combatStatistics = null,
     IThingStore contains = null)
 {
     return
         (id.HasValue ||
          thingType.HasValue ||
          name != null ||
          validSlots != null ||
          equipedAs != null ||
          combatStatistics != null ||
          contains != null
             ? new Thing(
              id ?? _id,
              thingType ?? _thingType,
              name ?? _name,
              validSlots ?? _validSlots,
              equipedAs ?? _equipedAs,
              combatStatistics ?? _combatStatistics,
              contains ?? _contains)
             : this);
 }
Пример #2
0
 public static void Validate(
     Tile instance,
     TileTypes?tileType    = null,
     string name           = null,
     IMaybe <long> actorId = null,
     IThingStore things    = null)
 {
     Assert.AreEqual(tileType ?? TileType, instance.TileType);
     Assert.AreEqual(name ?? Name, instance.Name);
     Assert.AreEqual(actorId ?? ActorId, instance.ActorId);
     Assert.AreSame(things ?? Things, instance.Things);
 }
Пример #3
0
 public static Tile Create(
     TileTypes tileType,
     string name,
     IMaybe <long> actorId,
     IThingStore things)
 {
     return(new Tile(
                tileType,
                name,
                actorId,
                things));
 }
Пример #4
0
        private Tile(
            TileTypes tileType,
            string name,
            IMaybe <long> actorId,
            IThingStore things)
        {
            Debug.Assert(name != null);
            Debug.Assert(actorId != null);
            Debug.Assert(things != null);

            _tileType = tileType;
            _name     = name;
            _actorId  = actorId;
            _things   = things;
        }
Пример #5
0
 private static void Validate(
     Actor instance,
     long?id = null,
     ActorTypes?actorType   = null,
     string name            = null,
     IStatisticsStore stats = null,
     HitPoints hp           = null,
     IThingStore things     = null)
 {
     Assert.AreEqual(id ?? Id, instance.Id);
     Assert.AreEqual(actorType ?? ActorType, instance.ActorType);
     Assert.AreEqual(name ?? Name, instance.Name);
     Assert.AreSame(stats ?? Stats, instance.Statistics);
     Assert.AreSame(hp ?? Hp, instance.HitPoints);
     Assert.AreSame(things ?? Things, instance.Things);
 }
Пример #6
0
 public static Actor Create(
     long id,
     ActorTypes actorType,
     string name,
     IStatisticsStore statistics,
     HitPoints hitPoints,
     IThingStore things)
 {
     return
         (new Actor(
              id,
              actorType,
              name,
              statistics,
              hitPoints,
              things));
 }
Пример #7
0
 private static void Validate(
     Thing instance,
     long?id = null,
     ThingTypes?thingType = null,
     string name          = null,
     ISlotList validSlots = null,
     IMaybe <EquipmentSlots> equipedAs          = null,
     IMaybe <CombatStatistics> combatStatistics = null,
     IThingStore contains = null)
 {
     Assert.AreEqual(id ?? Id, instance.Id);
     Assert.AreEqual(thingType ?? ThingType, instance.ThingType);
     Assert.AreEqual(name ?? Name, instance.Name);
     Assert.AreSame(validSlots ?? ValidSlots, instance.ValidSlots);
     Assert.AreSame(equipedAs ?? EquipedAs, instance.EquipedAs);
     Assert.AreSame(combatStatistics ?? CombatStats, instance.CombatStatistics);
     Assert.AreSame(contains ?? Contains, instance.Contains);
 }
Пример #8
0
 public static Thing Create(
     long id,
     ThingTypes thingType,
     string name,
     ISlotList validSlots,
     IMaybe <EquipmentSlots> equipedAs,
     IMaybe <CombatStatistics> combatStatistics,
     IThingStore contains)
 {
     return(new Thing(
                id,
                thingType,
                name,
                validSlots,
                equipedAs,
                combatStatistics,
                contains));
 }
Пример #9
0
        private Actor(
            long id,
            ActorTypes actorType,
            string name,
            IStatisticsStore statistics,
            HitPoints hitPoints,
            IThingStore things)
        {
            Debug.Assert(name != null);
            Debug.Assert(statistics != null);
            Debug.Assert(hitPoints != null);
            Debug.Assert(things != null);

            _id         = id;
            _actorType  = actorType;
            _name       = name;
            _statistics = statistics;
            _hitPoints  = hitPoints;
            _things     = things;
        }
Пример #10
0
        public Thing(
            long id,
            ThingTypes thingType,
            string name,
            ISlotList validSlots,
            IMaybe <EquipmentSlots> equipedAs,
            IMaybe <CombatStatistics> combatStatistics,
            IThingStore contains)
        {
            Debug.Assert(name != null);
            Debug.Assert(validSlots != null);
            Debug.Assert(equipedAs != null);
            Debug.Assert(combatStatistics != null);
            Debug.Assert(contains != null);

            _id               = id;
            _thingType        = thingType;
            _name             = name;
            _validSlots       = validSlots;
            _equipedAs        = equipedAs;
            _combatStatistics = combatStatistics;
            _contains         = contains;
        }
Пример #11
0
        public Tile With(
            TileTypes?tileType    = null,
            string name           = null,
            IMaybe <long> actorId = null,
            IThingStore things    = null)
        {
            if (TileType == TileTypes.Void)
            {
                throw new InvalidOperationException("Nothing can touch the void");
            }

            return
                (!tileType.HasValue &&
                 name == null &&
                 actorId == null &&
                 things == null
                    ? this
                    : new Tile(
                     tileType ?? _tileType,
                     name ?? _name,
                     actorId ?? _actorId,
                     things ?? _things));
        }
Пример #12
0
 public Actor With(
     long?id = null,
     ActorTypes?actorType        = null,
     string name                 = null,
     IStatisticsStore statistics = null,
     HitPoints hitPoints         = null,
     IThingStore things          = null)
 {
     return
         (id.HasValue ||
          actorType.HasValue ||
          name != null ||
          statistics != null ||
          hitPoints != null ||
          things != null
             ? new Actor(
              id ?? _id,
              actorType ?? _actorType,
              name ?? _name,
              statistics ?? _statistics,
              hitPoints ?? _hitPoints,
              things ?? _things)
             : this);
 }