home
·
contact
·
privacy
projects
/
plomrogue
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
53de46c
)
Simplify hunger() with Python's built-in abs().
author
Christian Heller
<c.heller@plomlompom.de>
Sat, 14 Mar 2015 00:41:44 +0000
(
01:41
+0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Sat, 14 Mar 2015 00:41:44 +0000
(
01:41
+0100)
roguelike-server
patch
|
blob
|
history
diff --git
a/roguelike-server
b/roguelike-server
index 7a61c81bec1fedbcf98476981dfbb65fe566089a..41506c0800e22f2e115d4a86c3d5936188ddba3c 100755
(executable)
--- a/
roguelike-server
+++ b/
roguelike-server
@@
-1092,11
+1092,11
@@
def hunger(t):
"""Decrement t's satiation,dependent on it trigger lifepoint dec chance."""
if t["T_SATIATION"] > -32768:
t["T_SATIATION"] -= 1
"""Decrement t's satiation,dependent on it trigger lifepoint dec chance."""
if t["T_SATIATION"] > -32768:
t["T_SATIATION"] -= 1
- testbase = t["T_SATIATION"] if t["T_SATIATION"] >= 0 else -t["T_SATIATION"]
if not world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"]:
raise RuntimeError("A thing that should not hunger is hungering.")
stomach = int(32767 / world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"])
if not world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"]:
raise RuntimeError("A thing that should not hunger is hungering.")
stomach = int(32767 / world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"])
- if int(int(testbase / stomach) / ((rand.next() % stomach) + 1)):
+ if int(int(abs(t["T_SATIATION"]) / stomach)
+ / ((rand.next() % stomach) + 1)):
if t == world_db["Things"][0]:
if t["T_SATIATION"] < 0:
strong_write(io_db["file_out"], "LOG You suffer from hunger.\n")
if t == world_db["Things"][0]:
if t["T_SATIATION"] < 0:
strong_write(io_db["file_out"], "LOG You suffer from hunger.\n")