home · contact · privacy
(Tentative: Contains bugs!) Add carpentry, building walls from wood.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 13 Mar 2015 00:13:53 +0000 (01:13 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 13 Mar 2015 00:13:53 +0000 (01:13 +0100)
SERVER_COMMANDS
confserver/world
roguelike-server
src/client/draw_wins.c
src/server/libplomrogue.c

index aa147c01128e4570a196de6d3503e1b88630eef7..e408a43e3a3b03b16b1980991ce6cf6145bd4cc3 100644 (file)
@@ -251,5 +251,4 @@ PLANT_0 [0 to infinity]
 
 LUMBER [0 to infinity]
 
-TT_TOOLS gain the "axe" argument.
-
+TT_TOOLS gains the arguments "axe", "carpentry", "wood".
index 9aa0d5700e62729b960b44f140de4b7b4bc53faf..452e9df48066be198315ebdf1121ea013b936027 100644 (file)
@@ -100,10 +100,18 @@ TT_TOOLPOWER 5000
 TT_START_NUMBER 1
 
 TT_ID 10
+TT_TOOL wood
 TT_START_NUMBER 0
 TT_SYMBOL =
 TT_NAME WOOD
 
+TT_ID 11
+TT_TOOL carpentry
+TT_SYMBOL -
+TT_NAME 'CARPENTRY TOOL'
+TT_TOOLPOWER 5000
+TT_START_NUMBER 1
+
 TT_ID 0
 TT_CORPSE_ID 6
 TT_ID 1
index 6b7d8ca075e001724f72e15baec3d449911a9fc0..a1da325c4abc7424a8db0505bd339dec3ca2ce23 100755 (executable)
@@ -495,7 +495,7 @@ def make_map():
         pos = (y * length) + x  # #
         if (("." == chr(world_db["MAP"][pos]  # #
              or ":" == chr(world_db["MAP"][pos]))
-            and not is_neighbor((y, x), 'X'))):  # #
+            and not is_neighbor((y, x), "X"))):  # #
             world_db["MAP"][pos] = ord("_")  # #
             world_db["altar"] = (y, x)  # #
             altar_placed = True  # #
@@ -762,7 +762,8 @@ def actor_move(t):
             if test and t == world_db["Things"][0]:  # #
                 add_gods_favor(-test)  # #
             return
-        if ord("X") == world_db["MAP"][pos]:  # #
+        if (ord("X") == world_db["MAP"][pos]  # #
+            or ord("|") == world_db["MAP"][pos]):  # #
             carries_axe = False  # #
             for id in t["T_CARRIES"]:  # # 
                 type = world_db["Things"][id]["T_TYPE"]  # #
@@ -777,16 +778,23 @@ def actor_move(t):
                                                     + ", you chop!\n")  # #
                     add_gods_favor(-1)  # #
                 chop_power = world_db["ThingTypes"][type]["TT_TOOLPOWER"]
-                if chop_power > 0 and 0 == int(rand.next() / chop_power):  # #
+                case_X = world_db["MAP"][pos] == ord("X")  # #
+                if (chop_power > 0  # #
+                    and ((case_X and  # #
+                          0 == int(rand.next() / chop_power))  # #
+                    or (not case_X and  # #
+                             0 == int(rand.next() / (3 * chop_power))))):  # #
                     if t == world_db["Things"][0]:  # #
                         strong_write(io_db["file_out"],  # #
-                                     "LOG You chop the tree down.\n")  # #
+                                     "LOG You chop it down.\n")  # #
                     add_gods_favor(-10)  # #
                     world_db["MAP"][pos] = ord(".")   # #
-                    id = id_setter(-1, "Things")  # #
-                    world_db["Things"][id] = new_Thing(world_db["LUMBER"],  # #
-                                                       (move_result[1],  # #
-                                                        move_result[2]))  # # 
+                    i = 3 if case_X else 1  # #
+                    for i in range(i):  # #
+                        id = id_setter(-1, "Things")  # #
+                        world_db["Things"][id] = \
+                          new_Thing(world_db["LUMBER"],  # #
+                                    (move_result[1], move_result[2]))  # # 
                     build_fov_map(t)  # #
                 return   # #
         passable = ("." == chr(world_db["MAP"][pos]) or
@@ -885,6 +893,47 @@ def actor_use(t):
                              "LOG To use this item for chopping, move "  # #
                              "towards a tree while carrying it in "  # #
                              "your inventory.\n")  # #
