added RndPoral func to create Random Portal code
This commit is contained in:
@@ -5,6 +5,11 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRndPortal(t *testing.T) {
|
||||
fmt.Printf("\nRandom Portal Code: ")
|
||||
fmt.Println(RndPortal())
|
||||
}
|
||||
|
||||
func TestPortal2Galactic(t *testing.T) {
|
||||
want, err := P2gc("006afa556c30")
|
||||
if err != nil {
|
||||
@@ -51,7 +56,7 @@ func TestGalactic2portal(t *testing.T) {
|
||||
|
||||
func TestCreateBanner(t *testing.T) {
|
||||
fmt.Printf("\nTesting CreateBanner: ")
|
||||
CreateBanner("006afa556c30", "/tmp/Test.png", 0)
|
||||
CreateBanner(RndPortal(), "/tmp/Test.png", 0)
|
||||
}
|
||||
|
||||
func TestTranslate(t *testing.T) {
|
||||
|
||||
41
rpcg.go
Normal file
41
rpcg.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package nmslib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
/*
|
||||
[P][SSS][YY][ZZZ][XXX] – (P = Planet Index / S = Star System Index / Y = Height / Z = Width / X = Length)
|
||||
|
||||
`Solar System Index
|
||||
A Solar System Index is assigned to each star system in a region. It always begins at SolarSystemIndex=001
|
||||
and counts up by one for every star system. The number of star systems in a region is variable so the
|
||||
maximum value of the Solar System Index is also variable, though the two correspond directly. To date there
|
||||
is no discovered value that is higher than SolarSystemIndex=243 (Mamundi-Kate in the Baadossm Anomaly of
|
||||
Euclid galaxy), meaning that 579 is the maximum number of star systems yet discovered in a region. Based
|
||||
on the evidence that every region has a SolarSystemIndex=079 and SolarSystemIndex=07A (with the former
|
||||
always having a Black Hole and the latter always having an Atlas Station), it is known that every region has
|
||||
at least 122 star systems. SolarSystemIndex=000 always leads to the region's first system, just like
|
||||
PlanetIndex=0 always leads to the first portal of a system due to the error proximity mechanic.`
|
||||
Source https://nomanssky.fandom.com/wiki/Portal_address#Solar_System_Index
|
||||
|
||||
*/
|
||||
|
||||
func RndPortal() (final string) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
min := 0x1
|
||||
ymax := 0xFF
|
||||
xzmax := 0xFFF
|
||||
ssimax := 0x242 // set this low to lower chances of an invalid address
|
||||
|
||||
x := rand.Intn(xzmax-min+1) + min
|
||||
z := rand.Intn(xzmax-min+1) + min
|
||||
y := rand.Intn(ymax-min+1) + min
|
||||
ssi := rand.Intn(ssimax-min+1) + min
|
||||
|
||||
final = fmt.Sprintf("%00X%03X%02X%03X%03X", 1, ssi, y, z, x)
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user