Example #1
0
 public Game(int gameId, IList <IPlayer> players, ISupply supply, IVictoryCondition victoryCondition)
 {
     GameId           = gameId;
     Players          = players;
     Supply           = supply;
     VictoryCondition = victoryCondition;
     Components       = new Components();
 }
Example #2
0
        public async Task GetSupplies_RepositoryLayer_InValidMedicineName_Fail()
        {
            MedicineDemand demandOfSupplier = new MedicineDemand()
            {
                Medicine = "abc",
                Demand   = 100
            };
            ISupply repo   = supplyRepo.Object;
            var     result = await repo.GetSupplies(demandOfSupplier.Medicine, demandOfSupplier.Demand);

            Assert.IsNull(result);
        }
Example #3
0
        public async Task GetSupplies_RepositoryLayer_ValidInput_Pass()
        {
            MedicineDemand demandOfSupplier = new MedicineDemand()
            {
                Medicine = "Aspirin",
                Demand   = 100
            };
            ISupply repo   = supplyRepo.Object;
            var     result = await repo.GetSupplies(demandOfSupplier.Medicine, demandOfSupplier.Demand);

            Assert.IsNotNull(result);
        }
Example #4
0
        public void TrashFromHand(ISupply supply, Card card)
        {
            var cardInHand = Hand.First(x => x == card);
            var instance   = CardFactory.Create(cardInHand);

            Hand.Remove(cardInHand);
            GameLog.Add(PlayerName.Substring(0, 1) + " trashes a " + card);
            supply.AddToTrash(card);

            if (instance is IOnTrashAbilityHolder abilityHolder)
            {
                abilityHolder.ResolveOnTrashAbilities(this);
            }

            RunTriggeredAbilities(PlayerAction.Trash, card);
        }
        public DatabaseTestBase()
        {
            _connection = new SqliteConnection("Filename=:memory:");
            _connection.Open();

            _db = new HobbyListDbContext(
                new DbContextOptionsBuilder <HobbyListDbContext>()
                .UseSqlite(_connection)
                .Options);

            _db.Database.EnsureCreated();

            _paint = new PaintService(_db);

            _supply = new SupplyService(_db);

            _miniModel = new MiniModelService(_db, _paint, _supply);
        }
        public async Task SupplyReader_ForResponse_CreatesCorrectObject()
        {
            ISupply result = await TestUtility.ExecuteObjectReaderByTypeAsync <ISupply>(SUPPLY_RESPONSE_SINGLE);

            Assert.Multiple(() =>
            {
                // 2012-10-31T19:50:00+1000
                var testDateTime = new DateTimeOffset(2012, 10, 31, 19, 50, 0, new TimeSpan(10, 0, 0));

                Assert.That(result.Timestamp, Is.EqualTo(testDateTime));
                Assert.That(result.RegionName, Is.EqualTo("Western Australia"));
                Assert.That(result.Utilisation, Is.EqualTo(5.709m));
                Assert.That(result.TotalPowerOutput, Is.EqualTo(19108));
                Assert.That(result.TotalPowerInput, Is.EqualTo(11598));
                Assert.That(result.AveragePowerOutput, Is.EqualTo(239));
                Assert.That(result.AveragePowerInput, Is.EqualTo(892));
                Assert.That(result.AverageNetPower, Is.EqualTo(-653));
                Assert.That(result.SystemsOut, Is.EqualTo(80));
                Assert.That(result.SystemsIn, Is.EqualTo(13));
                Assert.That(result.TotalSize, Is.EqualTo(334719));
                Assert.That(result.AverageSize, Is.EqualTo(4184));
            });
        }
 public MedicineSupplyService(ISupply supplyrepo)
 {
     this.supplyrepo = supplyrepo;
 }
Example #8
0
 public SuppliesController(ISupply supply)
 {
     _supply = supply;
 }
Example #9
0
 public bool IsMet(ISupply supply)
 {
     return(supply.NoProvincesRemain() || supply.ThreeOrMorePilesEmpty());
 }
Example #10
0
 public MiniModelService(HobbyListDbContext context, IPaint paint, ISupply supply)
 {
     _context = context;
     _paint   = paint;
     _supply  = supply;
 }
Example #11
0
 public PlayerInitializer(Game game, ISupply supply)
 {
     _game   = game;
     _supply = supply;
 }
Example #12
0
        public static Dictionary<string, string> VictoryCard(int priceLimit, ISupply supply, string format = "Gain {0}", bool allowNullAction = false)
        {
            var buyableCards = from c in supply.AvailableCards
                               where (c.Price <= priceLimit) &&
                                       (supply.NumAvailable(c.ToString()) > 0) &&
                                       (c is ITreasureCard)
                               orderby c.Price
                               select c;

            return GetActionsHelper(format, allowNullAction, buyableCards);
        }
Example #13
0
        public static Card GainInHand(Dictionary<string, string> actions, IPlayer player, ISupply supply, string action)
        {
            Card c = null;
            string cardName = actions[action];

            if (cardName != "")
            {
                c = supply.Release(cardName);
                player.Hand.Add(c);
            }
            return c;
        }