v1.6.3: now galaxies are named

This commit is contained in:
Luxferre
2024-01-23 17:26:27 +02:00
parent 7e3495527d
commit d8d85a27c4
2 changed files with 14 additions and 8 deletions
+11 -7
View File
@@ -1,5 +1,5 @@
# awlite: POSIX AWK port of Text Elite
# Version 1.6.2
# Version 1.6.3
# Original high-level algorithms from Text Elite 1.5 by Ian Bell, 1999, 2015
# Porting, corrections, improvements and optimizations by Luxferre, 2024
#
@@ -18,7 +18,8 @@
# - market and local info tables are better aligned
# - the "cash" and "sneak" commands are removed since v1.6 (use saves to cheat)
# - state saving functionality since v1.6 with "save" and "load" commands
# - since 1.6.1, the game gives you a hint if you might have found Raxxla
# - since v1.6.1, the game gives you a hint if you might have found Raxxla
# - since v1.6.3, galaxy names are actually displayed (taken from ArcElite)
# ... to be continued ...
# utility functions
@@ -221,13 +222,13 @@ function buildgalaxy(gnum, seeds, si, i) {
asplit("23114 584 46931", seeds, " ")
for(i=1;i<gnum;i++) galswitch(seeds)
split("", galaxy) # global galaxy array
split("", galnames) # global galaxy names array
split("", plannames) # global galaxy planet names array
split("", economies) # economy mapping
for(i=0;i<galsize;i++) {
split("", si) # init a new system info array
makesystem(seeds, si) # populate it
galaxy[i] = assocser(si, "|") # serialize into the field
galnames[i] = si["name"] # populate the name
plannames[i] = si["name"] # populate the name
galcoords_x[i] = si["x"] # populate x coordinate
galcoords_y[i] = si["y"] # populate y coordinate
economies[i] = si["economy"] # populate economy type
@@ -322,7 +323,7 @@ function matchsys(s, d, i, p, cd) {
d = 9999
s = toupper(s) # system names are stored in uppercase
for(i=0;i<galsize;i++) {
if(index(s, galnames[i]) == 1) { # found i-th system
if(index(s, plannames[i]) == 1) { # found i-th system
cd = distance(galcoords_x[i], galcoords_y[i], galcoords_x[p], galcoords_y[p])
if(cd < d) {d = cd; p = i}
}
@@ -337,7 +338,7 @@ function dotweakrand() { game["use_native_rand"] = 1 - game["use_native_rand"] }
# local command implementation
function dolocal(d, i, p, si) {
printf("Galaxy number %i", player["galaxynum"])
printf("\nGalaxy %i - %s\n", player["galaxynum"], galnames[player["galaxynum"]])
p = int(player["currentplanet"])
for(i=0;i<galsize;i++) {
d = distance(galcoords_x[i], galcoords_y[i], galcoords_x[p], galcoords_y[p])
@@ -547,6 +548,9 @@ function gameinit() {
# unit names
asplit("t kg g", unitnames, " ")
# galaxy names (1-indexed)
split("Santaari Colesque Lara'tan Angiana Proximus Sol Jaftra Xrata", galnames, " ")
# government names
asplit("Anarchy,Feudal,Multi-gov,Dictatorship,Communist,Confederacy,Democracy,Corporate State", govnames, ",")
@@ -616,7 +620,7 @@ BEGIN {
split("", globalseeds) # init galaxy seeds
buildgalaxy(player["galaxynum"], globalseeds) # build the current galaxy
genmarket(0, economies[player["currentplanet"]]) # build local market
printf("\nWelcome to awlite 1.6.2\n")
printf("\nWelcome to awlite 1.6.3\n")
dohelp()
# start the REPL
printf("\n\nCash: %.1f> ", player["cash"]/10)