go-underlords

module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2020 License: MIT

README

Go-Underlords

GitHub go.mod Go version Go Report Card PkgGoDev Go CI Coverage Status

Go library for Dota Underlords.


Features

  • Share code parsing
  • Share code encoding

Installation

This is a Go module.

Before installing, please download and install a Go version greater than or equal to 1.11.

Installation of the module is done using:

go get github.com/ThomasK33/go-underlords

Quick Start

package main

import (
  "log"

  "github.com/ThomasK33/go-underlords/sharecode"
)

func main() {
  // Create a clean v8 share code object
  code := sharecode.V8{}

  code.BoardUnitIDs[0][0] = 46 // Alchemist
  code.BoardUnitIDs[6][6] = 11 // Antimage
  code.BoardUnitIDs[6][3] = 52 // Lich

  code.BoardUnitIDs[4][4] = 255 // Underlord unit
  code.UnderlordIDs[1] = 4      // Hobgen
  code.UnderlordRanks[1] = 4    // Underlords rank

  // Items are encoded in 3 bytes, thus a remapping happens here
  code.UnitItems[0][0] = sharecode.NewV8EquippedItem3Bytes(sharecode.V8EquippedItem{
    ItemID: 10171,
  })

  code.UnequippedItems[0][0] = sharecode.NewV8EquippedItem3Bytes(sharecode.V8EquippedItem{
    ItemID: 10170,
  })

  code.PackedUnitRanks[0] = sharecode.NewV8PackedUnitRanks([]uint8{2})
  code.PackedUnitRanks[6] = sharecode.NewV8PackedUnitRanks([]uint8{0, 0, 0, 0, 0, 0, 3, 0})

  // code.ToString() is equivalent to code.ToBase64String()
  successfullShareCode := code.ToBase64String()
  log.Println(successfullShareCode)

  // Instanciate a v8 share code from a base64 string
  testShareCode := "8qAMAAP4BAK4BAATjJ/5uAEZuAAAgEVM0LgAAAG0AbQAACwAAAP8BDAABCRsI/wAJARcBAQAOAQUBAQAGES0QbUBHOlcBEmoBAAFIACABaBABAyAAEAEpLAIgIAAwAAAGAgEgAAWCAHUR2gB0EQkBAQRjAAVyLBAAAgABBAMGdycAdy4fAK4BAA=="
  newShareCode := sharecode.NewV8FromCode(testShareCode)
  log.Print(newShareCode.BoardUnitIDs)
  log.Printf("Unit at 6x6: %d", newShareCode.BoardUnitIDs[6][6])
}

Docs & Community

Contributing

Contributing Guide

License

MIT

Disclaimer

This project is not affiliated with Valve Corporation. Dota Underlords, Dota and Steam are registered trademarks of Valve Corporation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL