- ids = [id for id in world_db["Things"] if world_db["Things"][id] != t
- if not world_db["Things"][id]["carried"]
- if world_db["Things"][id]["T_POSY"] == t["T_POSY"]
- if world_db["Things"][id]["T_POSX"] == t["T_POSX"]]
- if len(ids):
- lowest_tid = -1
- eat_cost = eat_vs_hunger_threshold(t["T_TYPE"])
- for iid in ids:
- tid = world_db["Things"][iid]["T_TYPE"]
- if lowest_tid == -1 or tid < lowest_tid:
- if (t != world_db["Things"][0] and
- (world_db["ThingTypes"][tid]["TT_TOOL"] != "food"
- or (world_db["ThingTypes"][tid]["TT_TOOLPOWER"]
- <= eat_cost))):
- continue
- id = iid
- lowest_tid = tid
- world_db["Things"][id]["carried"] = True
- ty = world_db["Things"][id]["T_TYPE"]
- if (t != world_db["Things"][0]
- and world_db["Things"][id]["T_PLAYERDROP"]
- and world_db["ThingTypes"][ty]["TT_TOOL"] == "food"):
- score = int(world_db["ThingTypes"][ty]["TT_TOOLPOWER"] / 32)
+ from server.actions import actor_pickup
+ t_picked = actor_pickup(t)
+ if t_picked != None:
+ ty = world_db["ThingTypes"][t_picked["T_TYPE"]]
+ if t != world_db["Things"][0] and t_picked["T_PLAYERDROP"] \
+ and ty["TT_TOOL"] == "food":
+ score = int(ty["TT_TOOLPOWER"] / 32)