Realm detail
nisse2
gno.land/r/g1wt79w2q0sfmpfrxc4990mlsg5ll09yva6fyc4p/nisse2
Indexed deployment identity with independently loaded latest RPC source, functions, and Render.
Indexed deployment
Identity
- Package path
- gno.land/r/g1wt79w2q0sfmpfrxc4990mlsg5ll09yva6fyc4p/nisse2
- Block
- 272320
- Deployed (UTC)
- Transaction
- bttPhIDSuXKTPpVzVGaAsrdvDM3OtvGetl4C8VRIvuA=
Latest RPC state
Source
package nisse2
import "strconv"
type Message struct {
ID uint64
From string
To string
Body string
Turn uint64
}
var messages map[string]map[uint64]*Message
var nextMessageID uint64
func init() {
messages = make(map[string]map[uint64]*Message)
nextMessageID = 1
}
func pairSeed(from string, to string) uint64 {
source := normalizeKey(from) + "::" + normalizeKey(to)
sum := uint64(0)
for i := 0; i < len(source); i++ {
sum += uint64(source[i]) * uint64(i+1)
}
return sum%251 + 1
}
func hexDigit(n uint8) byte {
if n < 10 {
return byte('0' + n)
}
return byte('a' + (n - 10))
}
func encodeMessage(from string, to string, body string) string {
seed := pairSeed(from, to)
out := ""
for i := 0; i < len(body); i++ {
mask := uint8((seed + uint64(i*17)) % 256)
encoded := uint8(body[i]) ^ mask
out += string([]byte{hexDigit(encoded >> 4), hexDigit(encoded & 15)})
}
return out
}
func WriteToFriend(cur realm, fromPlayerName string, toPlayerName string, body string) string {
fromKey, fromPlayer := ownedPlayer(cur, fromPlayerName)
_ = fromKey
toPlayerName = cleanName(toPlayerName)
body = cleanName(body)
if toPlayerName == "" {
panic("recipient required")
}
if body == "" {
panic("message body is required")
}
toKey := normalizeKey(toPlayerName)
toPlayer, ok := players[toKey]
if !ok {
panic("recipient not found")
}
if messages[toKey] == nil {
messages[toKey] = make(map[uint64]*Message)
}
id := nextMessageID
nextMessageID++
messages[toKey][id] = &Message{
ID: id,
From: fromPlayer.Name,
To: toPlayer.Name,
Body: encodeMessage(fromPlayer.Name, toPlayer.Name, body),
Turn: fromPlayer.Turns,
}
return "message sent"
}
func GetMessages(playerName string) string {
key := normalizeKey(playerName)
entryMap, ok := messages[key]
if !ok || len(entryMap) == 0 {
return "No messages."
}
out := "Messages for " + playerName + "\n"
for id := uint64(1); id < nextMessageID; id++ {
entry, exists := entryMap[id]
if !exists {
continue
}
out += "- #" + strconv.Itoa(int(entry.ID)) + " from " + entry.From + ": " + entry.Body + "\n"
}
return out
}
func DescribeLatestIncomingMessage(playerName string) string {
key := normalizeKey(playerName)
entryMap, ok := messages[key]
if !ok || len(entryMap) == 0 {
return "No messages."
}
var latest *Message
for id := uint64(1); id < nextMessageID; id++ {
entry, exists := entryMap[id]
if !exists {
continue
}
latest = entry
}
if latest == nil {
return "No messages."
}
out := "Latest message for " + playerName + "\n"
out += "From: " + latest.From + "\n"
out += "Turn: " + strconv.Itoa(int(latest.Turn)) + "\n"
out += "Body: " + latest.Body
return out
}
Latest RPC state
Exported functions
- SetHouseSign(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, playerName string, buildingID uint64, text string) string
- DescribeTileBuildings(x uint64, y uint64) string
- ListPlayerHouses(playerName string) string
- DescribeTileSceneAt(x uint64, y uint64) string
- WriteToFriend(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, fromPlayerName string, toPlayerName string, body string) string
- GetMessages(playerName string) string
- DescribeLatestIncomingMessage(playerName string) string
- ListPlayerPositions() string
- GetPlayerCoreData(name string) string
- GetPlayerTravelData(name string) string
- GetPlayerWealthData(name string) string
- GetPlayerMapData(name string) string
- DescribeCompanion(playerName string) string
- DescribeLatestDiaryEntry(playerName string) string
- DescribeCreature(kind string) string
- Render(path string) string
- MintPlayer(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, name string) string
- TravelPlayer(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, playerName string, x uint64, y uint64, attitude string) string
Latest RPC state · Realm Render
Nisse v2
Frozen book: creatures + terrain live in /p/.../nisse2/book.
Rules live in /p/.../nisse2/rules. This realm only stores players and applies outcomes.
Atlas 18x10
sea sea sea sea sea sea sea sea sea sea sea sea sea sea sea sea sea sea
sea sea sea sea sea cst cst cst cst cst sea cst cst cst cst sea sea sea
sea sea sea cst nct for for moo moo moo fsh for for for cst cst sea sea
sea cst cst cst for for for mvl for mtn for for mon for moo cst cst sea
sea cst fsh for for frm frm mtn for mtn mdw for for for mtn hil cst sea
sea hbr frm for mdw mvl mtn mon mtn mtn for for for frm frm cst cst sea
sea cst for for for hil mtn for mtn hil fsh moo moo frm sct cst sea sea
sea cst cst for fsh moo moo moo moo moo cst cst cst cst cst sea sea sea
sea sea cst cst sea cst cst cst cst cst cst sea sea sea sea sea sea sea
sea sea sea sea sea sea sea sea sea sea sea sea sea sea sea sea sea sea
Players
Player positions
- troll2 @ (16, 9)
- Huldra @ (14, 5)