go: port foundation — types, RNG, tables, daemon scheduler
Module sneak.berlin/go/rogue, package game: - types.go: all rogue.h constants, flag types, Coord/Stats/Room/ObjInfo - creature.go/object.go: the THING union split into Creature (Player/ Monster) and Object; slices replace the C linked lists - level.go: Place map with the C column-major layout and chat/flat/moat/ winat access methods - tables.go: extern.c + init.c data (bestiary, item tables, name pools) - rng.go: the exact C LCG (seed*11109+13849), golden-tested against a compiled C reference for seed compatibility - init.go: per-game item appearance randomization (init.c) - daemon.go/daemons.go: scheduler with DaemonID replacing function pointers (ids match the C save format's mapping) - game.go: RogueGame holds all former globals; NewGame constructor
This commit is contained in:
327
game/tables.go
Normal file
327
game/tables.go
Normal file
@@ -0,0 +1,327 @@
|
||||
package game
|
||||
|
||||
// This file is the immutable data from extern.c and init.c: tables that are
|
||||
// never written after program start. Per-game mutable copies (the ObjInfo
|
||||
// tables, whose probabilities are re-summed and whose Know/Guess fields
|
||||
// change during play) are cloned into RogueGame.Items by NewGame.
|
||||
|
||||
// initStats is the C INIT_STATS: the player's starting statistics.
|
||||
var initStats = Stats{Str: 16, Exp: 0, Lvl: 1, Arm: 10, HP: 12, Dmg: "1x4", MaxHP: 12}
|
||||
|
||||
// aClass is extern.c a_class[]: armor class for each armor type.
|
||||
var aClass = [MaxArmors]int{
|
||||
8, // LEATHER
|
||||
7, // RING_MAIL
|
||||
7, // STUDDED_LEATHER
|
||||
6, // SCALE_MAIL
|
||||
5, // CHAIN_MAIL
|
||||
4, // SPLINT_MAIL
|
||||
4, // BANDED_MAIL
|
||||
3, // PLATE_MAIL
|
||||
}
|
||||
|
||||
// eLevels is extern.c e_levels[]: experience thresholds per level; the
|
||||
// zero terminates the table as in C.
|
||||
var eLevels = []int{
|
||||
10, 20, 40, 80, 160, 320, 640, 1300, 2600, 5200, 13000, 26000,
|
||||
50000, 100000, 200000, 400000, 800000, 2000000, 4000000, 8000000, 0,
|
||||
}
|
||||
|
||||
// trName is extern.c tr_name[]: names of the traps.
|
||||
var trName = [NTraps]string{
|
||||
"a trapdoor",
|
||||
"an arrow trap",
|
||||
"a sleeping gas trap",
|
||||
"a beartrap",
|
||||
"a teleport trap",
|
||||
"a poison dart trap",
|
||||
"a rust trap",
|
||||
"a mysterious trap",
|
||||
}
|
||||
|
||||
// invTName is extern.c inv_t_name[]: the inventory style names.
|
||||
var invTName = []string{"Overwrite", "Slow", "Clear"}
|
||||
|
||||
// monsterTable is extern.c monsters[26]: all monster kinds, indexed by
|
||||
// letter - 'A'. Monster strength (XX in C) is always 10; HP (___ in C) is
|
||||
// rolled from the level at creation time.
|
||||
var monsterTable = [26]MonsterKind{
|
||||
/* Name CARRY FLAGS str exp lvl arm hp dmg */
|
||||
{"aquator", 0, IsMean, Stats{10, 20, 5, 2, 1, "0x0/0x0", 0}},
|
||||
{"bat", 0, IsFly, Stats{10, 1, 1, 3, 1, "1x2", 0}},
|
||||
{"centaur", 15, 0, Stats{10, 17, 4, 4, 1, "1x2/1x5/1x5", 0}},
|
||||
{"dragon", 100, IsMean, Stats{10, 5000, 10, -1, 1, "1x8/1x8/3x10", 0}},
|
||||
{"emu", 0, IsMean, Stats{10, 2, 1, 7, 1, "1x2", 0}},
|
||||
{"venus flytrap", 0, IsMean, Stats{10, 80, 8, 3, 1, "%%%x0", 0}},
|
||||
{"griffin", 20, IsMean | IsFly | IsRegen, Stats{10, 2000, 13, 2, 1, "4x3/3x5", 0}},
|
||||
{"hobgoblin", 0, IsMean, Stats{10, 3, 1, 5, 1, "1x8", 0}},
|
||||
{"ice monster", 0, 0, Stats{10, 5, 1, 9, 1, "0x0", 0}},
|
||||
{"jabberwock", 70, 0, Stats{10, 3000, 15, 6, 1, "2x12/2x4", 0}},
|
||||
{"kestrel", 0, IsMean | IsFly, Stats{10, 1, 1, 7, 1, "1x4", 0}},
|
||||
{"leprechaun", 0, 0, Stats{10, 10, 3, 8, 1, "1x1", 0}},
|
||||
{"medusa", 40, IsMean, Stats{10, 200, 8, 2, 1, "3x4/3x4/2x5", 0}},
|
||||
{"nymph", 100, 0, Stats{10, 37, 3, 9, 1, "0x0", 0}},
|
||||
{"orc", 15, IsGreed, Stats{10, 5, 1, 6, 1, "1x8", 0}},
|
||||
{"phantom", 0, IsInvis, Stats{10, 120, 8, 3, 1, "4x4", 0}},
|
||||
{"quagga", 0, IsMean, Stats{10, 15, 3, 3, 1, "1x5/1x5", 0}},
|
||||
{"rattlesnake", 0, IsMean, Stats{10, 9, 2, 3, 1, "1x6", 0}},
|
||||
{"snake", 0, IsMean, Stats{10, 2, 1, 5, 1, "1x3", 0}},
|
||||
{"troll", 50, IsRegen | IsMean, Stats{10, 120, 6, 4, 1, "1x8/1x8/2x6", 0}},
|
||||
{"black unicorn", 0, IsMean, Stats{10, 190, 7, -2, 1, "1x9/1x9/2x9", 0}},
|
||||
{"vampire", 20, IsRegen | IsMean, Stats{10, 350, 8, 1, 1, "1x10", 0}},
|
||||
{"wraith", 0, 0, Stats{10, 55, 5, 4, 1, "1x6", 0}},
|
||||
{"xeroc", 30, 0, Stats{10, 100, 7, 7, 1, "4x4", 0}},
|
||||
{"yeti", 30, 0, Stats{10, 50, 4, 6, 1, "1x6/1x6", 0}},
|
||||
{"zombie", 0, IsMean, Stats{10, 6, 2, 8, 1, "1x8", 0}},
|
||||
}
|
||||
|
||||
// Base ObjInfo tables (extern.c). These are templates: NewGame copies them
|
||||
// into ItemLore before initProbs converts Prob to cumulative form.
|
||||
|
||||
var baseThings = [NumThings]ObjInfo{
|
||||
{Prob: 26}, // potion
|
||||
{Prob: 36}, // scroll
|
||||
{Prob: 16}, // food
|
||||
{Prob: 7}, // weapon
|
||||
{Prob: 7}, // armor
|
||||
{Prob: 4}, // ring
|
||||
{Prob: 4}, // stick
|
||||
}
|
||||
|
||||
var baseArmInfo = [MaxArmors]ObjInfo{
|
||||
{Name: "leather armor", Prob: 20, Worth: 20},
|
||||
{Name: "ring mail", Prob: 15, Worth: 25},
|
||||
{Name: "studded leather armor", Prob: 15, Worth: 20},
|
||||
{Name: "scale mail", Prob: 13, Worth: 30},
|
||||
{Name: "chain mail", Prob: 12, Worth: 75},
|
||||
{Name: "splint mail", Prob: 10, Worth: 80},
|
||||
{Name: "banded mail", Prob: 10, Worth: 90},
|
||||
{Name: "plate mail", Prob: 5, Worth: 150},
|
||||
}
|
||||
|
||||
var basePotInfo = [MaxPotions]ObjInfo{
|
||||
{Name: "confusion", Prob: 7, Worth: 5},
|
||||
{Name: "hallucination", Prob: 8, Worth: 5},
|
||||
{Name: "poison", Prob: 8, Worth: 5},
|
||||
{Name: "gain strength", Prob: 13, Worth: 150},
|
||||
{Name: "see invisible", Prob: 3, Worth: 100},
|
||||
{Name: "healing", Prob: 13, Worth: 130},
|
||||
{Name: "monster detection", Prob: 6, Worth: 130},
|
||||
{Name: "magic detection", Prob: 6, Worth: 105},
|
||||
{Name: "raise level", Prob: 2, Worth: 250},
|
||||
{Name: "extra healing", Prob: 5, Worth: 200},
|
||||
{Name: "haste self", Prob: 5, Worth: 190},
|
||||
{Name: "restore strength", Prob: 13, Worth: 130},
|
||||
{Name: "blindness", Prob: 5, Worth: 5},
|
||||
{Name: "levitation", Prob: 6, Worth: 75},
|
||||
}
|
||||
|
||||
var baseRingInfo = [MaxRings]ObjInfo{
|
||||
{Name: "protection", Prob: 9, Worth: 400},
|
||||
{Name: "add strength", Prob: 9, Worth: 400},
|
||||
{Name: "sustain strength", Prob: 5, Worth: 280},
|
||||
{Name: "searching", Prob: 10, Worth: 420},
|
||||
{Name: "see invisible", Prob: 10, Worth: 310},
|
||||
{Name: "adornment", Prob: 1, Worth: 10},
|
||||
{Name: "aggravate monster", Prob: 10, Worth: 10},
|
||||
{Name: "dexterity", Prob: 8, Worth: 440},
|
||||
{Name: "increase damage", Prob: 8, Worth: 400},
|
||||
{Name: "regeneration", Prob: 4, Worth: 460},
|
||||
{Name: "slow digestion", Prob: 9, Worth: 240},
|
||||
{Name: "teleportation", Prob: 5, Worth: 30},
|
||||
{Name: "stealth", Prob: 7, Worth: 470},
|
||||
{Name: "maintain armor", Prob: 5, Worth: 380},
|
||||
}
|
||||
|
||||
var baseScrInfo = [MaxScrolls]ObjInfo{
|
||||
{Name: "monster confusion", Prob: 7, Worth: 140},
|
||||
{Name: "magic mapping", Prob: 4, Worth: 150},
|
||||
{Name: "hold monster", Prob: 2, Worth: 180},
|
||||
{Name: "sleep", Prob: 3, Worth: 5},
|
||||
{Name: "enchant armor", Prob: 7, Worth: 160},
|
||||
{Name: "identify potion", Prob: 10, Worth: 80},
|
||||
{Name: "identify scroll", Prob: 10, Worth: 80},
|
||||
{Name: "identify weapon", Prob: 6, Worth: 80},
|
||||
{Name: "identify armor", Prob: 7, Worth: 100},
|
||||
{Name: "identify ring, wand or staff", Prob: 10, Worth: 115},
|
||||
{Name: "scare monster", Prob: 3, Worth: 200},
|
||||
{Name: "food detection", Prob: 2, Worth: 60},
|
||||
{Name: "teleportation", Prob: 5, Worth: 165},
|
||||
{Name: "enchant weapon", Prob: 8, Worth: 150},
|
||||
{Name: "create monster", Prob: 4, Worth: 75},
|
||||
{Name: "remove curse", Prob: 7, Worth: 105},
|
||||
{Name: "aggravate monsters", Prob: 3, Worth: 20},
|
||||
{Name: "protect armor", Prob: 2, Worth: 250},
|
||||
}
|
||||
|
||||
var baseWeapInfo = [MaxWeapons + 1]ObjInfo{
|
||||
{Name: "mace", Prob: 11, Worth: 8},
|
||||
{Name: "long sword", Prob: 11, Worth: 15},
|
||||
{Name: "short bow", Prob: 12, Worth: 15},
|
||||
{Name: "arrow", Prob: 12, Worth: 1},
|
||||
{Name: "dagger", Prob: 8, Worth: 3},
|
||||
{Name: "two handed sword", Prob: 10, Worth: 75},
|
||||
{Name: "dart", Prob: 12, Worth: 2},
|
||||
{Name: "shuriken", Prob: 12, Worth: 5},
|
||||
{Name: "spear", Prob: 12, Worth: 5},
|
||||
{}, // DO NOT REMOVE: fake entry for dragon's breath
|
||||
}
|
||||
|
||||
var baseWsInfo = [MaxSticks]ObjInfo{
|
||||
{Name: "light", Prob: 12, Worth: 250},
|
||||
{Name: "invisibility", Prob: 6, Worth: 5},
|
||||
{Name: "lightning", Prob: 3, Worth: 330},
|
||||
{Name: "fire", Prob: 3, Worth: 330},
|
||||
{Name: "cold", Prob: 3, Worth: 330},
|
||||
{Name: "polymorph", Prob: 15, Worth: 310},
|
||||
{Name: "magic missile", Prob: 10, Worth: 170},
|
||||
{Name: "haste monster", Prob: 10, Worth: 5},
|
||||
{Name: "slow monster", Prob: 11, Worth: 350},
|
||||
{Name: "drain life", Prob: 9, Worth: 300},
|
||||
{Name: "nothing", Prob: 1, Worth: 5},
|
||||
{Name: "teleport away", Prob: 6, Worth: 340},
|
||||
{Name: "teleport to", Prob: 6, Worth: 50},
|
||||
{Name: "cancellation", Prob: 5, Worth: 280},
|
||||
}
|
||||
|
||||
// rainbow is init.c rainbow[]: the possible potion colors.
|
||||
var rainbow = []string{
|
||||
"amber", "aquamarine", "black", "blue", "brown", "clear", "crimson",
|
||||
"cyan", "ecru", "gold", "green", "grey", "magenta", "orange", "pink",
|
||||
"plaid", "purple", "red", "silver", "tan", "tangerine", "topaz",
|
||||
"turquoise", "vermilion", "violet", "white", "yellow",
|
||||
}
|
||||
|
||||
// sylls is init.c sylls[]: syllables for generated scroll names.
|
||||
var sylls = []string{
|
||||
"a", "ab", "ag", "aks", "ala", "an", "app", "arg", "arze", "ash",
|
||||
"bek", "bie", "bit", "bjor", "blu", "bot", "bu", "byt", "comp",
|
||||
"con", "cos", "cre", "dalf", "dan", "den", "do", "e", "eep", "el",
|
||||
"eng", "er", "ere", "erk", "esh", "evs", "fa", "fid", "fri", "fu",
|
||||
"gan", "gar", "glen", "gop", "gre", "ha", "hyd", "i", "ing", "ip",
|
||||
"ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech",
|
||||
"mar", "me", "mi", "mic", "mik", "mon", "mung", "mur", "nej",
|
||||
"nelg", "nep", "ner", "nes", "nes", "nih", "nin", "o", "od", "ood",
|
||||
"org", "orn", "ox", "oxy", "pay", "ple", "plu", "po", "pot",
|
||||
"prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", "rol", "sa",
|
||||
"san", "sat", "sef", "seh", "shu", "ski", "sna", "sne", "snik",
|
||||
"sno", "so", "sol", "sri", "sta", "sun", "ta", "tab", "tem",
|
||||
"ther", "ti", "tox", "trol", "tue", "turs", "u", "ulk", "um", "un",
|
||||
"uni", "ur", "val", "viv", "vly", "vom", "wah", "wed", "werg",
|
||||
"wex", "whon", "wun", "xo", "y", "yot", "yu", "zant", "zeb", "zim",
|
||||
"zok", "zon", "zum",
|
||||
}
|
||||
|
||||
// stoneTable is init.c stones[]: ring stones and their worth.
|
||||
var stoneTable = []Stone{
|
||||
{"agate", 25}, {"alexandrite", 40}, {"amethyst", 50},
|
||||
{"carnelian", 40}, {"diamond", 300}, {"emerald", 300},
|
||||
{"germanium", 225}, {"granite", 5}, {"garnet", 50},
|
||||
{"jade", 150}, {"kryptonite", 300}, {"lapis lazuli", 50},
|
||||
{"moonstone", 50}, {"obsidian", 15}, {"onyx", 60},
|
||||
{"opal", 200}, {"pearl", 220}, {"peridot", 63},
|
||||
{"ruby", 350}, {"sapphire", 285}, {"stibotantalite", 200},
|
||||
{"tiger eye", 50}, {"topaz", 60}, {"turquoise", 70},
|
||||
{"taaffeite", 300}, {"zircon", 80},
|
||||
}
|
||||
|
||||
// woods is init.c wood[]: what staffs are made of.
|
||||
var woods = []string{
|
||||
"avocado wood", "balsa", "bamboo", "banyan", "birch", "cedar",
|
||||
"cherry", "cinnibar", "cypress", "dogwood", "driftwood", "ebony",
|
||||
"elm", "eucalyptus", "fall", "hemlock", "holly", "ironwood",
|
||||
"kukui wood", "mahogany", "manzanita", "maple", "oaken",
|
||||
"persimmon wood", "pecan", "pine", "poplar", "redwood", "rosewood",
|
||||
"spruce", "teak", "walnut", "zebrawood",
|
||||
}
|
||||
|
||||
// metals is init.c metal[]: what wands are made of.
|
||||
var metals = []string{
|
||||
"aluminum", "beryllium", "bone", "brass", "bronze", "copper",
|
||||
"electrum", "gold", "iron", "lead", "magnesium", "mercury",
|
||||
"nickel", "pewter", "platinum", "steel", "silver", "silicon",
|
||||
"tin", "titanium", "tungsten", "zinc",
|
||||
}
|
||||
|
||||
// helpEntry is rogue.h struct h_list.
|
||||
type helpEntry struct {
|
||||
Ch byte
|
||||
Desc string
|
||||
Print bool
|
||||
}
|
||||
|
||||
// helpStr is extern.c helpstr[]: the '?' command help text.
|
||||
var helpStr = []helpEntry{
|
||||
{'?', " prints help", true},
|
||||
{'/', " identify object", true},
|
||||
{'h', " left", true},
|
||||
{'j', " down", true},
|
||||
{'k', " up", true},
|
||||
{'l', " right", true},
|
||||
{'y', " up & left", true},
|
||||
{'u', " up & right", true},
|
||||
{'b', " down & left", true},
|
||||
{'n', " down & right", true},
|
||||
{'H', " run left", false},
|
||||
{'J', " run down", false},
|
||||
{'K', " run up", false},
|
||||
{'L', " run right", false},
|
||||
{'Y', " run up & left", false},
|
||||
{'U', " run up & right", false},
|
||||
{'B', " run down & left", false},
|
||||
{'N', " run down & right", false},
|
||||
{CTRL('H'), " run left until adjacent", false},
|
||||
{CTRL('J'), " run down until adjacent", false},
|
||||
{CTRL('K'), " run up until adjacent", false},
|
||||
{CTRL('L'), " run right until adjacent", false},
|
||||
{CTRL('Y'), " run up & left until adjacent", false},
|
||||
{CTRL('U'), " run up & right until adjacent", false},
|
||||
{CTRL('B'), " run down & left until adjacent", false},
|
||||
{CTRL('N'), " run down & right until adjacent", false},
|
||||
{0, " <SHIFT><dir>: run that way", true},
|
||||
{0, " <CTRL><dir>: run till adjacent", true},
|
||||
{'f', "<dir> fight till death or near death", true},
|
||||
{'t', "<dir> throw something", true},
|
||||
{'m', "<dir> move onto without picking up", true},
|
||||
{'z', "<dir> zap a wand in a direction", true},
|
||||
{'^', "<dir> identify trap type", true},
|
||||
{'s', " search for trap/secret door", true},
|
||||
{'>', " go down a staircase", true},
|
||||
{'<', " go up a staircase", true},
|
||||
{'.', " rest for a turn", true},
|
||||
{',', " pick something up", true},
|
||||
{'i', " inventory", true},
|
||||
{'I', " inventory single item", true},
|
||||
{'q', " quaff potion", true},
|
||||
{'r', " read scroll", true},
|
||||
{'e', " eat food", true},
|
||||
{'w', " wield a weapon", true},
|
||||
{'W', " wear armor", true},
|
||||
{'T', " take armor off", true},
|
||||
{'P', " put on ring", true},
|
||||
{'R', " remove ring", true},
|
||||
{'d', " drop object", true},
|
||||
{'c', " call object", true},
|
||||
{'a', " repeat last command", true},
|
||||
{')', " print current weapon", true},
|
||||
{']', " print current armor", true},
|
||||
{'=', " print current rings", true},
|
||||
{'@', " print current stats", true},
|
||||
{'D', " recall what's been discovered", true},
|
||||
{'o', " examine/set options", true},
|
||||
{CTRL('R'), " redraw screen", true},
|
||||
{CTRL('P'), " repeat last message", true},
|
||||
{Escape, " cancel command", true},
|
||||
{'S', " save game", true},
|
||||
{'Q', " quit", true},
|
||||
{'!', " shell escape", true},
|
||||
{'F', "<dir> fight till either of you dies", true},
|
||||
{'v', " print version number", true},
|
||||
}
|
||||
|
||||
// Version strings (vers.c). The encstr/statlist XOR keys are not ported:
|
||||
// the Go save format does not use them.
|
||||
const (
|
||||
Release = "5.4.4"
|
||||
Version = "rogue (sneak.berlin/go/rogue port of rogueforge 5.4.4)"
|
||||
)
|
||||
Reference in New Issue
Block a user