public void UpdatePassword_LocationIndex(int locationIndex) { char characterCode = CharacterCode.IndexToChar(locationIndex); passwordString[24] = characterCode; passwordUI.Invalidate(); }
ExpectedChecksum GetExpectedChecksum() { ExpectedChecksum result = new ExpectedChecksum(); string str = new string(passwordString); string line1 = str.Substring(0, 12); string line2 = str.Substring(12, 12); string line3 = str.Substring(24, 12); string inventory = str.Substring(36, 12); byte checksum1 = GetChecksumComponent(line1); byte checksum2 = GetChecksumComponent(line2); int expectedPartyChecksum = (checksum1 + checksum2) % 32; result.ExpectedPartyChecksum = CharacterCode.IndexToChar(expectedPartyChecksum); string eventInfo = line3.Substring(0, 9); int eventChecksum = GetChecksumComponent(eventInfo) % 32; result.ExpectedEventChecksum = CharacterCode.IndexToChar(eventChecksum); int inventoryChecksum = GetChecksumComponent(inventory) % 32; result.ExpectedInventoryChecksum = CharacterCode.IndexToChar(inventoryChecksum); return(result); }
public void UpdatePassword_Lines1And2(bool enabled, int desiredLevel, int weaponIndex, int armorIndex, int passwordStartIndex) { if (weaponIndex == -1 || armorIndex == -1) { return; // Not finished loading } if (weaponIndex == (int)Names.Weapon.Invalid || armorIndex == (int)Names.Armor.Invalid) { // Choose some arbitrary invalid sequence passwordString[passwordStartIndex + 0] = '.'; passwordString[passwordStartIndex + 1] = '.'; passwordString[passwordStartIndex + 2] = 'B'; passwordUI.Invalidate(); return; } int code1 = 0; int code2 = 0; int code3 = 0; if (enabled) { int multipleOf20 = desiredLevel / 20; int remainderOf20 = desiredLevel % 20; System.Diagnostics.Debug.Assert(multipleOf20 >= 0 && multipleOf20 <= 4); int levelEncode = remainderOf20; if (remainderOf20 >= 10) { levelEncode += 6; } code1 = levelEncode; int[] armorEncodeList2 = { 0, 0, 1, 1, 2, 3 }; int armorEncode2 = armorEncodeList2[armorIndex]; code2 = multipleOf20 + (armorEncode2 * 8); int weaponEncode = weaponIndex; int[] armorEncodeList3 = { 0, 1, 0, 1, 0, 0 }; int armorEncode3 = armorEncodeList3[armorIndex]; code3 = 16 + (weaponEncode * 2) + armorEncode3; } passwordString[passwordStartIndex + 0] = CharacterCode.IndexToChar(code1); passwordString[passwordStartIndex + 1] = CharacterCode.IndexToChar(code2); passwordString[passwordStartIndex + 2] = CharacterCode.IndexToChar(code3); passwordUI.Invalidate(); }
private void OnInventoryCheckboxCheckChanged(object sender, EventArgs e) { // Update password based on the checkbox UI int inventoryCheckboxIndex = 0; int passwordStringIndex = 0; char[] inventoryCharacterCodes = new char[12]; for (int column = 0; column < 6; column++) { { int l0 = 0; l0 |= inventoryCheckboxes[inventoryCheckboxIndex + 0].GetChecked() ? 0x1 : 0; l0 |= inventoryCheckboxes[inventoryCheckboxIndex + 1].GetChecked() ? 0x2 : 0; l0 |= inventoryCheckboxes[inventoryCheckboxIndex + 2].GetChecked() ? 0x4 : 0; l0 |= inventoryCheckboxes[inventoryCheckboxIndex + 3].GetChecked() ? 0x8 : 0; l0 |= inventoryCheckboxes[inventoryCheckboxIndex + 4].GetChecked() ? 0x10 : 0; inventoryCharacterCodes[passwordStringIndex] = CharacterCode.IndexToChar(l0); passwordStringIndex++; inventoryCheckboxIndex += 5; } { int l1 = 0; l1 |= inventoryCheckboxes[inventoryCheckboxIndex + 0].GetChecked() ? 0x1 : 0; l1 |= inventoryCheckboxes[inventoryCheckboxIndex + 1].GetChecked() ? 0x2 : 0; l1 |= inventoryCheckboxes[inventoryCheckboxIndex + 2].GetChecked() ? 0x4 : 0; l1 |= inventoryCheckboxes[inventoryCheckboxIndex + 3].GetChecked() ? 0x8 : 0; inventoryCharacterCodes[passwordStringIndex] = CharacterCode.IndexToChar(l1); passwordStringIndex++; inventoryCheckboxIndex += 4; } } passwordView.UpdatePassword_Inventory(inventoryCharacterCodes); checksum.UpdateButtonState(passwordView.IsValidChecksum()); }