Implemented hyperspace jump cost

This commit is contained in:
Luxferre
2024-01-21 22:00:22 +02:00
parent 3db87a7265
commit 35c38bcd66
+11 -5
View File
@@ -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