public void OnRemoveListViewItem(object sender, PokeblockCaseEventArgs e) { if (e.Index == selectedIndex) { selectedBlock = null; selectedIndex = -1; } blockCase.ListViewItems.RemoveAt(e.Index); UpdateDetails(); }
private void OnItemListSelectionChanged(object sender, SelectionChangedEventArgs e) { int index = listViewItems.SelectedIndex; if (index < blockCase.SlotsUsed) { if (index != -1) { selectedIndex = index; } selectedBlock = blockCase.GetPokeblockAt(selectedIndex); if (selectedIndex != -1) { labelPokeblockName.Content = selectedBlock.Color.ToString() + " Pokéblock"; imagePokeblock.Source = ItemDatabase.GetPokeblockImageFromColor(selectedBlock.Color, true); labelLevel.Content = selectedBlock.Level.ToString(); labelFeel.Content = selectedBlock.Feel.ToString(); labelLevelText.Content = "Level"; labelFeelText.Content = "Feel"; stackPanelFlavors1.Children.Clear(); stackPanelFlavors2.Children.Clear(); List <PokeblockFlavor> flavors = new List <PokeblockFlavor>(); flavors.Add(new PokeblockFlavor(PokeblockColors.Red, selectedBlock.Spicyness)); flavors.Add(new PokeblockFlavor(PokeblockColors.Blue, selectedBlock.Dryness)); flavors.Add(new PokeblockFlavor(PokeblockColors.Pink, selectedBlock.Sweetness)); flavors.Add(new PokeblockFlavor(PokeblockColors.Green, selectedBlock.Bitterness)); flavors.Add(new PokeblockFlavor(PokeblockColors.Yellow, selectedBlock.Sourness)); flavors.Sort((flavor1, flavor2) => (int)flavor2.Amount - (int)flavor1.Amount); foreach (PokeblockFlavor flavor in flavors) { if (flavor.Amount != 0) { AddFlavor(flavor.Flavor, flavor.Amount); } } } else { labelPokeblockName.Content = ""; labelLevel.Content = ""; labelFeel.Content = ""; labelLevelText.Content = ""; labelFeelText.Content = ""; imagePokeblock.Source = null; stackPanelFlavors1.Children.Clear(); stackPanelFlavors2.Children.Clear(); } } }
private void SavePokeblockCase(int index) { for (int i = 0; i < (int)parent.Inventory.Pokeblocks.TotalSlots; i++) { if (i < (int)parent.Inventory.Pokeblocks.SlotsUsed) { Pokeblock pokeblock = parent.Inventory.Pokeblocks.GetPokeblockAt(i); raw[index + i * 8] = (byte)pokeblock.Color; raw[index + i * 8 + 1] = pokeblock.Spicyness; raw[index + i * 8 + 2] = pokeblock.Dryness; raw[index + i * 8 + 3] = pokeblock.Sweetness; raw[index + i * 8 + 4] = pokeblock.Bitterness; raw[index + i * 8 + 5] = pokeblock.Sourness; raw[index + i * 8 + 6] = pokeblock.Feel; raw[index + i * 8 + 7] = pokeblock.Unknown; } else { LittleEndian.WriteUInt64(0, raw, index + i * 8); } } }
private static bool IsValidPokeBlockNature(uint seed, uint nature, out uint natureOrigin) { if (nature % 6 == 0) // neutral { natureOrigin = 0; return(false); } // unroll the RNG to a stack of seeds var stack = new Stack <uint>(); for (uint i = 0; i < 25; i++) { for (uint j = 1 + i; j < 25; j++) { stack.Push(seed = RNG.LCRNG.Prev(seed)); } } natureOrigin = RNG.LCRNG.Prev(stack.Peek()); if (natureOrigin >> (16 % 100) >= 80) // failed proc { return(false); } // init natures uint[] natures = new uint[25]; for (uint i = 0; i < 25; i++) { natures[i] = i; } // shuffle nature list for (uint i = 0; i < 25; i++) { for (uint j = 1 + i; j < 25; j++) { var s = stack.Pop(); if (((s >> 16) & 1) == 0) { continue; // only swap if 1 } (natures[i], natures[j]) = (natures[j], natures[i]); } } var likes = Pokeblock.GetLikedBlockFlavor(nature); // best case scenario is a perfect flavored pokeblock for the nature. // has liked flavor, and all other non-disliked flavors are present. // is it possible to skip this step? for (int i = 0; i < 25; i++) { var n = natures[i]; if (n == nature) { break; } var nl = Pokeblock.GetLikedBlockFlavor(natures[i]); if (nl == likes) // next random nature likes the same block as the desired nature { return(false); // current nature is chosen instead, fail! } } // unroll once more to hit the level calc (origin with respect for beginning the nature calcs) natureOrigin = RNG.LCRNG.Prev(natureOrigin); return(true); }