MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | // MorgenGrauen MUDlib |
| 2 | // |
| 3 | // living/clothing.c -- Modul fuer Bekleidungsfragen. ;-) |
| 4 | // |
| 5 | // $Id: armour.c,v 3.8 2003/08/25 09:36:04 Rikus Exp $ |
| 6 | #pragma strong_types |
| 7 | #pragma save_types |
| 8 | #pragma range_check |
| 9 | #pragma no_clone |
| 10 | #pragma pedantic |
| 11 | |
| 12 | #define NEED_PROTOTYPES |
| 13 | #include <thing/properties.h> |
| 14 | #undef NEED_PROTOTYPES |
| 15 | #include <living/clothing.h> |
| 16 | #include <living/combat.h> |
| 17 | #include <armour.h> |
| 18 | |
| 19 | protected void create() { |
| 20 | SetProp(P_CLOTHING, ({})); |
| 21 | Set(P_CLOTHING, PROTECTED, F_MODE_AS); |
| 22 | } |
| 23 | |
| 24 | public object *FilterClothing(closure filterfun, varargs mixed* extra) { |
| 25 | if (!closurep(filterfun)) |
| 26 | return ({}); |
| 27 | return apply(#'filter, QueryProp(P_CLOTHING), filterfun, extra); |
| 28 | } |
| 29 | |
| 30 | public object *FilterArmours(closure filterfun, varargs mixed* extra) { |
| 31 | if (!closurep(filterfun)) |
| 32 | return ({}); |
| 33 | return apply(#'filter, QueryProp(P_ARMOURS)-({0}), filterfun, extra); |
| 34 | } |
| 35 | |
| 36 | public int WearClothing(object ob) { |
| 37 | object *clothing = QueryProp(P_CLOTHING); |
| 38 | if (member(clothing, ob) != -1) |
| 39 | return 0; |
| 40 | clothing += ({ob}); |
| 41 | SetProp(P_CLOTHING, clothing); |
| 42 | return 1; |
| 43 | } |
| 44 | |
| 45 | public int WearArmour(object ob) { |
| 46 | if (!VALID_ARMOUR_TYPE(ob->QueryProp(P_ARMOUR_TYPE))) |
| 47 | return 0; |
| 48 | |
| 49 | object *armours = QueryProp(P_ARMOURS); |
| 50 | if (member(armours, ob) != -1) |
| 51 | return 0; |
| 52 | |
| 53 | armours += ({ob}); |
| 54 | SetProp(P_ARMOURS, armours); |
| 55 | return 1; |
| 56 | } |
| 57 | |
| 58 | public int Wear(object ob) { |
| 59 | // reihenfolge ist wichtig! Ruestung sind _auch_ Kleidung, aber Kleidung |
| 60 | // keine Ruestung. |
| 61 | if (ob->IsArmour()) |
| 62 | return WearArmour(ob); |
| 63 | else if (ob->IsClothing()) |
| 64 | return WearClothing(ob); |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | public int UnwearClothing(object ob) { |
| 69 | object *clothing = QueryProp(P_CLOTHING); |
| 70 | if (member(clothing, ob) == -1) |
| 71 | return 0; |
| 72 | clothing -= ({ob}); |
| 73 | SetProp(P_CLOTHING, clothing); |
| 74 | return 1; |
| 75 | } |
| 76 | |
| 77 | public int UnwearArmour(object ob) { |
| 78 | object *armours = QueryProp(P_ARMOURS); |
| 79 | if (member(armours, ob) == -1) |
| 80 | return 0; |
| 81 | |
| 82 | armours -= ({ob}); |
| 83 | SetProp(P_ARMOURS, armours); |
| 84 | return 1; |
| 85 | } |
| 86 | |
| 87 | public int Unwear(object ob) { |
| 88 | // reihenfolge ist wichtig! Ruestung sind _auch_ Kleidung, aber Kleidung |
| 89 | // keine Ruestung. |
| 90 | if (ob->IsArmour()) |
| 91 | return UnwearArmour(ob); |
| 92 | else if (ob->IsClothing()) |
| 93 | return UnwearClothing(ob); |
| 94 | return 0; |
| 95 | } |
| 96 | |