Skip to content

Commit

Permalink
Merge branch 'obc/scorer-generator' into ok/obc-alpha-release
Browse files Browse the repository at this point in the history
  • Loading branch information
OldBeardedCoder committed Jan 23, 2021
2 parents 31ca52c + 3a88041 commit b92feab
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 43 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ The mod config is located in `cfg.json`. You can change this config to your lik
* Removes attribute requirements from items.
#### RemoveUniqCharmLimit `bool`
* Allows to carry more than 1 unique charm of the same type.
#### PerfectProps `bool`
* All props will have the max value for min/max values
#### UseOSkills `bool`
* Will change class only skills to oskills
#### PerfectProps `bool`
* All props will have the max value for min/max values
#### EnterToExit `bool`
* If this is true, this will require the user to press enter to close the program
* If false, it will not prompt user input
Expand Down Expand Up @@ -202,6 +202,9 @@ Anyone who donates, will get recognition in the form of a role in the Discord.
Thanks!

# Change Log
## v0.5.2-alpha-20
* Set Generator default to false to work around the ui bug.
* Fix for PerfectProps doing "r=" proptypes
## v0.5.2-alpha-19
* Set PropScoreMultiplier to 1 if user had set it to 0 (thx Speculator)
* Fix Seeds.txt code to write correct seed, and in addition write SetsSeed.
Expand Down Expand Up @@ -330,3 +333,8 @@ Thanks!

