ncomet / u2ug

A Golang library that given a UUID, generates a random adjective and Ubisoft game, or character

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

u2ug: UUID to Ubisoft game

Go

A Golang library that given a UUID (v1 or v4), will return the concatenation of a random adjective and Ubisoft game, or character.

c840005c-06f0-43af-a96f-77bf13fdc956 → Crazy Rocksmith

Disclaimer

Highly inspired by https://github.com/CleverCloud/uuid_to_pokemon.rs, but in Go. Special thanks to the Clever Cloud teams ;)

It is not an injective function, meaning that a given UUID will always produce the same name, but a given name could be the output of two different UUIDs.

It does should not matter since the original UUID must be kept as original source of uniqueness. This library is created in order to assign a reproducible human-readable name to a UUID.

How to use

Go library

go get github.com/ncomet/u2ug/ubi
import "github.com/ncomet/u2ug/ubi"

game, err := ubi.Game("d3acc428-3172-457a-9447-6a22263ef6b3")
if err != nil {
	panic(err)
}

fmt.Println(game) // "Selfish Space Junkies"

character, err := ubi.Character("d3acc428-3172-457a-9447-6a22263ef6b3")
if err != nil {
	panic(err)
}

fmt.Println(character) // "Selfish Selena"

Binary

$ go build .
$ ./u2ug game d3acc428-3172-457a-9447-6a22263ef6b3
Selfish Space Junkies
$ ./u2ug character d3acc428-3172-457a-9447-6a22263ef6b3
Selfish Selena
$ go run ./ game d3acc428-3172-457a-9447-6a22263ef6b3
Selfish Space Junkies
$ go run ./ character d3acc428-3172-457a-9447-6a22263ef6b3
Selfish Selena

Docker

$ docker build -t u2ug .
$ docker run u2ug game d3acc428-3172-457a-9447-6a22263ef6b3
Selfish Space Junkies

WASM

Build the wasm version:

GOOS=js GOARCH=wasm go build -o u2ug.wasm
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .

Then use it in your webapp:

<html>
<head>
    <meta charset="utf-8"/>
    <script src="wasm_exec.js"></script>
    <script>
        const go = new Go();
        WebAssembly.instantiateStreaming(fetch("u2ug.wasm"), go.importObject).then((result) => {
            go.run(result.instance);
        });

        // call the functions available in window.ubiGame or window.ubiCharacter
        document.body.textContent = ubiGame("c74c3694-8040-4213-8a46-988ee9a42ef3");
    </script>
</head>
<body>
</body>
</html>

You can run an example avaible in /wasm_example:

GOOS=js GOARCH=wasm go build -o ./wasm_example/u2ug.wasm
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./wasm_example
ℹ️
Serve the index.html in your favorite tool to avoid CORS errors

Some examples

Games

Polite Tom Clancy’s Ghost Recon Advanced Warfighter

Dreadful Gunfighter II: Revenge of Jesse James

Shrill Cloudy with a Chance of Meatballs

Shrill Rocket: Robot on Wheels

Meek Assassin’s Creed Origins

Caring Far Cry New Dawn

Scared Buck Bumble

Selfish Splinter Cell: Blacklist - Spider-Bot

Shining Petz: Bunnyz

Angry Seven Kingdoms II: The Fryhtan Wars

Odd ZombiU

Plush Super Bust-A-Move

Sleepy Tiger Woods PGA Tour Golf

Foul Adventures in Music with the Recorder

Cruel Heroes of Might and Magic V: Tribes of the East

Stingy Theocracy

Quiet Lost: Via Domus

Bored Skateball

Tiny Warlords: Battlecry II

Shining Imagine: Babyz

Rich All Star Tennis '99

Characters

Soaring Tus

Fussy Eivor

Thrifty Amaru

Afraid Barr-Barr

Chilly Mo

Creeping Thant

Sloppy Teen Punk

Caring Nikolai Andreievich Orelov

Stingy Princess

Generous Hytham

Rapid Glaz

Grimy Sigurd

Cowardly Straker

Bashful Tiva

Generous Amaru

Kind Clancy

Hard Piquedram

Games list source

All games were taken and de-duplicated from:

Characters list source

Extracted from various dedicated game wiki fandom websites.

About

A Golang library that given a UUID, generates a random adjective and Ubisoft game, or character

License:MIT License


Languages

Language:Go 97.6%Language:HTML 2.0%Language:Dockerfile 0.5%