Beispiel #1
0
        private void SavePlayer(int index)
        {
            if (index < 0)
            {
                return;
            }

            var player = SAV.Players[index];
            var pers   = player.Personal;

            if (pers.PlayerName != TB_Name.Text)
            {
                var orig = pers.GetPlayerIdentity();
                pers.PlayerName = TB_Name.Text;
                var updated = pers.GetPlayerIdentity();
                SAV.ChangeIdentity(orig, updated);
            }
            if (pers.TownName != TB_TownName.Text)
            {
                var orig = pers.GetTownIdentity();
                pers.TownName = TB_TownName.Text;
                var updated = pers.GetTownIdentity();
                SAV.ChangeIdentity(orig, updated);
            }

            var bank = pers.Bank;

            bank.Value = (uint)NUD_BankBells.Value;
            pers.Bank  = bank;

            var nook = pers.NookMiles;

            nook.Value     = (uint)NUD_NookMiles.Value;
            pers.NookMiles = nook;

            var tnook = pers.TotalNookMiles;

            tnook.Value         = (uint)NUD_TotalNookMiles.Value;
            pers.TotalNookMiles = tnook;

            var wallet = pers.Wallet;

            wallet.Value = (uint)NUD_Wallet.Value;
            pers.Wallet  = wallet;

            // swapped on purpose -- first count is the first two rows of items
            pers.PocketCount = (uint)NUD_PocketCount1.Value;
            pers.BagCount    = (uint)NUD_PocketCount2.Value;

            pers.ItemChestCount = (uint)NUD_StorageCount.Value;

            if (player.WhereAreN is { } x)
            {
                var poki = x.Poki;
                poki.Value = (uint)NUD_Poki.Value;
                x.Poki     = poki;
            }
        }
Beispiel #2
0
        private void SavePlayer(int index)
        {
            if (index < 0)
            {
                return;
            }

            var player = SAV.Players[index];
            var pers   = player.Personal;

            if (pers.PlayerName != TB_Name.Text)
            {
                var orig = pers.GetPlayerIdentity();
                pers.PlayerName = TB_Name.Text;
                var updated = pers.GetPlayerIdentity();
                SAV.ChangeIdentity(orig, updated);
            }
            if (pers.TownName != TB_TownName.Text)
            {
                var orig = pers.GetTownIdentity();
                pers.TownName = TB_TownName.Text;
                var updated = pers.GetTownIdentity();
                SAV.ChangeIdentity(orig, updated);
            }

            var bank = pers.Bank;

            bank.Value = (uint)NUD_BankBells.Value;
            pers.Bank  = bank;

            var nook = pers.NookMiles;

            nook.Value     = (uint)NUD_NookMiles.Value;
            pers.NookMiles = nook;

            var wallet = pers.Wallet;

            wallet.Value = (uint)NUD_Wallet.Value;
            pers.Wallet  = wallet;
        }
Beispiel #3
0
        private void UpdateCrossRefsPlayer(bool randomID, int playerNum = -1)
        {
            Random random = new Random();

            byte[] bytes = new byte[4];

            playerNum = playerNum == -1 ? (int)PlayerNum.Value : playerNum;

            Player player = _loaded.Players[playerNum];

            string oldName = player.Personal.PlayerName;
            string newName = PlayerName.Text;
            uint   oldId   = player.Personal.PlayerID;

            random.NextBytes(bytes);
            uint newId = randomID ? BitConverter.ToUInt32(bytes, 0) : oldId;

            string oldTown   = player.Personal.TownName;
            string newTown   = TownName.Text;
            uint   oldTownId = player.Personal.TownID;

            random.NextBytes(bytes);
            uint newTownId = randomID ? BitConverter.ToUInt32(bytes, 0) : oldTownId;

            byte[] oldPlayerIdentity = player.Personal.GetPlayerIdentity();
            byte[] oldTownIdentity   = player.Personal.GetTownIdentity();

            player.Personal.PlayerName = newName;
            player.Personal.PlayerID   = newId;

            player.Personal.TownName = newTown;
            player.Personal.TownID   = newTownId;

            byte[] newPlayerIdentity = player.Personal.GetPlayerIdentity();
            byte[] newTownIdentity   = player.Personal.GetTownIdentity();

            _loaded.ChangeIdentity(oldPlayerIdentity, newPlayerIdentity);
            _loaded.ChangeIdentity(oldTownIdentity, newTownIdentity);

            /*
             * I would much prefer if we could surgically replace the relevant IDs rather than find replace,
             * but they don't seem to be all covered yet. Maybe one day.
             * Just hope someone doesn't spell out your ID and name in a furniture arrangment or something.
             *
             * foreach (var villager in _villagers)
             * {
             *  var memories = villager.GetMemories();
             *
             *  foreach (var memory in memories)
             *  {
             *      if (memory.PlayerName == oldName && memory.PlayerID == oldId && memory.TownName == oldTown && memory.TownID == oldTownId)
             *      {
             *          memory.PlayerName = newName;
             *          memory.PlayerID = newId;
             *          memory.TownName = newTown;
             *          memory.TownID = newTownId;
             *      }
             *  }
             *
             *  villager.SetMemories(memories);
             * }
             *
             * _loaded.Main.SetVillagers(_villagers);
             *
             * foreach (var design in _designs)
             * {
             *  if (design.PlayerName == oldName && design.PlayerID == oldId && design.TownName == oldTown && design.TownID == oldTownId)
             *  {
             *      design.PlayerName = newName;
             *      design.PlayerID = newId;
             *      design.TownName = newTown;
             *      design.TownID = newTownId;
             *  }
             * }
             *
             * _loaded.Main.SetDesigns(_designs);
             *
             * foreach (var design in _pro)
             * {
             *  if (design.PlayerName == oldName && design.PlayerID == oldId && design.TownName == oldTown && design.TownID == oldTownId)
             *  {
             *      design.PlayerName = newName;
             *      design.PlayerID = newId;
             *      design.TownName = newTown;
             *      design.TownID = newTownId;
             *  }
             * }
             *
             * _loaded.Main.SetDesignsPRO(_pro);
             *
             * foreach (var design in _designsTailor)
             * {
             *  if (design.PlayerName == oldName && design.PlayerID == oldId && design.TownName == oldTown && design.TownID == oldTownId)
             *  {
             *      design.PlayerName = newName;
             *      design.PlayerID = newId;
             *      design.TownName = newTown;
             *      design.TownID = newTownId;
             *  }
             * }
             *
             * _loaded.Main.SetDesignsTailor(_designsTailor);
             *
             * for (int i = 0; i < _loaded.Players.Length; i++)
             * {
             *  if (i == playerNum) continue;
             *
             *  Player other = _loaded.Players[i];
             *
             *  other.Personal.TownName = newTown;
             *  other.Personal.TownID = newTownId;
             * }
             */
        }