-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DeepStats core functionality without external backend #44
Open
jmichelsen
wants to merge
8
commits into
blizzhackers:mainline
Choose a base branch
from
jmichelsen:deepstats__nogheeds
base: mainline
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
87e1db3
Add DeepStats reporting functionality
jmichelsen db77bbb
Merge remote-tracking branch 'blizzhackers/master' into deepstats__ng
jmichelsen 63dd627
Add getEstimateBuild to stats dumped
jmichelsen 611f871
Remove unused raw_desc param
jmichelsen af552e0
Fix inaccurate string in thown error message
jmichelsen c2d6bb2
Remove dead link
jmichelsen 1933e8c
Remove stub of deepstats from config templates
jmichelsen 10e6050
Add DeepStats file log sample
jmichelsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
"{\"item_id\":\"k6x1zs56$2604023116:522:3:1:3\",\"name\":\"The Stone of Jordan Ring\",\"fname\":\"Ring\\nThe Stone of Jordan\",\"description\":\"\\\\xffc4The Stone of Jordan (75)\\n\\\\xffc4Ring\\n\\\\xffc0Required Level: 29\\n\\\\xffc3+1 to All Skills\\n\\\\xffc3Adds 1-12 lightning damage\\n\\\\xffc3+20 to Mana\\n\\\\xffc3Increase Maximum Mana 25%\\n\\\\xffc0Area: Catacombs Level 4\\n\\\\xffc0Line: perfect.nip #268$\",\"action\":\"Kept\",\"ilvl\":75,\"lvlreq\":29,\"quality\":7,\"code\":\"rin4\",\"size\":[1,1],\"class_id\":522,\"type\":10,\"ethereal\":false,\"pickit_line\":\"perfect.nip #268\",\"act\":1,\"last_area\":37,\"difficulty\":2,\"player_count\":2,\"char_name\":\"DaBest\",\"char_level\":99,\"char_class\":1,\"char_mf\":416,\"ladder\":true,\"realm\":\"USWest\",\"hardcore\":false,\"expansion\":true,\"can_teleport\":true}" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,6 +383,7 @@ var DataFile = { | |
experience: 0, | ||
deaths: 0, | ||
lastArea: "", | ||
lastAreaID: 0, | ||
gold: 0, | ||
level: 0, | ||
name: "", | ||
|
@@ -423,7 +424,7 @@ var DataFile = { | |
|
||
print("Error reading DataFile. Using null values."); | ||
|
||
return {runs: 0, experience: 0, lastArea: "", gold: 0, level: 0, name: "", gameName: "", ingameTick: 0, handle: 0, nextGame: ""}; | ||
return {runs: 0, experience: 0, lastArea: "", lastAreaID: 0, gold: 0, level: 0, name: "", gameName: "", ingameTick: 0, handle: 0, nextGame: ""}; | ||
}, | ||
|
||
getStats: function () { | ||
|
@@ -463,6 +464,7 @@ var DataFile = { | |
} | ||
|
||
obj.lastArea = Pather.getAreaName(me.area); | ||
obj.lastAreaID = me.area; | ||
|
||
break; | ||
case "gold": | ||
|
@@ -499,6 +501,62 @@ var DataFile = { | |
} | ||
}; | ||
|
||
const DeepStats = { | ||
create: function () { | ||
let obj = [], | ||
string; | ||
|
||
string = JSON.stringify(obj); | ||
|
||
Misc.fileAction("data/deepstats/" + me.profile + ".dump.json", 1, string); | ||
|
||
return obj; | ||
}, | ||
|
||
getObj: function () { | ||
let obj, string; | ||
|
||
if (!FileTools.exists("data/deepstats/" + me.profile + ".dump.json")) { | ||
DeepStats.create(); | ||
} | ||
|
||
string = Misc.fileAction("data/deepstats/" + me.profile + ".dump.json", 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit worried about the potential file size. |
||
|
||
try { | ||
obj = JSON.parse(string); | ||
} catch (e) { | ||
// If we failed, file might be corrupted, so create a new one | ||
obj = this.create(); | ||
} | ||
|
||
if (obj) { | ||
return obj; | ||
} | ||
|
||
print("Error reading DeepStats file. Using null values."); | ||
|
||
return []; | ||
}, | ||
|
||
updateStats: function (value) { | ||
while (me.ingame && !me.gameReady) { | ||
delay(100); | ||
} | ||
|
||
let currentStats, string; | ||
|
||
currentStats = this.getObj(); | ||
|
||
if (typeof value === "string") { | ||
currentStats.push(value); | ||
} | ||
|
||
string = JSON.stringify(currentStats); | ||
|
||
Misc.fileAction("data/deepstats/" + me.profile + ".dump.json", 1, string); | ||
} | ||
}; | ||
|
||
var ControlAction = { | ||
mutedKey: false, | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
lastAreaID
will then also appear in current logging which should be fine but I think you wanted to avoid that.You could also maybe use sdk.js instead to parse the ID from string.