- Making the new highlight/select bindings work

- script to move selected regions
This commit is contained in:
Enno Rehling 2006-05-25 22:34:58 +00:00
parent 964387c834
commit 6b835e9b82
4 changed files with 41 additions and 9 deletions

View File

@ -523,17 +523,16 @@ max_magicians(const faction * f)
int int
max_skill(faction * f, skill_t sk) max_skill(faction * f, skill_t sk)
{ {
int m = INT_MAX; int m = INT_MAX;
int al = allied_skilllimit(f, sk);
if (allied_skilllimit(f, sk)) { if (al>0) {
if (sk!=SK_ALCHEMY && sk!=SK_MAGIC) return INT_MAX; if (sk!=SK_ALCHEMY && sk!=SK_MAGIC) return INT_MAX;
if (f->alliance!=NULL) { if (f->alliance!=NULL) {
int ac = listlen(f->alliance->members); /* number of factions */ int ac = listlen(f->alliance->members); /* number of factions */
int al = allied_skilllimit(f, sk); /* limit per alliance */ int fl = (al+ac-1)/ac; /* faction limit, rounded up */
int fl = (al+ac-1)/ac; /* faction limit */ /* the faction limit may not be achievable because it would break the alliance-limit */
/* the following ist _very_ weird, please examine */
int sc = al - allied_skillcount(f, sk); int sc = al - allied_skillcount(f, sk);
if (sc==0) return count_skill(f, sk); if (sc<=0) return 0;
return fl; return fl;
} }
} }

View File

@ -243,7 +243,7 @@ init_curses(void)
if (has_colors() || force_color) { if (has_colors() || force_color) {
short bcol = COLOR_BLACK; short bcol = COLOR_BLACK;
short hcol = COLOR_CYAN; short hcol = COLOR_MAGENTA;
start_color(); start_color();
#ifdef WIN32 #ifdef WIN32
/* looks crap on putty with TERM=linux */ /* looks crap on putty with TERM=linux */
@ -698,7 +698,7 @@ highlight_region(region *r)
} }
void void
select_coordinate(selection * selected, int x, int y) select_coordinate(struct selection * selected, int x, int y)
{ {
coordinate coord = { 0 }; coordinate coord = { 0 };
coord.x = x; coord.x = x;

View File

@ -15,6 +15,7 @@
extern "C" { extern "C" {
#endif #endif
struct lua_State; struct lua_State;
struct selection;
extern int gmmain(int argc, char *argv[]); extern int gmmain(int argc, char *argv[]);
extern int curses_readline(struct lua_State * L, const char * prompt); extern int curses_readline(struct lua_State * L, const char * prompt);

32
src/scripts/gm/move.lua Normal file
View File

@ -0,0 +1,32 @@
swapx = 0
swapy = 0
function swap_region(r, tr)
local sr = get_region(swapx, swapy)
while sr~=nil do
swapx = math.random(1000)
swapy = math.random(1000)
sr = get_region(swapx, swapy)
end
local tx = tr.x
local ty = tr.y
local x = r.x
local y = r.y
tr:move(swapx, swapy)
r:move(tx, ty)
tr:move(x, y)
end
function move_selection(x, y)
for r in gmtool.selection() do
local tx = r.x+x
local ty = r.y+y
local tr = get_region(tx, ty)
if tr~=nil then
swap_region(r, tr)
else
r:move(tx, ty)
end
end
end