Beispiel #1
0
        public void Card_AgricultureAction1()
        {
            //testGame.Players[0].AlwaysParticipates = true;
            //testGame.Players[0].SelectsCards = new List<int>() { 0 };

            bool result = new Agriculture().Actions.ToList()[0].ActionHandler(new CardActionParameters {
                TargetPlayer = testGame.Players[0], Game = testGame, ActivePlayer = testGame.Players[0], PlayerSymbolCounts = new Dictionary <IPlayer, Dictionary <Symbol, int> >()
            });

            Assert.AreEqual(true, result);

            Assert.AreEqual(2, testGame.Players[0].Hand.Count);
            Assert.AreEqual(4, testGame.AgeDecks.Where(x => x.Age == 1).FirstOrDefault().Cards.Count);
            Assert.AreEqual(2, testGame.AgeDecks.Where(x => x.Age == 2).FirstOrDefault().Cards.Count);

            Assert.AreEqual(1, testGame.Players[0].Tableau.ScorePile.Count);
            Assert.AreEqual(2, testGame.Players[0].Tableau.GetScore());
            Assert.AreEqual(0, testGame.Players[1].Tableau.ScorePile.Count);

            Assert.AreEqual(1, testGame.Players[0].Tableau.Stacks[Color.Blue].Cards.Count);
            Assert.AreEqual(0, testGame.Players[0].Tableau.Stacks[Color.Green].Cards.Count);
            Assert.AreEqual(1, testGame.Players[0].Tableau.Stacks[Color.Red].Cards.Count);
            Assert.AreEqual(0, testGame.Players[0].Tableau.Stacks[Color.Purple].Cards.Count);
            Assert.AreEqual(0, testGame.Players[0].Tableau.Stacks[Color.Yellow].Cards.Count);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Agriculture agriculture = db.Agricultures.Find(id);

            db.Agricultures.Remove(agriculture);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Variable,AgricultureIndex,AgricultureNumber,Date,AreaId")] Agriculture agriculture)
 {
     if (ModelState.IsValid)
     {
         db.Entry(agriculture).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(agriculture));
 }
        public ActionResult Create([Bind(Include = "Id,Variable,AgricultureIndex,AgricultureNumber,Date,AreaId")] Agriculture agriculture)
        {
            if (ModelState.IsValid)
            {
                db.Agricultures.Add(agriculture);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(agriculture));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Agriculture agriculture = db.Agricultures.Find(id);

            if (agriculture == null)
            {
                return(HttpNotFound());
            }
            return(View(agriculture));
        }
Beispiel #6
0
        public ActionResult AgricultureSave(List <string> agriArr)
        {
            Agriculture agriculture = new Agriculture();

            var userIdentity = db.Users.FirstOrDefault(p => p.Email == User.Identity.Name);
            var area         = db.Areas.FirstOrDefault(p => p.UserId == userIdentity.Id);

            agriculture.AreaId            = area.Id;
            agriculture.Variable          = agriArr[0];
            agriculture.Date              = Convert.ToDateTime(agriArr[1]);
            agriculture.AgricultureIndex  = Convert.ToInt32(agriArr[2]);
            agriculture.AgricultureNumber = Convert.ToInt32(agriArr[3]);

            db.Agricultures.Add(agriculture);
            db.SaveChanges();
            return(RedirectToAction("Application"));
        }
Beispiel #7
0
        /*
         * CR-1 - add comments to method, get rid of redundant namespace qualifier in argument type
         */
        protected override void Seed(FarmApp.DAL.EF.FarmContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            using (var transaction = context.Database.BeginTransaction())
            {
                try
                {
                    /*
                     * CR-1 - fix encoding of test data
                     */
                    var msk = new Region()
                    {
                        Name = "Сочи"
                    };
                    var psb = new Region()
                    {
                        Name = "Краснодар"
                    };

                    context.Regions.AddOrUpdate(x => x.Name, msk);
                    context.Regions.AddOrUpdate(x => x.Name, psb);

                    var rye = new Agriculture()
                    {
                        Name = "Рожь"
                    };
                    var wheat = new Agriculture()
                    {
                        Name = "Пшеница"
                    };

                    context.Agricultures.AddOrUpdate(x => x.Name, rye);
                    context.Agricultures.AddOrUpdate(x => x.Name, wheat);

                    var vasya = new Farmer()
                    {
                        Name = "Василий Петрович"
                    };

                    var parfen = new Farmer()
                    {
                        Name = "Парфён Семёнович"
                    };

                    context.Farmers.AddOrUpdate(x => x.Name, vasya);
                    context.Farmers.AddOrUpdate(x => x.Name, parfen);

                    context.SaveChanges();

                    var smallFarm = new Farm()
                    {
                        Name = "Сочинская ферма Василия Петровича", Area = 100, FarmerId = vasya.Id, RegionId = msk.Id
                    };

                    var bigFarm = new Farm()
                    {
                        Name = "ЗАО Краснодарский совхоз Парфёна", Area = 600, FarmerId = parfen.Id, RegionId = psb.Id
                    };

                    context.Farms.AddOrUpdate(x => x.Name, smallFarm);
                    context.Farms.AddOrUpdate(x => x.Name, bigFarm);

                    context.SaveChanges();

                    var cropRyeSmallFarm = new Crop()
                    {
                        AgricultureId = rye.Id, FarmId = smallFarm.Id, Gather = 250
                    };
                    var cropWheatSmallFarm = new Crop()
                    {
                        AgricultureId = wheat.Id, FarmId = smallFarm.Id, Gather = 139
                    };
                    var cropRyeBigFarm = new Crop()
                    {
                        AgricultureId = rye.Id, FarmId = bigFarm.Id, Gather = 1100
                    };
                    var cropWheatBigFarm = new Crop()
                    {
                        AgricultureId = wheat.Id, FarmId = bigFarm.Id, Gather = 900
                    };

                    context.Crops.AddOrUpdate(x => new { x.AgricultureId, x.FarmId }, cropRyeSmallFarm);
                    context.Crops.AddOrUpdate(x => new { x.AgricultureId, x.FarmId }, cropWheatSmallFarm);
                    context.Crops.AddOrUpdate(x => new { x.AgricultureId, x.FarmId }, cropRyeBigFarm);
                    context.Crops.AddOrUpdate(x => new { x.AgricultureId, x.FarmId }, cropWheatBigFarm);


                    context.SaveChanges();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                }
            }
        }
Beispiel #8
0
    void Update()
    {
        bool beginToSelect = Agriculture.beginToSelect;

        if ((beginToSelect) && (!DialogUI.panelTouched) && (!finishedSelecting))
        {
            startScreenPos = Agriculture.TouchToPos(Agriculture.farmCorner1);
            Debug.Log("startscreenpos : " + startScreenPos.ToString());
            waitTime++;

            if ((Player_script.VerifyTouch()) && (waitTime > 200))
            {
                Touch touch = Player_script.ImportTouch();

                if (touch.phase == TouchPhase.Ended)
                {
                    selectionBox.gameObject.SetActive(false);
                    finishedSelecting = true;
                    endPos            = touch;
                }
                else
                {
                    Vector3 pos = Agriculture.TouchToPos(touch);

                    float x0 = MiseEchelleCanvas(startScreenPos.x, canvas);
                    float x1 = MiseEchelleCanvas(pos.x, canvas);
                    float y0 = MiseEchelleCanvas(-startScreenPos.z, canvas);
                    float y1 = MiseEchelleCanvas(-pos.z, canvas);

                    if (x0 <= x1)
                    {
                        if (y0 <= y1)
                        {
                            rt.anchorMin = new Vector2(x0, y0);
                            rt.anchorMax = new Vector2(x1, y1);
                        }
                        else
                        {
                            rt.anchorMin = new Vector2(x0, y1);
                            rt.anchorMax = new Vector2(x1, y0);
                        }
                    }
                    else
                    {
                        if (y0 <= y1)
                        {
                            rt.anchorMin = new Vector2(x1, y0);
                            rt.anchorMax = new Vector2(x0, y1);
                        }
                        else
                        {
                            rt.anchorMin = new Vector2(x1, y1);
                            rt.anchorMax = new Vector2(x0, y0);
                        }
                    }

                    rt.sizeDelta = new Vector2(1f, 1f);

                    selectionBox.gameObject.SetActive(true);
                    Debug.Log("Mise à jour sélection");
                }
            }
        }
    }
 public AgricultureManage(Agriculture agriculture)
 {
     this.agriculture = agriculture;
 }