+        elif (world_db["ThingTypes"][type]["TT_TOOL"] == "carpentry"):  # #
+            pos = t["T_POSY"] * world_db["MAP_LENGTH"] + t["T_POSX"]
+            if (world_db["MAP"][pos] == ord("X")  # #
+                or world_db["MAP"][pos] == ord("|")):  # #
+                strong_write(io_db["file_out"],  # #
+                             "LOG Can't build when standing on barrier.\n")  # #
+                return
+            for id in [id for id in world_db["Things"]
+                       if not 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"]]:
+                 strong_write(io_db["file_out"],
+                              "LOG Can't build when standing objects.\n")  # #
+                 return
+            for id in t["T_CARRIES"]:  # #
+                type_tool = world_db["Things"][id]["T_TYPE"]  # #
+                if (world_db["ThingTypes"][type_tool]["TT_TOOL"]  # #
+                    == "carpentry"):  # #
+                    break  # #
+            wood_id = None  # #
+            for id in t["T_CARRIES"]:  # #
+                type_material = world_db["Things"][id]["T_TYPE"]  # #
+                if (world_db["ThingTypes"][type_material]["TT_TOOL"]  # #
+                    == "wood"):  # #
+                    wood_id = id  # #
+                    break  # #
+            if wood_id != None:  # #
+                t["T_CARRIES"].remove(wood_id)  # #
+                del world_db["Things"][wood_id]  # #
+                world_db["MAP"][pos] = ord("|")  # #
+                strong_write(io_db["file_out"], "LOG With your "  # #
+                             + world_db["ThingTypes"][type_tool]["TT_NAME"]  # #
+                             + " you build a wooden barrier from your "  # #
+                             + world_db["ThingTypes"][type_material]  # #
+                               ["TT_NAME"]  # #
+                             + ".\n")  # #
+            else:  # #
+                strong_write(io_db["file_out"], "LOG You can't use a "  # #
+                             + world_db["ThingTypes"][type_tool]["TT_NAME"]  # #
+                             + " without some wood in your inventory.\n")  # #
         elif world_db["ThingTypes"][type]["TT_TOOL"] == "food":
             t["T_CARRIES"].remove(id)
             del world_db["Things"][id]
@@ -1232,7 +1281,7 @@ def turn_over():
                    if not world_db["Things"][id]["carried"]]:
             y = world_db["Things"][id]["T_POSY"]
             x = world_db["Things"][id]["T_POSX"]
-            proliferable_map[y * world_db["MAP_LENGTH"] + x] = ord('X')
+            proliferable_map[y * world_db["MAP_LENGTH"] + x] = ord("X")
         for id in [id for id in world_db["Things"]]:  # Only what's from start!
             if not id in world_db["Things"] or \
                world_db["Things"][id]["carried"]:   # May have been consumed or
index 940b76813b2ecbb0711740288f7e3225ff38aa7e..d0d460c3ceccfaf2669f0b40f2ca0e04b6b618e3 100644 (file)
@@ -365,7 +365,7 @@ extern void draw_win_log(struct Win * win)
         }
     }
     if (n_postbreak_lines > win->frame_size.y)
-    {
+    { 
         uint32_t size = n_postbreak_lines * (win->frame_size.x + 1);
         win->winmap = try_malloc(sizeof(chtype) * size, __func__);
         for (i = 0; i < size; win->winmap[i] = ' ', i++);
@@ -398,7 +398,7 @@ extern void draw_win_map(struct Win * win)
             { //
                 a = COLOR_PAIR(1); //
             } //
-            else if (c_m == 'X') //
+            else if (c_m == 'X' || c_m == '|') //
             { //
                 a = COLOR_PAIR(3); //
             } //
@@ -448,11 +448,11 @@ extern void draw_win_map(struct Win * win)
                 { //
                     a = COLOR_PAIR(9); //
                 } //
-                else if ('m' == c || '/' == c) //
+                else if ('m' == c || '/' == c || '-' == c) //
                 { //
                     a = COLOR_PAIR(10); //
                 } //
-                else if ('X' == c) //
+                else if ('X' == c || '|' == c) //
                 { //
                     a = COLOR_PAIR(11); //
                 } //
index e8ff9ae950f7a90b05998cbf236d59e06232d1ed..c7fb5ce4fa67ddd757bc00a914a545fe6891a5af 100644 (file)
@@ -357,7 +357,8 @@ static uint8_t eval_position(uint16_t dist, uint16_t hex_i, char * fov_map,
     uint16_t pos_in_map = test_pos->y * maplength + test_pos->x;
     uint8_t all_shaded = shade_hex(left_angle, right_angle_1st, middle_angle,
                                    shadows, pos_in_map, fov_map);
-    if (!all_shaded && 'X' == worldmap[pos_in_map])
+    if (!all_shaded && ('X' == worldmap[pos_in_map]
+                        || '|' == worldmap[pos_in_map]))  //
     {
         if (set_shadow(left_angle, right_angle_1st, shadows))
         {