# Credits
* [Dead Weight Design](https://www.instagram.com/deadweightdesign/) - Thanks for creating the logo!
* tlentz, Deadlock39, OldBeardedCoder/EMPY -- Teh Devs
* Amek for being the true moderating god he is and for his awesome tutorials and cat herding.
* iksargodzilla - Thank-you so much for doing 90% of the grunt work for the scoring engine
* macohan, Negative Inspiration, for helping with design and being a huge help with the newbies.
* The many others that reported bugs, proposed enhancements and gave moral support & encouragement.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.5.2-alpha-19
v0.5.2-alpha-20
4 changes: 2 additions & 2 deletions cfg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": "v0.5.2-alpha-19",
"Version": "v0.5.2-alpha-20",
"SourceDir": "",
"OutputDir": "",
"MeleeSplash": true,
Expand Down Expand Up @@ -37,7 +37,7 @@
"ElementalSkills": true
},
"GeneratorOptions": {
"Generate": true,
"Generate": false,
"UseSeed": true,
"Seed": 1234,
"UseSetsSeed": true,
Expand Down
6 changes: 3 additions & 3 deletions gui/react-ui/src/components/D2ModMaker/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const _ = require('lodash');
const axios = require("axios");

const defaultCfg = {
Version: "v0.5.2-alpha-19",
Version: "v0.5.2-alpha-20",
SourceDir: "",
OutputDir: "",
MeleeSplash: true,
Expand All @@ -39,8 +39,8 @@ const defaultCfg = {
RemoveLevelRequirements: false,
RemoveAttRequirements: false,
RemoveUniqCharmLimit: false,
PerfectProps: false,
UseOSkills: true,
PerfectProps: false,
SafeUnsocket: true,
PropDebug: false,
EnterToExit: false,
Expand All @@ -59,7 +59,7 @@ const defaultCfg = {
ElementalSkills: true
},
GeneratorOptions: {
Generate: true,
Generate: false,
UseSeed: false,
Seed: -1,
UseSetsSeed: true,
Expand Down
14 changes: 4 additions & 10 deletions internal/d2fs/assets/assets_vfsdata.go

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions internal/d2fs/d2fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewFiles(sourceDir string, outDir string) Files {
if (sourceDir == outDir) && (sourceDir != "") {
log.Fatalf("Error: Source Directory == Output Directory. Either set the Source Directory to blank (to use 1.13c default files), or set it to vanilla data/ directory. OutDir is deleted and re-created each run")
}
//os.RemoveAll(path.Join(files.outDir, "/data/")) // obc: This is c4 approach, use sword instead
//os.RemoveAll(path.Join(files.outDir, "/data/")) // obc: This is the old c4 approach, use sword instead
err := os.MkdirAll(path.Join(files.outDir, assets.DataGlobalExcel), 0755)
util.Check(err)

Expand All @@ -74,10 +74,8 @@ func NewFiles(sourceDir string, outDir string) Files {
// ReadD2File reads a given d2 file
func (d2files *Files) Read(filepath string, filename string) *File {
if d2files.sourceDir == "" {
// open csvfile
//fmt.Printf("Opening %s %s\n", filepath, filename)
// open tsvfile
csvfile, err := assets.Assets.Open(path.Join(filepath, filename))
//TODO: figure out how to move this out of if/else
checkError(filename, err)
defer csvfile.Close()
return importCsv(csvfile, filename)
Expand All @@ -91,14 +89,15 @@ func (d2files *Files) Read(filepath string, filename string) *File {

// ReadAsset Reads in a tsv file from vfs but doesn't cache it in Files
func ReadAsset(filePath string, filename string) *File {
// open csvfile
// open tsvfile
csvfile, err := assets.Assets.Open(path.Join(filePath, filename))
checkError(filename, err)
defer csvfile.Close()

return importCsv(csvfile, filename)
}

// importCsv This is actually tab separated value, i.e. tsv
func importCsv(csvfile io.Reader, filename string) *File {
// create new D2File pointer with fname
d2file := &File{FileName: filename}
Expand Down Expand Up @@ -197,21 +196,20 @@ func MergeRows(f1 *File, f2 File) {

keys[f1.Rows[rowIdx][0]] = rowIdx
}
//fmt.Printf("%v", keys)
for f2RowIdx := range f2.Rows {
f1RowIdx, ok := keys[f2.Rows[f2RowIdx][0]]
if ok {
f1.Rows[f1RowIdx] = f2.Rows[f2RowIdx]
//fmt.Printf("Merging...%s\n", f2.Rows[f2RowIdx][0])
} else {
//fmt.Printf("Len Before:%d\n", len(f1.Rows))
f1.Rows = append(f1.Rows, f2.Rows[f2RowIdx])
//fmt.Printf("Len After :%d\n", len(f1.Rows))
}
}
}

//func printFile() {
// This function will generate a list of constants from a header.
// Useful when creating a new internal\txt\blah\blah.go file
//func printFileHeader() {
// d2files := d2file.D2Files{}
// f := d2file.GetOrCreateFile(d2files, magicSuffix.FileName)
// for i := range f.Headers {
Expand All @@ -220,7 +218,7 @@ func MergeRows(f1 *File, f2 File) {
// panic("")
//}

// DebugDumpFiles Dump all of Files to console
func DebugDumpFiles(f Files, filename string) {
// DebugDumpVFSFileNames Dump all of Files to console
func DebugDumpVFSFileNames(f Files, filename string) {
fmt.Printf("%s\n", f.cache[filename])
}
8 changes: 4 additions & 4 deletions internal/d2mod/config/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type Data struct {
RemoveLevelRequirements bool `json:"RemoveLevelRequirements"`
RemoveAttRequirements bool `json:"RemoveAttRequirements"`
RemoveUniqCharmLimit bool `json:"RemoveUniqCharmLimit"`
PerfectProps bool `json:"PerfectProps"` // sets min/max to max
UseOSkills bool `json:"UseOSkills"` // +3 Fireball (Sorceress Only) -> +3 Fireball
PerfectProps bool `json:"PerfectProps"` // sets min/max to max
SafeUnsocket bool `json:"SafeUnsocket"`
PropDebug bool `json:"PropDebug"`
EnterToExit bool `json:"EnterToExit"`
Expand All @@ -69,7 +69,7 @@ type Data struct {
// DefaultData Default configuration should the cfg.json not read/be missing anything.
func DefaultData() Data {
return Data{
Version: "v0.5.2-alpha-19",
Version: "v0.5.2-alpha-20",
SourceDir: "",
OutputDir: "",
MeleeSplash: true,
Expand All @@ -87,8 +87,8 @@ func DefaultData() Data {
RemoveLevelRequirements: false,
RemoveAttRequirements: false,
RemoveUniqCharmLimit: false,
PerfectProps: false,
UseOSkills: true,
PerfectProps: false,
SafeUnsocket: true,
PropDebug: false,
EnterToExit: false,
Expand All @@ -107,7 +107,7 @@ func DefaultData() Data {
ElementalSkills: true,
},
GeneratorOptions: GeneratorOptions{
Generate: true,
Generate: false,
UseSeed: false,
Seed: -1,
UseSetsSeed: true,
Expand Down
9 changes: 4 additions & 5 deletions internal/d2mod/elementalskills/elementalskills.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/tlentz/d2modmaker/internal/d2fs/txts/itemStatCost"
"github.com/tlentz/d2modmaker/internal/d2fs/txts/properties"
"github.com/tlentz/d2modmaker/internal/d2fs/txts/propscores"
"github.com/tlentz/d2modmaker/internal/d2mod/d2items"
"github.com/tlentz/d2modmaker/internal/d2mod/prop"
"github.com/tlentz/d2modmaker/internal/d2mod/scorer/scorerstatistics"
"github.com/tlentz/d2modmaker/internal/util"
Expand Down Expand Up @@ -45,7 +44,7 @@ func Run(outDir string, d2files d2fs.Files, enabled bool) {
}
}

// SetProbability Increase probability of getting the other elementalskills to match fireskills
// SetProbability Increase probability of getting the other elementalskills to match fireskills in the Generator
func SetProbability(d2files d2fs.Files, ss *scorerstatistics.ScorerStatistics, enabled bool) {
if enabled {
fireSkillsRows := make(map[int]bool, 0)
Expand Down Expand Up @@ -99,9 +98,9 @@ func copyPatchString(outDir string) {
util.Check(err)
}

// Props Add elemental skill props to a list of props
func Props() d2items.Props {
props := make(d2items.Props, 4)
// Props Add elemental skill props to a list of props. (Randomizer)
func Props() prop.Props {
props := make(prop.Props, 4)
props[0] = prop.NewProp("coldskill", "", "1", "4", 0)
props[1] = prop.NewProp("poisonskill", "", "1", "4", 0)
props[2] = prop.NewProp("lightningskill", "", "1", "4", 0)
Expand Down
2 changes: 1 addition & 1 deletion internal/d2mod/perfectprops/perfectprops.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func convertFile(d2files *d2fs.Files, pmap propName2PropParType, ifi *d2fs.ItemF
propName := file.Rows[rowIdx][colIdx]
parType := pmap[propName]
switch {
case (parType == "r") || (parType == "rp") || (parType == "rt") || (parType == "smm"):
case (parType == "r") || (parType == "rp") || (parType == "rt") || (parType == "smm") || (parType == "r="):
if file.Rows[rowIdx][colIdx+2] == file.Rows[rowIdx][colIdx+3] {
conversionCounter++
}
Expand Down
8 changes: 4 additions & 4 deletions internal/d2mod/runewordlevels/runewordlevels.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runewordlevels

import (
"fmt"
"log"
"strconv"

"github.com/tlentz/d2modmaker/internal/d2fs"
Expand All @@ -13,8 +14,7 @@ var miscItemLevelsCache map[string]int // OBC: yeah ok it's static variable, thr

func GetRunewordLevel(row []string, miscItemLevels map[string]int) int {
if len(miscItemLevels) == 0 {
fmt.Printf("runewordlevels was not initialized before calling GetRunewordLevel\n")
panic(1)
log.Panicf("runewordlevels was not initialized before calling GetRunewordLevel\n")
}
rl := 0
for j := 0; j < 6; j++ {
Expand Down Expand Up @@ -46,9 +46,9 @@ func GetMiscItemLevels(d2files *d2fs.Files) map[string]int {
fmt.Printf("%s\n", row)
if row[misc.Code][0] == 'r' {
fmt.Printf("GetMiscItemLevels Row:%s\n", row[misc.Code])
d2fs.DebugDumpFiles(*d2files, misc.FileName)
d2fs.DebugDumpVFSFileNames(*d2files, misc.FileName)

panic(3)
log.Panicf("MicItems.txt Level column is not numeric")
}
}
}
Expand Down
Binary file modified internal/d2mod/scorer/PropAnalysis.ods
Binary file not shown.

0 comments on commit b92feab

Please sign in to comment.