awlite

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

commit 271bcec60db4e7d6e2e18c479cef05c4e3cad550
parent 017b29dae98baf2d2cf4c9cc9c9c15b8118be6f9
Author: Luxferre <lux@ferre>
Date:   Mon, 22 Jan 2024 09:11:04 +0200

Limited cargo bay upgrades

Diffstat:
Mawlite.awk | 51++++++++++++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 21 deletions(-)

diff --git a/awlite.awk b/awlite.awk @@ -10,7 +10,8 @@ # 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) +# - galaxy jumps are no longer free and cost 5000 credits each (like in classic Elite and Oolite) +# - cargo hold expansion also is non-free (400 credits) and can only be done once from 20t to 35t # - 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 @@ -406,6 +407,14 @@ function doinfo(s, dest, si) { # hold command implementation function dohold(a, t, i) { + if(player["holdspace"] >= game["cargoexpsize"]) { + printf("\nExpansion not possible! The cargo bay already is at maximum capacity") + return 0 + } + if(player["cash"] < game["cargoexpcost"]) { + printf("\nNot enough cash! Need %.1f CR for upgrading the cargo bay", game["cargoexpcost"]/10) + return 0 + } t = 0 a = int(a) for(i=0;i<=IDX_ALIEN_ITEMS;i++) @@ -491,24 +500,22 @@ function domkt() { # display help function dohelp() { - printf("\nCommands are:"); - printf("\nBuy tradegood amount"); - printf("\nSell tradegood amount"); - printf("\nFuel amount (buy amount LY of fuel)"); - printf("\nJump planetname (limited by fuel)"); - if(CHEAT) - printf("\nSneak planetname (any distance - no fuel cost)"); - printf("\nGalhyp (jumps to next galaxy)"); - printf("\nInfo planetname (prints info on system)"); - printf("\nMkt (shows market prices)"); - printf("\nLocal (lists systems within 7 light years)"); - if(CHEAT) - printf("\nCash number (alters cash - cheating!)"); - printf("\nHold number (change cargo bay)"); - printf("\nQuit or ^C (exit)"); - printf("\nHelp (display this text)"); - printf("\nRand (toggle RNG)"); - printf("\n\nAbbreviations allowed eg. b fo 5 = Buy Food 5, m= Mkt"); + printf("\nCommands are:") + printf("\nBuy product amount") + printf("\nSell product amount") + printf("\nFuel amount (buy amount LY of fuel)") + printf("\nJump planetname (limited by fuel)") + if(CHEAT) printf("\nSneak planetname (any distance - no fuel cost)") + printf("\nGalhyp (jumps to next galaxy)") + printf("\nInfo planetname (prints info on system)") + printf("\nMkt (shows market prices)") + printf("\nLocal (lists systems within 7 light years)") + if(CHEAT) printf("\nCash number (alters cash - cheating!)") + printf("\nHold (expand cargo bay to %dt)", game["cargoexpsize"]) + printf("\nQuit or ^D (exit)") + printf("\nHelp (display this text)") + printf("\nRand (toggle RNG)") + printf("\n\nAbbreviations allowed eg. b fo 5 = Buy Food 5, m= Mkt") } # Game init procedure: first thing to call in the BEGIN block @@ -520,13 +527,15 @@ function gameinit() { split("",game) # overall game state is stored here game["use_native_rand"] = 1 game["galhypcost"] = 50000 # 5000 CR + game["cargoexpcost"] = 4000 # 400 CR for one-time upgrade + game["cargoexpsize"] = 35 # 35t after the upgrade game["fuelcost"] = 2 # 0.2 CR/lightyear game["maxfuel"] = 70 # 7.0 LY tank split("",player) # current (saveable) player state is stored here player["currentplanet"] = numForLave # current planet (1 to 256) player["galaxynum"] = 1 # current galaxy (1 to 8) - player["cash"] = 1000 # current cash + player["cash"] = 1000 # current cash (100 CR) player["fuel"] = game["maxfuel"] # current fuel amount player["holdspace"] = 20 # max cargo hold space split("",shipshold) # (saveable) contents of cargo bay, up to 16 items @@ -625,7 +634,7 @@ BEGIN { else if(action == "s" || action == "sell") dosell(paramstr) else if(action == "j" || action == "jump") dojump(paramstr) else if(action == "f" || action == "fuel") dofuel(paramstr) - else if(action == "ho" || action == "hold") dohold(paramstr) + else if(action == "ho" || action == "hold") dohold(game["cargoexpsize"]) else if(CHEAT && action == "cash") docash(paramstr) else if(CHEAT && action == "sneak") dosneak(paramstr) else printf("Unknown command")