Ejemplo n.º 1
0
        public void ReplaceCabinName()
        {
            var uniqueName = $"Cabin{Guid.NewGuid()}";

            Element.Element("indoors").Element("uniqueName").Value = uniqueName;
            Farmhand.Element("homeLocation").Value = uniqueName;
        }
Ejemplo n.º 2
0
 public void RemoveFarmhandFromStorage(Farmhand farmhand)
 {
     if (farmhand.InStorage)
     {
         farmhand.Cabin.Element.Remove();
     }
 }
Ejemplo n.º 3
0
        public void ReplaceMultiplayerId()
        {
            byte[] buffer = new byte[8];
            random.NextBytes(buffer);
            var uniqueMultiplayerId = BitConverter.ToInt64(buffer, 0);

            Farmhand
            .Element("UniqueMultiplayerID")
            .Value = uniqueMultiplayerId.ToString();
        }
Ejemplo n.º 4
0
        public void StoreFarmhand(Farmhand farmhand)
        {
            var element = _farmhands.FirstOrDefault(x => x.Element("name")?.Value == farmhand.Name);

            if (element == null)
            {
                _doc.Element("Farmhands").Add(farmhand.Cabin.Element);
            }
            else
            {
                element.ReplaceAll(farmhand.Cabin.Element.Nodes());
            }
        }
Ejemplo n.º 5
0
        public void RemoveCabin(XElement cabin)
        {
            var farmhand = new Farmhand(cabin, true, isCabin: true);

            if (farmhand.Name == null)
            {
                cabin.Remove();
            }
            else
            {
                var farmhands = new Farmhands(this);
                farmhands.StoreFarmhand(farmhand);
                Console.WriteLine("Storing backup of farmhand...");
            }
        }
Ejemplo n.º 6
0
        public bool AddFarmhand(Farmhand farmhand)
        {
            var cabin = _game.FindEmptyCabin();

            if (cabin == null)
            {
                cabin = _game.CreateNewCabin(farmhand.Cabin);
                if (cabin == null)
                {
                    return(false);
                }
            }
            cabin.SwitchCabin(farmhand.Cabin);
            farmhand.Cabin = cabin;
            RemoveFarmhandFromStorage(farmhand);
            return(true);
        }
Ejemplo n.º 7
0
 public void RemoveFarmhandFromCabin(Farmhand farmhand, bool storeFarmhand = true, bool removeCabin = false)
 {
     if (farmhand.InGame)
     {
         if (storeFarmhand)
         {
             StoreFarmhand(farmhand);
         }
         if (!removeCabin)
         {
             var newFarmhand = CreateBlankFarmhandElement();
             farmhand.Cabin.SwitchFarmhand(newFarmhand);
         }
         else
         {
             farmhand.Cabin.Element.Remove();
         }
     }
 }
Ejemplo n.º 8
0
 public void SwitchFarmhand(XElement farmhand)
 {
     Farmhand.ReplaceAll(farmhand.Nodes());
 }
Ejemplo n.º 9
0
 public void UpdateFarmhand(XElement host)
 {
     Farmhand.Element("farmName").Value    = host.Element("farmName").Value;
     Farmhand.Element("money").Value       = host.Element("money").Value;
     Farmhand.Element("slotCanHost").Value = "true";
 }