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:
9330c75
)
Enhance sanity of get_inventory_slot_to_consume.
author
Christian Heller
<c.heller@plomlompom.de>
Sat, 14 Mar 2015 03:14:06 +0000
(
04:14
+0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Sat, 14 Mar 2015 03:14:06 +0000
(
04:14
+0100)
roguelike-server
patch
|
blob
|
history
diff --git
a/roguelike-server
b/roguelike-server
index c5b50db90d44aa18fece591748ca8435623383c2..29fe11994b79c15bca1ac95536f788cb16345e21 100755
(executable)
--- a/
roguelike-server
+++ b/
roguelike-server
@@
-1310,16
+1310,20
@@
def standing_on_food(t):
def get_inventory_slot_to_consume(t):
def get_inventory_slot_to_consume(t):
- """Return slot Id of
strong
est consumable in t's inventory, else -1."""
- cmp_food =
0
+ """Return slot Id of
healthi
est consumable in t's inventory, else -1."""
+ cmp_food =
-1
selection = -1
i = 0
for id in t["T_CARRIES"]:
type = world_db["Things"][id]["T_TYPE"]
if world_db["ThingTypes"][type]["TT_TOOL"] == "food" \
selection = -1
i = 0
for id in t["T_CARRIES"]:
type = world_db["Things"][id]["T_TYPE"]
if world_db["ThingTypes"][type]["TT_TOOL"] == "food" \
- and world_db["ThingTypes"][type]["TT_TOOLPOWER"] > cmp_food:
- cmp_food = world_db["ThingTypes"][type]["TT_TOOLPOWER"]
- selection = i
+ and world_db["ThingTypes"][type]["TT_TOOLPOWER"]:
+ nutvalue = world_db["ThingTypes"][type]["TT_TOOLPOWER"]
+ tmp_cmp = abs(t["T_SATIATION"] + nutvalue)
+ if (cmp_food < 0 and tmp_cmp < abs(t["T_SATIATION"])) \
+ or tmp_cmp < cmp_food:
+ cmp_food = tmp_cmp
+ selection = i
i += 1
return selection
i += 1
return selection