-
Notifications
You must be signed in to change notification settings - Fork 0
/
Character.cs
115 lines (100 loc) · 3.09 KB
/
Character.cs
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using EVE.ISXEVE;
using LavishScriptAPI;
using LavishVMAPI;
using InnerSpaceAPI;
namespace Eve_TradingAgent
{
/// <summary>
/// Data set about a character.
/// </summary>
// TODO: Add order number related skills when we want to enable auto selling.
public class Character
{
/// <summary>
/// Get the information of the character.
/// </summary>
public bool LoadCharacterInfo()
{
Me me;
using (new FrameLock(true))
{
EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE();
// me is not persistent, we can't just keep a static reference somewhere,have to renew every frame;
me = new Me();
name = me.Name;
currentStationID = me.StationID;
// TODO: Support remote modify in future.
daytradingLevel = 0;
}
bool succeed = !string.IsNullOrEmpty(Name);
return succeed;
}
# region public property
public string Name
{
get
{
return name;
}
}
public int CurrentStationID
{
get
{
return currentStationID;
}
}
public int ModifyRange
{
get
{
return getOperationRange(daytradingLevel);
}
}
# endregion
# region private field
private string name;
private int currentStationID;
/// <summary>
/// Allows for remote modification of buy and sell orders. Each level of skill increases the range at which orders may be modified.
/// Level 1 allows for modification of orders within the same solar system, Level 2 extends that range to systems within 5 jumps,
/// and each subsequent level then doubles it. Level 5 allows for market order modification anywhere within current region.
/// </summary>
private int daytradingLevel;
# endregion
/// <summary>
/// Compute the range within which the character is able to operate (create/modify/etc) the market orders.
/// </summary>
/// <param name="skillLevel"></param>
/// <returns></returns>
private int getOperationRange(int skillLevel)
{
if (skillLevel >= 0 && skillLevel <= 1)
{
return skillLevel - 1;
}
else if (skillLevel <= 4)
{
int i = skillLevel - 2;
int jumps = 5;
while (i > 0)
{
jumps = jumps * 2;
i--;
}
return jumps;
}
else if (skillLevel == 5)
{
return 32767;
}
else
{
Log.WriteLog(new ArgumentOutOfRangeException("Unexpected Skill Level"));
// Return minimal range instead of crash.
return -1;
}
}
}
}