forked from blakehartley/RNGHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSteal.cs
More file actions
92 lines (85 loc) · 2.85 KB
/
Steal.cs
File metadata and controls
92 lines (85 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
namespace FF12RNGHelper
{
/// <summary>
/// This class encapsulates a single steal oportunity
/// </summary>
class Steal
{
// Strings for display in the UI
private const string Rare = "Rare";
private const string Uncommon = "Uncommon";
private const string Common = "Common";
private const string None = "None";
private const string Linker = " + ";
// Steal chances
private const int CommonChance = 55;
private const int UncommonChance = 10;
private const int RareChance = 3;
private const int CommonChanceCuffs = 80;
private const int UncommonChanceCuffs = 30;
private const int RareChanceCuffs = 6;
/// <summary>
/// Check if you steal anything while not wearing the Thief's Cuffs
/// When not wearing Thief's Cuffs you may only steal one item.
/// Once you are successful, you get that item and that's it.
/// </summary>
public string checkSteal(uint PRNG1, uint PRNG2, uint PRNG3)
{
if (stealSuccessful(PRNG1, RareChance))
{
return Rare;
}
if (stealSuccessful(PRNG2, UncommonChance))
{
return Uncommon;
}
if (stealSuccessful(PRNG3, CommonChance))
{
return Common;
}
return None;
}
/// <summary>
/// Check if you steal anything while wearing the Thief's Cuffs
/// When not wearing Thief's Cuffs you may steal more than one
/// item, and you have better odds. Roll against all 3 and get
/// everything you successfully steal.
/// </summary>
public string checkStealCuffs(uint PRNG1, uint PRNG2, uint PRNG3)
{
string returnStr = String.Empty;
if (stealSuccessful(PRNG1, RareChanceCuffs))
{
returnStr += Rare;
}
if (stealSuccessful(PRNG2, UncommonChanceCuffs))
{
returnStr += Linker + Uncommon;
}
if (stealSuccessful(PRNG3, CommonChanceCuffs))
{
returnStr += Linker + Common;
}
if (returnStr == String.Empty)
{
returnStr = None;
}
return returnStr.TrimStart(Linker.ToCharArray());
}
/// <summary>
/// Calculate if a steal attempt was successful
/// </summary>
private bool stealSuccessful(uint PRNG, int chance)
{
return randToPercent(PRNG) < chance;
}
/// <summary>
/// Convert an RNG value into a percentage
/// </summary>
private int randToPercent(uint toConvert)
{
return (int) (toConvert % 100);
}
}
}