Ejemplo n.º 1
0
        public HttpResponseMessage EditWell(int id, [FromBody] Well newWell)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Все поля должны быть заполнены"));
            }
            try
            {
                Well well = Wells.Find(w => w.Id == id);
                if (well == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Скважина с ID = " + id.ToString() + "не найдена"));
                }
                else
                {
                    well.Name          = newWell.Name;
                    well.Group         = newWell.Group;
                    well.Field         = newWell.Field;
                    well.Factory       = newWell.Factory;
                    well.ControllerId  = newWell.ControllerId;
                    well.OperationType = newWell.OperationType;

                    return(Request.CreateResponse(HttpStatusCode.OK, well));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Ejemplo n.º 2
0
 public HttpResponseMessage CreateWell([FromBody] Well well)
 {
     if (!ModelState.IsValid)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Все поля должны быть заполнены"));
     }
     try
     {
         int ID;
         if (Wells.Count == 0)
         {
             ID = 1;
         }
         else
         {
             ID = Wells.Max(w => w.Id) + 1;
         }
         well.Id = ID;
         Wells.Add(well);
         var message = Request.CreateResponse(HttpStatusCode.Created, well);
         message.Headers.Location = new Uri(Request.RequestUri + well.Id.ToString());
         return(message);
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Ejemplo n.º 3
0
 public IActionResult Create([FromBody] Wells item)
 {
     using (var context = GetContext())
     {
         if (item == null)
         {
             return(BadRequest());
         }
         context.Wells.Add(item);
         context.SaveChanges();
     }
     return(CreatedAtRoute("getWellsFromField", new { id = item.FkFieldsId }, item));
 }
Ejemplo n.º 4
0
 public IActionResult Update(int id, [FromBody] Wells item)
 {
     using (var context = GetContext())
     {
         var wellItem = (from well in context.Wells
                         where well.Id == id
                         select well).First();
         wellItem.Name       = item.Name;
         wellItem.FkFieldsId = item.FkFieldsId;
         context.Wells.Update(wellItem);
         context.SaveChanges();
     }
     return(new NoContentResult());
 }
Ejemplo n.º 5
0
        public void CreateWellsTestApi()
        {
            var   testcontroller = new WellsControllerMock();
            Wells well           = new Wells()
            {
                Id         = 2,
                FkFieldsId = 1
            };

            var result = testcontroller.Create(well);

            Assert.IsType <CreatedAtRouteResult>(result);
            Assert.Equal("getWellsFromField", ((CreatedAtRouteResult)result).RouteName);
            Assert.NotNull(((CreatedAtRouteResult)result).RouteValues["id"]);
        }
Ejemplo n.º 6
0
        public void UpdateWellsTestApi()
        {
            var testcontroller = new WellsControllerMock();

            Wells well = new Wells()
            {
                Id         = 2,
                Name       = "test",
                FkFieldsId = 1
            };

            var result = testcontroller.Update(2, well);

            Assert.IsType <NoContentResult>(result);
        }
Ejemplo n.º 7
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Wells.Add(new Models.Well {
                Id = 1, Name = "Скважина1", Group = "Куст1", Field = "Качканар", Factory = "Завод1", ControllerId = 1, OperationType = OperationTypeEnum.ГПШГН
            });
            Wells.Add(new Models.Well {
                Id = 2, Name = "Скважина2", Group = "Куст2", Field = "Пермь", Factory = "Завод2", ControllerId = 2, OperationType = OperationTypeEnum.ЭВН
            });
            Wells.Add(new Models.Well {
                Id = 3, Name = "Скважина3", Group = "Куст3", Field = "Луганск", Factory = "Завод3", ControllerId = 3, OperationType = OperationTypeEnum.ЭЦН
            });
        }
Ejemplo n.º 8
0
 // DELETE api/wells/id
 public HttpResponseMessage DeleteWell(int id)
 {
     try
     {
         Well well = Wells.Find(w => w.Id == id);
         if (well == null)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Скважина с ID = " + id.ToString() + "не найдена"));
         }
         else
         {
             Wells.Remove(well);
             return(Request.CreateResponse(HttpStatusCode.OK));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Ejemplo n.º 9
0
    public void WriteToFile(string filename)
    {
        Debug.Log("Beginning SaveTheGame");
        string path = System.IO.Directory.GetCurrentDirectory();

        using (System.IO.StreamWriter file =
                   new System.IO.StreamWriter(path + filename + ".txt"))
        {
            int      index         = (int)PhotonNetwork.CurrentRoom.CustomProperties["CurrentPlayerIndex"];
            string[] players       = (string[])PhotonNetwork.CurrentRoom.CustomProperties["Players"];
            int      gameSize      = (int)PhotonNetwork.CurrentRoom.CustomProperties["GameSize"];
            int      narratorPos   = (int)PhotonNetwork.CurrentRoom.CustomProperties["NarratorPosition"];
            int      numMonsters   = (int)PhotonNetwork.CurrentRoom.CustomProperties["MonstersAtCastle"];
            int      numFarmers    = (int)PhotonNetwork.CurrentRoom.CustomProperties["FarmersAtCastle"];
            bool     herbsAtCastle = (bool)PhotonNetwork.CurrentRoom.CustomProperties["HerbAtCastle"];
            bool     skralDefeated = (bool)PhotonNetwork.CurrentRoom.CustomProperties["SkralAtCastleDefeated"];
            file.WriteLine(index.ToString());
            file.WriteLine(narratorPos.ToString());
            file.WriteLine(numMonsters.ToString());
            file.WriteLine(numFarmers.ToString());
            file.WriteLine(herbsAtCastle.ToString());
            file.WriteLine(skralDefeated.ToString());
            foreach (Player p in PhotonNetwork.PlayerList)
            {
                string type        = (string)p.CustomProperties["Type"];
                int    pos         = (int)p.CustomProperties["pos"];
                int    hours       = (int)p.CustomProperties["Hours"];
                int    wp          = (int)p.CustomProperties["wp"];
                int    sp          = (int)p.CustomProperties["sp"];
                int    farmer      = (int)p.CustomProperties["farmer"];
                int    gold        = (int)p.CustomProperties["gold"];
                bool   herb        = (bool)p.CustomProperties["herb"];
                int    wineskin    = (int)p.CustomProperties["wineskin"];
                int    shield      = (int)p.CustomProperties["shield"];
                int    falcon      = (int)p.CustomProperties["falcon"];
                int    telescope   = (int)p.CustomProperties["telescope"];
                int    bow         = (int)p.CustomProperties["bow"];
                int    helm        = (int)p.CustomProperties["helm"];
                int    brew        = (int)p.CustomProperties["brew"];
                int    yellowStone = (int)p.CustomProperties["yellowStone"];
                int    blueStone   = (int)p.CustomProperties["blueStone"];
                int    greenStone  = (int)p.CustomProperties["greenStone"];

                string ln = type + "\t" + pos + "\t" + hours + "\t" + wp + "\t" + sp + "\t" + farmer + "\t" + gold + "\t" + herb + "\t" + wineskin + "\t" + shield + "\t" + falcon + "\t" + telescope + "\t" + bow + "\t" + helm + "\t" + brew + "\t" + yellowStone + "\t" + blueStone + "\t" + greenStone;
                file.WriteLine(ln);
            }
            GameObject[] monsters = GameObject.FindGameObjectsWithTag("Monster");
            foreach (GameObject obj in monsters)
            {
                Monster m = obj.GetComponent <Monster>();
                file.WriteLine(m.type + "\t" + m.pos);
            }
            GameObject[] wells = GameObject.FindGameObjectsWithTag("Well");
            foreach (GameObject obj in wells)
            {
                Wells w = obj.GetComponent <Wells>();
                file.WriteLine("well" + "\t" + w.pos + "\t" + w.wellStatus.ToString());
            }
            GameObject[] fogs = GameObject.FindGameObjectsWithTag("Fog");
            foreach (GameObject obj in fogs)
            {
                GameBoardRegion regionWithFog = obj.GetComponent <GameBoardRegion>();
                file.WriteLine("fog" + "\t" + regionWithFog.num);
            }
            string line = "";
            foreach (string f in UnFlippedFog.fogOutcomes)
            {
                line = line + f + "\t";
            }
            file.WriteLine(line);
            GameObject[] golds = GameObject.FindGameObjectsWithTag("GoldToken");
            foreach (GameObject obj in golds)
            {
                GoldToken g = obj.GetComponent <GoldToken>();
                file.WriteLine("gold" + "\t" + g.pos + "\t" + g.amt);
            }
            GameObject[] yellow = GameObject.FindGameObjectsWithTag("RuneStoneYellow");
            foreach (GameObject obj in yellow)
            {
                RuneStone r = obj.GetComponent <RuneStone>();
                file.WriteLine("yellow" + "\t" + r.pos);
            }
            GameObject[] green = GameObject.FindGameObjectsWithTag("RuneStoneGreen");
            foreach (GameObject obj in green)
            {
                RuneStone r = obj.GetComponent <RuneStone>();
                file.WriteLine("green" + "\t" + r.pos);
            }
            GameObject[] blue = GameObject.FindGameObjectsWithTag("RuneStoneBlue");
            foreach (GameObject obj in blue)
            {
                RuneStone r = obj.GetComponent <RuneStone>();
                file.WriteLine("blue" + "\t" + r.pos);
            }
            GameObject[] farmers = GameObject.FindGameObjectsWithTag("Farmer");
            foreach (GameObject obj in farmers)
            {
                Farmer f = obj.GetComponent <Farmer>();
                file.WriteLine("farmer" + "\t" + f.pos);
            }
            GameObject herbToken = GameObject.Find("Herb");
            if (herbToken == null)
            {
                herbToken = GameObject.Find("Herb(Clone)");
            }
            else
            {
                file.WriteLine("herb" + "\t" + herbToken.GetComponent <HerbController>().pos);
            }
            GameObject witch = GameObject.Find("WitchBrew");
            if (witch == null)
            {
                witch = GameObject.Find("WitchBrew(Clone)");
            }
            else
            {
                file.WriteLine("witch" + "\t" + witch.GetComponent <WitchBrewController>().pos);
            }
            Debug.Log("Closing Stream Writer");

            file.Close();
        }
    }
Ejemplo n.º 10
0
 public void Clear()
 {
     Wells.Clear();
     Indexes.Clear();
 }
Ejemplo n.º 11
0
        // GET api/wells
        //public IEnumerable<Well> SearchWells(int id, int controllerId, Well.OperationTypeEnum operationType)
        //{
        //    if ((id.ToString() != null && id.ToString() != "") || (controllerId.ToString() != null
        //        && controllerId.ToString() != "") || (operationType != 0))
        //    {
        //        var select = from wells in Wells select wells;
        //        if (id.ToString() != null && id.ToString() != "")
        //        {
        //            select = from wells in @select
        //                     where wells.Id == id
        //                     select wells;
        //        }
        //        if (controllerId.ToString() != null && controllerId.ToString() != "")
        //        {
        //            select = from wells in @select
        //                     where wells.ControllerId == controllerId
        //                     select wells;
        //        }
        //        if (operationType != 0)
        //        {
        //            select = from wells in @select
        //                     where wells.OperationType == operationType
        //                     select wells;
        //        }
        //        List<Well> wellSearchResult = select.ToList();
        //        return wellSearchResult;
        //    }
        //    else
        //    {
        //        return Wells;
        //    }
        //}

        // GET api/wells/id


        public Well GetWell(int id)
        {
            return(Wells.FirstOrDefault(w => w.Id == id));
        }
Ejemplo n.º 12
0
 public List <string> FilterFields(string area)
 {
     string[] fields = Wells.Where(x => (area == ALL) || (area == x.Area)).Select(x => x.Field).Distinct().ToArray();
     return(SortedItems(new HashSet <string>(fields)));
 }
Ejemplo n.º 13
0
 public List <string> FilterAreas(string country)
 {
     string[] areas = Wells.Where(x => (country == ALL) || (country == x.Country)).Select(x => x.Area).Distinct().ToArray();
     return(SortedItems(new HashSet <string>(areas)));
 }
Ejemplo n.º 14
0
 public List <Well> FilterWells(string country, string area, string field)
 {
     return(Wells.Where(x => ((area == ALL) || (area == x.Area)) && ((field == ALL) || (field == x.Field)) && ((country == ALL) || (country == x.Country))).ToList());
 }
Ejemplo n.º 15
0
    private void OnMouseDown()
    {
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (hero.canMove(num))
            {
                //otherwise, update position to region that was clicked on
                hero.updatePos(s_Collider.bounds.center);
                hero.updateRegion(num);
                if (GameObject.Find("Region36") == null)
                {
                    return;                                         //game is over and board has been set inactive
                }
                PolygonCollider2D collide36 = GameObject.Find("Region36").GetComponent <PolygonCollider2D>();
                PolygonCollider2D collide42 = GameObject.Find("Region42").GetComponent <PolygonCollider2D>();
                PolygonCollider2D collide38 = GameObject.Find("Region38").GetComponent <PolygonCollider2D>();
                PolygonCollider2D collide44 = GameObject.Find("Region44").GetComponent <PolygonCollider2D>();
                //can drop off a farmer
                if (num == 0 && (int)PhotonNetwork.LocalPlayer.CustomProperties["farmer"] > 0)
                {
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);
                    dropFarmerYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    dropFarmerYesButton.onClick.AddListener(() => ExecuteDropFarmer());
                    dropFarmerNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    setActiveTrue(dropFarmerPopup, 4);
                }

                if (num == 0 && (bool)PhotonNetwork.LocalPlayer.CustomProperties["herb"])
                { //at castle with herb
                    ExecuteDropHerb();
                }

                //if witch brew exists and is on that region
                GameObject brew = GameObject.Find("WitchBrew");
                if (brew == null)
                {
                    brew = GameObject.Find("WitchBrew(Clone)");
                }
                if (brew != null && brew.GetComponent <WitchBrewController>().pos == this.num)
                {
                    int gold      = (int)PhotonNetwork.LocalPlayer.CustomProperties["gold"];
                    int nbPlayers = (int)PhotonNetwork.CurrentRoom.CustomProperties["GameSize"];
                    if (gold >= nbPlayers + 1)
                    { //if they have enough gold to buy brew
                        //do pop up for picking up witches brew
                        collide36.gameObject.SetActive(false);
                        collide42.gameObject.SetActive(false);
                        collide38.gameObject.SetActive(false);
                        collide44.gameObject.SetActive(false);
                        pickBrewYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                        pickBrewYesButton.onClick.AddListener(() => ExecuteBuyBrew(brew, gold, nbPlayers + 1));
                        pickBrewNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                        setActiveTrue(pickBrewPopup, 4);
                    }
                }

                GameObject herb = GameObject.Find("Herb");
                if (herb == null)
                {
                    herb = GameObject.Find("Herb(Clone)");
                }
                if (herb != null && herb.GetComponent <HerbController>().pos == this.num)
                {
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);
                    pickHerbYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    pickHerbYesButton.onClick.AddListener(() => ExecutePickupHerb(herb));
                    pickHerbNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    setActiveTrue(pickHerbPopup, 4);
                }

                //check for runestones
                GameObject[] stones2   = GameObject.FindGameObjectsWithTag("RuneStoneBlue");
                GameObject   stoneBlue = Array.Find(stones2, f => f.GetComponent <RuneStone>().pos == num);
                if (stoneBlue != null && stoneBlue.GetComponent <RuneStone>().pos == this.num)
                {
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);
                    pickStoneYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    pickStoneYesButton.onClick.AddListener(() => ExecutePickupStone(stoneBlue, "blue"));
                    pickStoneNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    setActiveTrue(pickStonePopup, 4);
                }

                GameObject[] stones      = GameObject.FindGameObjectsWithTag("RuneStoneYellow");
                GameObject   stoneYellow = Array.Find(stones, f => f.GetComponent <RuneStone>().pos == num);

                if (stoneYellow != null && stoneYellow.GetComponent <RuneStone>().pos == this.num)
                {
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);
                    pickStoneYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    pickStoneYesButton.onClick.AddListener(() => ExecutePickupStone(stoneYellow, "yellow"));
                    pickStoneNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    setActiveTrue(pickStonePopup, 4);
                }

                GameObject[] stones3    = GameObject.FindGameObjectsWithTag("RuneStoneGreen");
                GameObject   stoneGreen = Array.Find(stones3, f => f.GetComponent <RuneStone>().pos == num);
                if (stoneGreen == null)
                {
                    stoneGreen = GameObject.Find("RuneStoneGreen(Clone)");
                }
                if (stoneGreen != null && stoneGreen.GetComponent <RuneStone>().pos == this.num)
                {
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);
                    pickStoneYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    pickStoneYesButton.onClick.AddListener(() => ExecutePickupStone(stoneGreen, "green"));
                    pickStoneNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    setActiveTrue(pickStonePopup, 4);
                }

                //at a well
                if (num == 5 || num == 35 || num == 45 || num == 55)
                {
                    List <GameObject> wells    = new List <GameObject>(GameObject.FindGameObjectsWithTag("Well"));
                    Wells             thisWell = null;
                    foreach (GameObject w in wells)
                    {
                        Wells temp = w.GetComponent <Wells>();
                        if (temp.pos == num && temp.wellFull.activeSelf)
                        {
                            thisWell = temp;
                        }
                    }
                    if (thisWell != null)
                    {
                        PhotonView wellView = thisWell.gameObject.GetPhotonView();
                        setActiveTrue(wellPopup, 4);
                        collide36.gameObject.SetActive(false);
                        collide42.gameObject.SetActive(false);
                        collide38.gameObject.SetActive(false);
                        collide44.gameObject.SetActive(false);
                        yesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                        yesButton.onClick.AddListener(() => wellView.RPC("DrinkWell", RpcTarget.AllBuffered, (int)PhotonNetwork.CurrentRoom.CustomProperties["CurrentPlayerIndex"]));
                        noButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    }
                }

                //at a store
                else if (num == 18 || num == 71 || num == 57)
                {
                    PhotonNetwork.AutomaticallySyncScene = false;
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);
                    storeYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    storeNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    setActiveTrue(storePopup, 4);
                }

                // check for gold
                GameObject[] golds     = GameObject.FindGameObjectsWithTag("GoldToken");
                GameObject   foundGold = Array.Find(golds, f => f.GetComponent <GoldToken>().pos == num);
                if (foundGold != null)
                {
                    Debug.Log("Gold PhotonView: " + foundGold.GetPhotonView());
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);
                    pickGoldYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    pickGoldYesButton.onClick.AddListener(() => ExecutePickupGold(foundGold));
                    pickGoldNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    setActiveTrue(pickGoldPopup, 4);
                }

                // check for farmer
                GameObject[] farmers = GameObject.FindGameObjectsWithTag("Farmer");
                GameObject   found   = Array.Find(farmers, f => f.GetComponent <Farmer>().pos == num);
                if (found != null)
                {
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);
                    farmerYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    farmerYesButton.onClick.AddListener(() => ExecutePickupFarmer(found));
                    farmerNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    setActiveTrue(farmerPopup, 4);
                }

                //check for monster
                GameObject[] monsters = GameObject.FindGameObjectsWithTag("Monster");
                GameObject   g        = Array.Find(monsters, m => m.GetComponent <Monster>().pos == num);
                bool         onRegion = true;

                if ((string)PhotonNetwork.LocalPlayer.CustomProperties["Type"] == "Archer" && g == null)
                {
                    //check for adj regions
                    onRegion = false;
                    int[] adjRegions = Graph.getAdjRegions(this.num);
                    foreach (int r in adjRegions)
                    {
                        g = Array.Find(monsters, m => m.GetComponent <Monster>().pos == r);
                        if (g != null)
                        {
                            break;
                        }
                    }
                }
                else if ((int)PhotonNetwork.LocalPlayer.CustomProperties["bow"] > 0 && g == null)
                {
                    onRegion = false;
                    int[] adjRegions = Graph.getAdjRegions(this.num);
                    foreach (int r in adjRegions)
                    {
                        g = Array.Find(monsters, m => m.GetComponent <Monster>().pos == r);
                        if (g != null)
                        {
                            Debug.Log("Using a Bow");
                            break;
                        }
                    }
                }

                if (g != null && num != 0)
                {
                    if ((int)PhotonNetwork.LocalPlayer.CustomProperties["farmer"] > 0 && onRegion)
                    {
                        PhotonHashtable h = new PhotonHashtable();
                        h.Add("farmer", 0);
                        PhotonNetwork.LocalPlayer.SetCustomProperties(h);
                        Debug.Log("farmer(s) died because on same space as monster");
                    }

                    Monster monst = g.GetComponent <Monster>();
                    PhotonNetwork.AutomaticallySyncScene = false;
                    GameObject fightController = GameObject.Find("FightController");
                    if (fightController == null)
                    {
                        fightController = GameObject.Find("FightController(Clone)");
                    }
                    collide36.gameObject.SetActive(false);
                    collide42.gameObject.SetActive(false);
                    collide38.gameObject.SetActive(false);
                    collide44.gameObject.SetActive(false);

                    /*
                     * fightYesButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                     */
                    if (!onRegion && !((string)PhotonNetwork.LocalPlayer.CustomProperties["Type"]).Equals("Archer"))
                    {
                        fightYesButton.onClick.AddListener(() => UseBow());
                    }
                    fightYesButton.onClick.AddListener(() => setActiveTrue(inviteToFightPopup, 4));
                    fightYesButton.onClick.AddListener(() => fightController.GetPhotonView().RPC("AddToFight", RpcTarget.AllBuffered, hero.type));
                    fightNoButton.onClick.AddListener(() => StartCoroutine(SetRegionsToTrue(collide36, collide42, collide38, collide44)));
                    inviteYesButton.onClick.AddListener(() => fightController.GetComponent <Fight>().InviteFighters(g, monst.type, this.num, hero.type));
                    inviteNoButton.onClick.AddListener(() => fightController.GetComponent <Fight>().InitializeFight(g, monst.type, this.num, hero.type));
                    //joinYesButton.onClick.AddListener(() => fightController.GetComponent<Fight>().InitializeFight(monst.type, this.num, ""));


                    setActiveTrue(fightPopup, 4);
                    // SHOULD WE ADD THIS?: fightPopup.GetComponent<TextMeshProUGUI>().text = "Would you like to use a bow \nto fight the monster on the adjacent space?";
                }

                int i = (int)PhotonNetwork.CurrentRoom.CustomProperties["CurrentPlayerIndex"];
                Debug.Log("Hero at " + (int)PhotonNetwork.PlayerList[i].CustomProperties["Hours"] + " hours");
                if ((int)PhotonNetwork.PlayerList[i].CustomProperties["Hours"] >= 10)
                {
                    hero.endTurn(); //if out of hours, set turn to next player
                }
            }
        }
    }