From: Christian Heller Date: Fri, 13 Mar 2015 00:13:53 +0000 (+0100) Subject: (Tentative: Contains bugs!) Add carpentry, building walls from wood. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/static/ledger?a=commitdiff_plain;h=7363d6d3949f5d698223cf56170b9d2167377ed5;p=plomrogue (Tentative: Contains bugs!) Add carpentry, building walls from wood. --- diff --git a/SERVER_COMMANDS b/SERVER_COMMANDS index aa147c0..e408a43 100644 --- a/SERVER_COMMANDS +++ b/SERVER_COMMANDS @@ -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". diff --git a/confserver/world b/confserver/world index 9aa0d57..452e9df 100644 --- a/confserver/world +++ b/confserver/world @@ -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 diff --git a/roguelike-server b/roguelike-server index 6b7d8ca..a1da325 100755 --- a/roguelike-server +++ b/roguelike-server @@ -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 diff --git a/src/client/draw_wins.c b/src/client/draw_wins.c index 940b768..d0d460c 100644 --- a/src/client/draw_wins.c +++ b/src/client/draw_wins.c @@ -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); // } // diff --git a/src/server/libplomrogue.c b/src/server/libplomrogue.c index e8ff9ae..c7fb5ce 100644 --- a/src/server/libplomrogue.c +++ b/src/server/libplomrogue.c @@ -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)) {