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

            Element.Element("indoors").Element("uniqueName").Value = uniqueName;
            Farmhand.Element("homeLocation").Value = uniqueName;
        }
Exemplo n.º 2
0
 public void RemoveFarmhandFromStorage(Farmhand farmhand)
 {
     if (farmhand.InStorage)
     {
         farmhand.Cabin.Element.Remove();
     }
 }
Exemplo 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();
        }
Exemplo 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());
            }
        }
Exemplo 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...");
            }
        }
Exemplo 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);
        }
Exemplo 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();
         }
     }
 }
Exemplo n.º 8
0
 public void SwitchFarmhand(XElement farmhand)
 {
     Farmhand.ReplaceAll(farmhand.Nodes());
 }
Exemplo 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";
 }