X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=plomrogue-server.py;h=eb1267157f2a6598c347e10ab7b895721c7090cc;hb=f64676dc1f4da35e687031c868ac551dafc0e190;hp=0c82f05996e8bd6f6e0307305ea1b96323a59621;hpb=5797646d53448d99a5d6c0e031b16e8ee78a8edb;p=plomrogue diff --git a/plomrogue-server.py b/plomrogue-server.py index 0c82f05..eb12671 100755 --- a/plomrogue-server.py +++ b/plomrogue-server.py @@ -86,7 +86,7 @@ def obey(command, prefix, replay=False, do_record=False): if do_record: record(command) save_world() - else: + elif 0 != len(tokens): print("Invalid command/argument, or bad number of tokens.") @@ -131,6 +131,8 @@ def save_world(): tt_string = tt_string + "TT_ID " + str(id) + "\n" + \ "TT_CONSUMABLE " + \ str(tt["TT_CONSUMABLE"]) + "\n" + \ + "TT_LIFEPOINTS " + \ + str(tt["TT_LIFEPOINTS"]) + "\n" + \ "TT_CORPSE_ID " + \ str(tt["TT_CORPSE_ID"]) + "\n" + \ "TT_PROLIFERATE " + \ @@ -277,7 +279,7 @@ def set_world_inactive(): def integer_test(val_string, min, max): - """Return val_string if possible integer >= min and <= max, else False.""" + """Return val_string if possible integer >= min and <= max, else None.""" try: val = int(val_string) if val < min or val > max: @@ -286,7 +288,7 @@ def integer_test(val_string, min, max): except ValueError: print("Ignoring: Please use integer >= " + str(min) + " and <= " + str(max) + ".") - return False + return None def worlddb_value_setter(key, min, max): @@ -356,7 +358,7 @@ def command_ttid(id_string): >255, a new ID is calculated: the lowest unused ID >=0 and <= 255. """ id = integer_test(id_string, -32768, 32767) - if id: + if None != id: if id in world_db["ThingTypes"]: command_ttid.id = id else: @@ -374,6 +376,7 @@ def command_ttid(id_string): world_db["ThingTypes"][id] = { "TT_NAME": "(none)", "TT_CONSUMABLE": 0, + "TT_LIFEPOINTS": 0, "TT_PROLIFERATE": 0, "TT_START_NUMBER": 0, "TT_SYMBOL": "?", @@ -402,7 +405,7 @@ def ThingType_value_setter(key, min, max): @test_ThingType_id def f(val_string): val = integer_test(val_string, min, max) - if val: + if None != val: world_db["ThingTypes"][command_ttid.id][key] = val return f @@ -426,7 +429,7 @@ def command_ttsymbol(char): def command_ttcorpseid(str_int): """Set to int(str_int) TT_CORPSE_ID of selected ThingType.""" val = integer_test(str_int, 0, 255) - if val: + if None != val: if val in world_db["ThingTypes"]: world_db["ThingTypes"][command_ttid.id]["TT_CORPSE_ID"] = val else: @@ -441,7 +444,7 @@ def command_taid(id_string): is calculated: The lowest unused ID >0 and <= 255. """ id = integer_test(id_string, 0, 255) - if id: + if None != id: if id in world_db["ThingActions"]: command_taid.id = id else: @@ -468,7 +471,7 @@ test_ThingAction_id = test_for_id_maker(command_taid, "ThingAction") def command_taeffort(str_int): """Set to int(str_int) TA_EFFORT of selected ThingAction.""" val = integer_test(str_int, 0, 255) - if val: + if None != val: world_db["ThingActions"][command_taid.id]["TA_EFFORT"] = val @@ -525,7 +528,9 @@ commands_db = { "TT_START_NUMBER": (1, False, ThingType_value_setter("TT_START_NUMBER", 0, 255)), "TT_PROLIFERATE": (1, False, ThingType_value_setter("TT_PROLIFERATE", - 0, 255)) + 0, 255)), + "TT_LIFEPOINTS": (1, False, ThingType_value_setter("TT_LIFEPOINTS", + 0, 255)) }