awlite

POSIX AWK port of Text Elite game
git clone git://git.luxferre.top/awlite.git
Log | Files | Refs

commit 35c38bcd66dafdb102536020e7e706d089498a90
parent 3db87a7265437ed1ae3b6feb1b7d6fbead4d24e4
Author: Luxferre <lux@ferre>
Date:   Sun, 21 Jan 2024 22:00:22 +0200

Implemented hyperspace jump cost

Diffstat:
Mawlite.awk | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/awlite.awk b/awlite.awk @@ -1,7 +1,7 @@ # awlite: POSIX AWK port of Text Elite 1.5 -# Version 1.5.1-alpha +# Version 1.5.2 # Original C version by Ian Bell, 1999, 2015 -# Porting, corrections and optimizations by Luxferre, 2024 +# Porting, corrections, improvements and optimizations by Luxferre, 2024 # # Tested on: nawk/one-true-awk, busybox awk, gawk --posix, mawk -W posix # Should run on any current POSIX-compliant AWK implementation but @@ -10,6 +10,7 @@ # Gameplay differences from the original C version of TE 1.5: # - multiple typos corrected in text strings # - the "cash" and "sneak" commands are only available to the REPL if running with -v CHEAT=1 +# - galaxy jumps are no longer free and cost 5000 credits each (like in OOlite) # - alien items are available by default, can be overridden with -v NO_ALIEN_ITEMS=1 # - economy names are no longer shortened # - the "politically correct" goods names are turned on with -v CENSORED=1 @@ -387,9 +388,13 @@ function dosneak(s, kp, r) { # jump to next galaxy (planet number is preserved) function dogalhyp() { - player["galaxynum"]++ - if(player["galaxynum"] == 9) player["galaxynum"] = 1 - buildgalaxy(player["galaxynum"], globalseeds) # build a new galaxy + if(player["cash"] > game["galhypcost"]) { + player["cash"] -= game["galhypcost"] + player["galaxynum"]++ + if(player["galaxynum"] == 9) player["galaxynum"] = 1 + buildgalaxy(player["galaxynum"], globalseeds) # build a new galaxy + } + else printf("Not enough credits for hyperspace jump!\nMust have at least %.1f CR", game["galhypcost"]/10) } # print planet info @@ -514,6 +519,7 @@ function gameinit() { split("",game) # overall game state is stored here game["use_native_rand"] = 1 + game["galhypcost"] = 50000 # 5000 CR game["fuelcost"] = 2 # 0.2 CR/lightyear game["maxfuel"] = 70 # 7.0 LY tank